VirtualWrite not pushing data

I am trying to make a Low power ESP32 Plant monitor, I’ve already made wifi more reliable, but my VirtualWrite Function doesn’t seem to work. I don’t know if it’s my code or some bug. Here is the super early version of the code, and I have tried to get the VirtualWrite to work with delays and stuff, but no luck.


#define BLYNK_DEBUG
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <Wire.h>
#define uS_TO_S_FACTOR 1000000  /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP  10
#define SDA 27
#define SCL 26
char auth[] = "vvCifMo****Punpnktg*hzBH**k_KU2CMf";
char ssid[] = "*********";
char pass[] = "********";
IPAddress blynk_server_ip(45, 55, 96, 146);              
IPAddress ip(192, 168, 1, 112); // this 3 lines for a fix IP-address
IPAddress dns1(8, 8, 8, 8);
IPAddress dns2(8, 8, 4, 4);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
uint8_t router_mac[6] = { 0x2e, 0x80, 0x88, 0xe9, 0x16, 0x8f };
int statusLED = 5;
int i;
int retry = 350;
float soil;
float soil1;
float soil2;
int Psoil;
int Psoil1;
int Psoil2;
int o = 4;
void setup() {

 pinMode(32, INPUT);
 pinMode(33, INPUT);
 pinMode(34, INPUT);
 pinMode(5, OUTPUT);
  digitalWrite(5, LOW);
 Serial.begin(115200);
 delay(200);
 Wire.begin(SDA, SCL);
   WiFi.config(ip, gateway, subnet, dns1, dns2);
 WiFi.begin(ssid, pass, 1, router_mac);
   while (WiFi.status() != WL_CONNECTED) {
     delay(20);
     Serial.print(".");
 
    //   for (i = 0; i < retry; i++) {
    // Serial.println("RETRYING WiFi CONECTION");
   //  delay(100);
  // }
   //goto sleep;
 }
Blynk.config(auth, blynk_server_ip);
while (Blynk.connect() == false) {
   Serial.print(".");
 }
 Blynk.run();
 digitalWrite(5, HIGH);
 delay(100);
 digitalWrite(5, LOW);
 soil = ReadVoltage(32), 3;
 soil1 = ReadVoltage(33), 3;
 soil2 = ReadVoltage(34), 3;
 Psoil = map(soil, 3, 1, 0, 100);
 Blynk.run();
 Blynk.virtualWrite(V0, Psoil);
 yield();
 Blynk.virtualWrite(V6, soil1);
 Blynk.virtualWrite(V7, soil2);
 yield();
 Serial.println(soil);
 Serial.println(Psoil);
 Blynk.run();
 yield();





sleep:
digitalWrite(5, HIGH);
 esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
 Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) +
                " Seconds");
 Serial.println("Going to sleep now");
 esp_deep_sleep_start();
 Blynk.run();
 delay(100);
}

void loop() {

}


double ReadVoltage(byte pin) {
 double reading = analogRead(pin); // Reference voltage is 3v3 so maximum reading is 3v3 = 4095 in range 0 to 4095
 if (reading < 1 || reading > 4095) return 0;
 // return -0.000000000009824 * pow(reading,3) + 0.000000016557283 * pow(reading,2) + 0.000854596860691 * reading + 0.065440348345433;
 return -0.000000000000016 * pow(reading, 4) + 0.000000000118171 * pow(reading, 3) - 0.000000301211691 * pow(reading, 2) + 0.001109019271794 * reading + 0.034143524634089 + 0.013;
}





What are you seeing in your serial monitor?

Pete.

I see the esp32 connecting to wifi, connecting to blynk, and after it connects it prints the values and goes to sleep. I can’t seem to find the bug.
Thanks for the help, Ivan.

A copy and paste of the serial monitor output produced by the code above would be more useful than this short summary.

Pete.

......................................................................................................................................................................................................................................................................................................................................[6795] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP32

[6796] Connecting to 45.55.96.146
[14928] <[1D|00|01|00] -vvCifMoURPunpnktgvhzBHPk_KU2CMf
[15746] >[00|00|01|00|C8]
[15747] Ready (ping: 818ms).
[15814] <[11|00|02|00]Fver[00]0.6.1[00]h-beat[00]10[00]buff-in[00]1024[00]dev[00]ESP32[00]build[00]Feb 29 2020 00:35:13[00]
[15882] <[14|00|03|00|07]vw[00]0[00]50
[15949] <[14|00|04|00|0A]vw[00]6[00]0.228
[16016] <[14|00|05|00|0A]vw[00]7[00]0.000
2.81
50
Setup ESP32 to sleep for every 10 Seconds
Going to sleep now
ets Jun  8 2016 00:22:57

rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:812
load:0x40078000,len:0
load:0x40078000,len:11572
entry 0x40078a5c
⸮........................................................................................................................................................................................................................................................................................................................................[6850] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP32

[6851] Connecting to 45.55.96.146
[19850] <[1D|00|01|00] -vvCifMoURPunpnktgvhzBHPk_KU2CMf
.[24851] Connecting to 45.55.96.146
[25587] <[1D|00|01|00] -vvCifMoURPunpnktgvhzBHPk_KU2CMf
[26407] >[00|00|01|00|C8]
[26408] Ready (ping: 820ms).
[26475] <[11|00|02|00]Fver[00]0.6.1[00]h-beat[00]10[00]buff-in[00]1024[00]dev[00]ESP32[00]build[00]Feb 29 2020 00:35:13[00]
[26543] <[14|00|03|00|07]vw[00]0[00]50
[26610] <[14|00|04|00|0A]vw[00]6[00]0.527
[26677] <[14|00|05|00|0A]vw[00]7[00]0.000
2.82
50
Setup ESP32 to sleep for every 10 Seconds
Going to sleep now
ets Jun

Can anybody help me? I still haven’t resolved the issue and don’t know where i was wrong in the coding

Your serial monitor shows that you’re connecting to the server and your auth code is being successfully validated. The ping time is a little long, but you don’t seem to be getting any ill effects from this.

These three lines show that you are doing Virtual Writes to pins V0, V6 and V7 and the values that are being written…

[26543] <[14|00|03|00|07]vw[00]0[00]50        <--- Pin V0 is sent value 50
[26610] <[14|00|04|00|0A]vw[00]6[00]0.527     <--- Pin V6 is sent value 0.527
[26677] <[14|00|05|00|0A]vw[00]7[00]0.000     <--- Pin V7 is sent value 0.000

Looking at the JSON for your app project, it seems that you only have one widget set-up, which is connected to pin V0:
image

The value of 50 that is being sent to V0 should display on that widget.

Pete.

Thanks a lot for the help Pete, could the problem be that I put the wrong blynk server IP for Chile? I still cant resolve the issue.
Thanks for the help, Ivan.

I have recorded my phone screen and the Serial Monitor to show a little better the issue, how can I send it?

The IP was not the issue, my app still doesn’t work at all and can’t seem to find the bug

  • Here is a link to the video if it helps: Video

Please Help me

Try removing the sleep portion and see if it posts the data. That would at least help to narrow it down a bit.

I have now logged out and created a new account and the values are updates once, and after the sleep they are stuck there and i need to re open the app. Could it be that I am sending too much float values?

Help, i think the server space allocated to my account is some how broken, when i go to erase the superchart, the server immediately pushes a value received weeks ago, and doesn’t receive more values, is sort of stuck in that state, and i don’t know what to do