Dear all, i need to prefill a table with some values but the following code fails to do this. The table remain empty.
I think because the write occours before the blynk.run().
Any help will be appreciated
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
WidgetTable table;
BLYNK_ATTACH_WIDGET(table, V1);
int rowIndex = 0;
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.config(auth);
table.addRow(0,"Sole",1);
table.pickRow(0);
table.addRow(1,"Luna",1);
table.addRow(2,"Temperatura Esterna",1);
table.addRow(3,"Temperatura Interna",1);
}
void loop()
{
Blynk.run();
}
It’s in the docs…
http://docs.blynk.cc/#blynk-firmware-configuration-blynkconfig
“Note: Just after Blynk.config(…), Blynk is not yet connected to the server.
It will try to connect when it reaches first Blynk.run() or Blynk.connect()call.”
Pete.
I changed the code but the behaviour doesn’t change. I attched the debug log
WidgetTable table;
BLYNK_ATTACH_WIDGET(table, V1);
int rowIndex = 0;
bool firstrun = true;
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.config(auth);
}
void loop()
{
Blynk.run();
if (firstrun) {
Serial.println("firstrun");
table.addRow(0, "Sole", 1);
table.pickRow(0);
table.addRow(1, "Luna", 1);
//table.addRow(2,"Temperatura Esterna",1);
//table.addRow(3,"Temperatura Interna",1);
firstrun = !firstrun;
}
}
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.5.3 on Arduino
Give Blynk a Github star! => https://github.com/blynkkk/blynk-library
[67] Connecting to blynk-cloud.com:80
firstrun
[5068] Connecting to blynk-cloud.com:80
[10069] Connecting to blynk-cloud.com:80
[10136] <[02|00|01|00]
[10203] >[00|00|01|00|C8]
[10203] Ready (ping: 66ms).
[10203] Free RAM: 43688
[10270] <[11|00|02|00]Hver[00]0.5.3[00]h-beat[00]10[00]buff-in[00]1024[00]dev[00]Arduino[00]build[00]Jun 19 2018 10:44:26[00]
[10336] >[00|00|02|00|C8]
Perfect ! Now it’s works.
Marked the topi as solved
You may want to refresh your Auth code, as you shared it in the last post. Wouldn’t want people writing naughty entries into your table would we?
Pete.