Hey Pete - I’m working on a similar issue with new Blynk (Only forced because my phone died and I couldn’t recover the app… drat.)
Attached is the working code I had for previous blynk, I’m having trouble finding the porting instructions or - really - making sense of how to do what I was doing before - but now… can you help?
Attached is the code:
/******************************************************************
Fermenter 2 Controller
******************************************************************/
#include <OneWire.h> // http://www.pjrc.com/teensy/td_libs_OneWire.html
#include "SSD1306Wire.h" // https://github.com/ThingPulse/esp8266-oled-ssd1306
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define glycolS 0
#define PRV 16
int sp_gl, sv_gl, sp_prv, gl_OFF, gl_ON, prv_OFF, prv_ON;
bool Glyc, prv;
#define BLYNK_PRINT Serial
//---BLYNK SETUP---
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "MZ_Ffb8JihHREJiD_CbOaXXXm9fA1iyo";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "XXXX";
char pass[] = "XXXXXXXXX";
// OLED
SSD1306Wire display(0x3c, D2, D5);
// DS18B20+
OneWire ds(5);
//----Function to send sensor Data to Blynk
void sendSensor()
{
Glyc=digitalRead(glycolS);
}
void setup()
{
Blynk.begin(auth, ssid, pass);
// OLED
display.init();
display.flipScreenVertically();
display.setFont(ArialMT_Plain_24);
]
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.setFont(ArialMT_Plain_10);
// write the buffer to the display
display.display();
delay(1500);
}
void loop()
{
Blynk.run();
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius, fahrenheit;
if (!ds.search(addr))
{
ds.reset_search();
delay(250);
return;
}
ds.reset();
ds.select(addr);
ds.write(0x44, 1); // start conversion, with parasite power on at the end
delay(1000); // maybe 750ms is enough, maybe not
present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
// we need 9 bytes
for (i = 0; i < 9; i++)
{
data[i] = ds.read();
}
// Convert the data to actual temperature
int16_t raw = (data[1] << 8) | data[0];
if (type_s)
{
raw = raw << 3; // 9 bit resolution default
if (data[7] == 0x10)
{
// "count remain" gives full 12 bit resolution
raw = (raw & 0xFFF0) + 12 - data[6];
}
}
else
{
byte cfg = (data[4] & 0x60);
// at lower res, the low bits are undefined, so let's zero them
if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
// default is 12 bit resolution, 750 ms conversion time
}
celsius = (float)raw / 16.0;
fahrenheit = celsius * 1.8 + 32.0;
// celsius
display.clear();
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.setFont(ArialMT_Plain_16);
display.drawString(0, 5, "Temperature");
display.setFont(ArialMT_Plain_24);
display.drawString(0, 30, String(celsius));
display.drawString(65, 30, "C");
// write the buffer to the display
display.display();
delay(2000);
// fahrenheit
display.clear();
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.setFont(ArialMT_Plain_16);
display.drawString(0, 5, "Temperature");
display.setFont(ArialMT_Plain_24);
display.drawString(0, 30, String(fahrenheit));
display.drawString(65, 30, "F");
// write the buffer to the display
display.display();
delay(2000);
Blynk.virtualWrite(V0, fahrenheit);
}