Well… I’m no expert but I tried to follow your advice and based on the great post you did Using BlynkTimer or SimpleTimer and this is the current status…
#define BLYNK_PRINT Serial
#include <Blynk.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <max6675.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_TEMPLATE_NAME ""
#define BLYNK_AUTH_TOKEN ""
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
char auth[] = ""; // You should get Auth Token in the Blynk App.
char ssid[] = ""; // Your WiFi credentials.
char pass[] = "";
int ktcSO = 12;
int ktcCS = 13;
int ktcCLK = 14;
MAX6675 ktc(ktcCLK, ktcCS, ktcSO);
// This function creates the timer object. It's part of Blynk library
BlynkTimer timer;
void getTemp()
{
float DC = ktc.readCelsius();
float DF = ktc.readFahrenheit();
Blynk.virtualWrite(V0, DC);
Blynk.virtualWrite(V1, DF);
Serial.print("C = ");
Serial.print(DC);
Serial.print("\t F = ");
Serial.println(DF);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(20, 0);
display.print("Temperature");
display.setTextSize(2);
display.setCursor(10, 20);
display.print(DC);
display.print((char)247);
display.print("C");
display.setTextSize(2);
display.setCursor(10, 45);
display.print(DF);
display.print((char)247);
display.print("F");
display.display();
}
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
timer.setInterval(5000L, getTemp);
display.begin(SSD1306_SWITCHCAPVCC, 0x3c); //initialize with the I2C addr 0x3C (128x64)
delay(500);
display.clearDisplay();
display.setCursor(25, 15);
display.setTextSize(1);
display.setTextColor(WHITE);
display.println(" Thermometer");
display.setCursor(25, 35);
display.setTextSize(1);
display.print("Initializing");
display.display();
delay(3000);
}
void loop()
{
timer.run(); // call the BlynkTimer object
Blynk.run(); // perform a handshake with the Blynk server
}
And unfortunately I’m still getting the same results. I’m attaching a side by side photo of the lcd and the blynk on the phone. This photo is with No Units defined on the Datastream V1. It shows the right value… I tried with setInterval 1sec and 5sec. Same result.
PS: The code does look cleaner, thanks for the tip.