Andrew BerrySpiveyJack Duff
Published

Become a Stock Market Billionaire with Wia Dot One

In this tutorial, we will show how to display any stock market price to a TFT screen using the Wia Dot One. (Actual results may vary.)

IntermediateFull instructions provided30 minutes166
Become a Stock Market Billionaire with Wia Dot One

Things used in this project

Hardware components

Wia Dot One
Wia Dot One
×1
Wia TFT LCD Screen Module
Wia TFT LCD Screen Module
×1
Wia Micro USB Cable
Wia Micro USB Cable
×1
Arduino ESP8266 ESP32 Dual 18650 Lithium Battery Shield
×1

Software apps and online services

Wia
Wia

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Code

MSFT Tracker Code Project

C/C++
#include <WiFi.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
#include <Wia.h>

#define TFT_RST -1
#define TFT_CS 16
#define TFT_DC 17

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
Wia wiaClient = Wia();
int i = 0;
String price = "";
String previous_open = "";
String previous_close = "";
int iterator = 0;


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(85, 12);
  tft.setTextColor(ST7735_BLACK);
  tft.setTextSize(2);
  tft.setRotation(1);
  tft.println("Wia");

  tft.setCursor(95, 0);
 	tft.setTextColor(ST7735_YELLOW);
  tft.setTextSize(2);
  tft.setRotation(1);
  tft.println(".");

  tft.setCursor(55, 30);
  tft.setTextColor(ST7735_BLACK);
  tft.setTextSize(2);
  tft.setRotation(1);
  tft.println("Stock");
}

void setup() 
{
  WiFi.begin();
  delay(2500);
  tft.initR(INITR_144GREENTAB);
  tft.fillScreen(ST7735_WHITE);
}

void loop() 
{
  if(previous_open != wiaClient.getDeviceState("MSFT_Open") || previous_close != wiaClient.getDeviceState("MSFT_Close") || i == 0)
  {
    // This block covers the previous Open text in white keeping the TFT from flashing
    tft.setCursor(50, 70);
    tft.setTextColor(ST7735_WHITE);
    tft.setTextSize(2);
    tft.setRotation(1);
    tft.println(previous_open);
		// This then prints the new Open price in black 
    tft.setCursor(50, 70);
    tft.setTextColor(ST7735_BLACK);
    tft.setTextSize(2);
    tft.setRotation(1);
    tft.println(wiaClient.getDeviceState("MSFT_Open").substring(0,6)); // BTC
    previous_open = wiaClient.getDeviceState("MSFT_Open");
    
    // This block covers the previous text in white keeping the TFT from flashing
    tft.setCursor(50, 110);
    tft.setTextColor(ST7735_WHITE);
    tft.setTextSize(2);
    tft.setRotation(1);
    tft.println(previous_close);
		// This then prints the new Open price in black 
    tft.setCursor(50, 110);
    tft.setTextColor(ST7735_BLACK);
    tft.setTextSize(2);
    tft.setRotation(1);
    tft.println(wiaClient.getDeviceState("MSFT_Close").substring(0,6)); // BTC
    previous_close = wiaClient.getDeviceState("MSFT_Close");
    
    tft.setCursor(3, 30);
    tft.setTextColor(ST7735_ORANGE);
    tft.setTextSize(2);
    tft.setRotation(1);
    tft.println("MSFT");
    
    tft.setCursor(3, 54);
    tft.setTextColor(ST7735_BLACK);
    tft.setTextSize(2);
    tft.setRotation(1);
    tft.println("Open:");
    
    tft.setCursor(3, 90);
    tft.setTextColor(ST7735_BLACK);
    tft.setTextSize(2);
    tft.setRotation(1);
    tft.println("Close:");
    
    powered_by();
  }
  i++;
  delay(3600000);;
}

Flow Run Function Code

JavaScript
if(input.body) {
  let response = JSON.parse(input.body);
	let timeSeries = response['Time Series (Daily)'];
  let datetime = new Date();
  let daily = timeSeries[datetime.toISOString().slice(0,10)];
  output.body.data = {
  	open: daily['1. open'],
    close: daily['4. close']
  };
}

Credits

Andrew Berry

Andrew Berry

25 projects • 4 followers
Spivey

Spivey

82 projects • 45 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
Jack Duff

Jack Duff

32 projects • 3 followers
Man of the people. Champion of the downtrodden. Marketing magic @ Wia. Becoming a maker by learning, building, and exploring

Comments