mangavalk

gamestop price on VFD

Apr 15th, 2021
714
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.    BasicHTTPClient.ino
  3.  
  4.     Created on: 24.05.2015
  5.  
  6.     hardware, esp32, but can also be an esp8266
  7.     serial VFD screen, in my case a 20l203da5
  8.  
  9.     replace SSID and PASSWORD with your wifi name and password.
  10.     replace PRICE and CHANGE with your codes from https://thingspeak.com/apps/thinghttp
  11.  
  12.     in https://thingspeak.com/apps/thinghttp add 2 ThingHTTP's
  13.     for PRICE add url: https://finance.yahoo.com/quote/GME/
  14.         parse string: /html/body/div[1]/div/div/div[1]/div/div[2]/div/div/div[4]/div/div/div/div[3]/div[1]/div/span[1]
  15.     for CHANGE add url: https://finance.yahoo.com/quote/GME/
  16.         parse string: /html/body/div[1]/div/div/div[1]/div/div[2]/div/div/div[4]/div/div/div/div[3]/div[1]/div/span[2]
  17.     copy the api_key after saving into PRICE and CHANGE
  18.  
  19. */
  20.  
  21. #include <Arduino.h>
  22.  
  23. #include <WiFi.h>
  24. #include <WiFiMulti.h>
  25.  
  26. #include <HTTPClient.h>
  27.  
  28. #define USE_SERIAL Serial
  29.  
  30. WiFiMulti wifiMulti;
  31.  
  32. void setup() {
  33.  
  34.   USE_SERIAL.begin(9600);
  35.   delay(1000);
  36.  
  37.   USE_SERIAL.write(0x1B);
  38.   USE_SERIAL.write(0x40);
  39.   USE_SERIAL.write(0x0C);  //CLEAR SCREEN CMD
  40.   USE_SERIAL.println("StockTicker VFD");
  41.  
  42.   for (uint8_t t = 4; t > 0; t--) {
  43.     //        USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
  44.     //        USE_SERIAL.flush();
  45.     delay(1000);
  46.   }
  47.  
  48.   wifiMulti.addAP("SSID", "PASSWORD");
  49.  
  50. }
  51.  
  52. void loop() {
  53.   String gme_price, gme_change = "wifi not connected";
  54.  
  55.   // wait for WiFi connection
  56.   if ((wifiMulti.run() == WL_CONNECTED)) {
  57.  
  58.     HTTPClient http;
  59.  
  60.     //        USE_SERIAL.print("[HTTP] begin...\n");
  61.     // configure traged server and url
  62.     http.begin("https://api.thingspeak.com/apps/thinghttp/send_request?api_key=PRICE"); //HTTP
  63.  
  64.     //        USE_SERIAL.print("[HTTP] GET...\n");
  65.     // start connection and send HTTP header
  66.     int httpCode = http.GET();
  67.  
  68.     // httpCode will be negative on error
  69.     if (httpCode > 0) {
  70.       // HTTP header has been send and Server response header has been handled
  71.       //            USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);
  72.  
  73.       // file found at server
  74.       if (httpCode == HTTP_CODE_OK) {
  75.         String payload = http.getString();
  76.         gme_price = payload;
  77.       }
  78.     } else {
  79.       //            USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
  80.     }
  81.  
  82.  
  83.     //        USE_SERIAL.print("[HTTP] begin...\n");
  84.     // configure traged server and url
  85.     http.begin("https://api.thingspeak.com/apps/thinghttp/send_request?api_key=CHANGE"); //HTTP
  86.  
  87.     //        USE_SERIAL.print("[HTTP] GET...\n");
  88.     // start connection and send HTTP header
  89.     httpCode = http.GET();
  90.  
  91.     // httpCode will be negative on error
  92.     if (httpCode > 0) {
  93.       // HTTP header has been send and Server response header has been handled
  94.       //            USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);
  95.  
  96.       // file found at server
  97.       if (httpCode == HTTP_CODE_OK) {
  98.         String payload = http.getString();
  99.         gme_change = payload;
  100.       }
  101.     } else {
  102.       //            USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
  103.     }
  104.  
  105.     http.end();
  106.   }
  107.  
  108.   USE_SERIAL.write(0x0C);  //CLEAR SCREEN CMD
  109.   USE_SERIAL.println("GME $" + gme_price);
  110.   USE_SERIAL.println(gme_change);
  111.  
  112. //  delay(500);
  113. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×