The first tries there was nothing there because the only thing i want is to store a variable to be retrieved later on. Because it didn’t work i tried putting a value display there and the value’s became visible on the app thus giving me feedback that at least the sending of the variable to the app worked.
The hardware will shut down and at startup i want it to read the variable which it stored last so it can continue from there on.
I read on this page that Can I read data stored in the server? that johanan was trying something similar.
I get the feeling that it A) does not retrieve the variable correctly with Blynk sync and _write or B) the variable is a local variable which does never reach the rest of the program like in the loop section.
I’m now trying to pinpoint the above statements but both seem invalid because if i run the code below i still don’t get any feedback in the serial monitor. This time i put a slider on V15 if only to try to get a variable to display on my hardware (in this case the serial monitor)
#include <Adafruit_SSD1306.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 14
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
unsigned long lastlasttime;
unsigned long Nownow;
//BLYNK:
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
WidgetTerminal terminal(V1);
WidgetLCD lcd(V3);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "0a7c1f0a0b4b424498c763e785ce77a6"; //stefan
// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 1
BLYNK_CONNECTED() {
Blynk.syncAll();
}
int pinValue;
BLYNK_WRITE(V15)
{
pinValue = param.asInt(); // assigning incoming value from pin V15 to a variable
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Serial.print("V15 Slider value is: ");
Serial.println(pinValue);
}
void setup() {
Serial.begin(115200);
Serial.setTimeout(2000);
Blynk.begin(auth, "Tuypgroup", "Kleurboek1");
// Serial.println("test");
// Wait for serial to initialize.
while(!Serial) { }
}
void loop()
{
Blynk.run();
//Serial.print("V15 Slider value is: ");
//Serial.println(pinValue);
}
The resulting serial monitor is (even tough the slider is adjusted to 764 in the app):
rl��r��c�n�����p�|����x��ǒ��p�nn��;�n����e�b�$errrl��r��#�n�����p�|����x��ǒ��p�nn��;�n����e�b�$rrp�n�������l�����b�n��n�$��b��<~�n�����l`e���#�n�rnr���;����{r�ےn��b��`eĞ�l�����8��r��n�b�[41] Connecting to Tuypgroup
[542] Connected to WiFi
[542] IP: 192.168.178.179
[542] Blynk v0.3.10 on Arduino
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
[5002] Connecting to blynk-cloud.com:8442
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
[5288] Ready (ping: 43ms).
V15 Slider value is: 0
V15 Slider value is: 0
V15 Slider value is: 0
�rl��r��c�n�����p�|����x��ǒ��p�nn��;�n����e�b�$rrp�n�������l�����b�n��n�$��b��>~�n�����l`e���#�n�rnr���;��?��{r�ےn��b��`eĞ�l�����x��r��n�b�[41] Connecting to Tuypgroup
[542] Connected to WiFi
[542] IP: 192.168.178.179
[542] Blynk v0.3.10 on Arduino