Andrew BerryAdam O' CeallaighJack DuffSpivey
Published

Coffee Counter with Wia Dot One, Button and TFT Screen

In this tutorial we will be going over how to use the Wia Dot One, TFT Module, and Smart Button Module to create a coffee counter.

AdvancedFull instructions provided1 hour189

Things used in this project

Hardware components

Wia Dot One
Wia Dot One
×1
Wia Button Module
Wia Button Module
×1
Wia TFT LCD Screen Module
Wia TFT LCD Screen Module
×1
Wia Micro USB Cable
Wia Micro USB Cable
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
Must have at least 400 tie points
×1
Micro USB 16340 Lithium Battery Shield Mobile Power Holder Adapter For Arduino
×1

Software apps and online services

Wia
Wia

Story

Read more

Custom parts and enclosures

Coffee Counter Case Main

Be careful when putting the breadboard, with the TFT Screen and Button Module and Wia Dot One in this main portion of the case because they are all sensitive so do not push very hard. If need be sand down portions of the case for better fitment.
Also the position of the three components is specific to how I set up this project and yours may differ so if you are using this case be sure to take that into account and adjust yours to fit by moving components around on the breadboard and adjust the position of the Dot One.

Coffee Counter Case Lid

Be sure to clean up the meating points of both this lid and the main portion of the case to ensure that they fit correctly. I used a knife and sanders to get the fitment perfect so could fit in tightly.

Stand For Coffee Counter

This is just a standard stand made so the coffee counter in its case can sit at an angle for the users view it better!

Code

This is the code project for the coffee counter

C/C++
/* The following instructions and comments are based on the assumption that you are framiliar with the 
syntax of C++ anda few funtioins and tools that are commonly used in C++ and classes used with Wia.*/

//These are libraries stored by Wia which are necessary for Wia products
#include <WiFi.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
#include <Wia.h>

int coffee_count;// this is a variable used to keep track of the number of coffees
int i;
int hold_time; // this variable keeps track of the ammount of time the button is held to detect a hold
const int button = 15;
Wia wiaClient = Wia();

#define TFT_RST -1// these three definitions define pins for the TFT screen
#define TFT_CS 16
#define TFT_DC 17

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void powered_by() { // this is a function which is used to display the header "Powered by: Wia Dot One"
  
  // each of these sections is specific to different texts which are printed in the TFT scree
  // as you can see each time for new text we define where the text starts, the color, the size and rotation
  
  	tft.setCursor(5, 5); // this function moves where this snipet of text "Powered by:" is
    tft.setTextColor(ST7735_BLACK); // this functioin changes the color of the text "Powered by:"
    tft.setTextSize(1); // this defines the size of the text "Powered by:"
    tft.setRotation(1); // this sets the rotation of the text "Powered by:"
    tft.println("Powered by:"); // this displays the text "Powered by:" with the settings defined above
    
  	// the following 4 sections of code work the same but are for different pieces of text.
    tft.setCursor(5, 20);
    tft.setTextColor(ST7735_BLACK);
    tft.setTextSize(2);
    tft.setRotation(1);
    tft.println("Wia");
    
    tft.setCursor(15, 8);
    tft.setTextColor(ST7735_YELLOW);
    tft.setTextSize(2);
    tft.setRotation(1);
    tft.println(".");
    
    tft.setCursor(43, 20);
    tft.setTextColor(ST7735_YELLOW);
    tft.setTextSize(2);
    tft.setRotation(1);
    tft.println("Dot");
    
    tft.setCursor(85, 20);
    tft.setTextColor(ST7735_YELLOW);
    tft.setTextSize(2);
    tft.setRotation(1);
    tft.println("One");
}


void print_coffee_count () { // this functioin is used to print the count of coffees
  wiaClient.createEvent("button-pressed");
  coffee_count += 1;
  
  /* each of these if statements adjusts the font size and position of the count based on the size of the 
  number this is necessary for the numbers to show up correctly on the TFT (i.e. 1000 takes more screen 
  space than 1)*/
  
  if (coffee_count >= 1000) 
  {
    tft.fillScreen(ST7735_WHITE);
    tft.setCursor(0, 50);
    tft.setTextColor(ST7735_BLACK);
    tft.setTextSize(5);
    tft.setRotation(1);
    tft.println(coffee_count);
  } 
  else if (coffee_count >= 100) 
  {
    tft.fillScreen(ST7735_WHITE);
    tft.setCursor(0, 50);
    tft.setTextColor(ST7735_BLACK);
    tft.setTextSize(7);
    tft.setRotation(1);
    tft.println(coffee_count);
  } 
  else if (coffee_count >= 10) 
  {
    tft.fillScreen(ST7735_WHITE);
    tft.setCursor(30, 50);
    tft.setTextColor(ST7735_BLACK);
    tft.setTextSize(7);
    tft.setRotation(1);
    tft.println(coffee_count);
  } 
  else 
  {
    tft.fillScreen(ST7735_WHITE);
    tft.setCursor(40, 50);
    tft.setTextColor(ST7735_BLACK);
    tft.setTextSize(7);
    tft.setRotation(1);
    tft.println(coffee_count);
  }
}



void setup() {
  WiFi.begin(); // this starts the connection 
  delay(2500); // delay is necessary for the WIFI to work properly
  pinMode(button, INPUT_PULLDOWN);
  tft.initR(INITR_144GREENTAB);
  
  powered_by(); // printing header
  coffee_count = 0; // initializing the variables to reset the count
  i = 0;
  // this TFT print resets the number when the TFT is initially turned on.
  tft.fillScreen(ST7735_WHITE);
  tft.setCursor(40, 40);
  tft.setTextColor(ST7735_BLACK);
  tft.setTextSize(7);
  tft.setRotation(1);
  tft.println(coffee_count);
}



void loop() {
/* the first time the screen turns on this ensures it prints the header information 
"Powered by: Wia Dot One"*/
  if(i == 0)  
  {
    powered_by();
    i++;
  }
  hold_time = 0; // whenever the button is low the hold timer resets
  while(digitalRead(button) == HIGH)
  {
    if(hold_time == 0) // if the button is pressed once
    {
      print_coffee_count();
    }
    // The button is considered held after the parent while loop increments 100 times
    else if (hold_time > 100) 
    {
      while(digitalRead(button) == HIGH)
      {
        hold_time++;
        print_coffee_count();
        powered_by();
        /* The TFT Screen needs a delay so it is not updating too fast causing it to flicker and so it 
        doesnt increment too fast*/
        delay(100); 
      }             
    }
    
    hold_time++; 
  	powered_by();
  }
}

Credits

Andrew Berry

Andrew Berry

17 projects • 1 follower
Adam O' Ceallaigh

Adam O' Ceallaigh

13 projects • 4 followers
Jack Duff

Jack Duff

20 projects • 2 followers
Man of the people.Champion of the downtrodden.Marketing magic @ Wia
Spivey

Spivey

70 projects • 43 followers
Tourist in a Tutu || US Born || Melbourne/Mexico/California Raised || New Yorker at ❤️ || SF to Dublin to be COO of Wia the best IoT startup

Comments