[SOLVED] BLYNK_READ don't update App

Hi folks,

I built up a local blynk_server on my synology NAS server - works fine -

As hardware I use an ESP8266-12E with a RGB LED and a LDR resistor. On my iPhone I built up a small app with sliders, lcd and two gauges.
All pins from all widgets are virtual pins. (of course I doubled checked the pin numbers inside app and my source code)

Sliders for three colors => works fine. If I change slider, color on RGB change :slight_smile.
If i use BLYNK_READ on ESP8266 to update LDR data to display inside my APP nothing happens.
No changes were made.

Below some small snippets from my code: (Log is an self made logging lib)
BTW: BLYNK_READ will be called and I see the log output on serial. But nothing is send from hardware to app :confused:

//----- works fine ---------
BLYNK_WRITE(V4) {
uint8_t value = param.asInt();
Log.Info(“Slider BLUE [%i]” CR, value);
analogWrite(LED_BLUE_GPIO, value);
}

//----- no update inside iPhone App

BLYNK_READ(V5) {
uint16_t value = analogRead(LDR_GPIO);
Log.Info(“read LDR (%i)” CR, value);
Blynk.virtualWrite(V5, (int)value);
Blynk.virtualWrite(V1, (int)value);
}

//---- writing on LCD didn’t work too

void Display() {
lcd.print(0, 0, “BeVo-Lamp V01”);
lcd.print(0, 1, millis() / 1000);
}

Any ideas what could be wrong?

Cheers
Bernd

@LunaX hello. could you please post screenshot of settings of widget that is on V5 pin?

wow, very quick response :slight_smile:

This is the firste gauge, second gauge is the same - it was only for test

BTW: I tested different values (0-1023, 0-255, …) - every time the same.

On LCD I’m not able to write too

:wink:. Do you see serial output exactly for V5? I mean does

Log.Info("read LDR (%i)" CR, value);

show something? Could you please also add (int)value to serial output? Maybe you just send zeros.

yeap, I’m 99,8% sure - unfortunately the hardware is not running yet - so I can’t send you some screenshots from serial output.

But, I got the values from LDR and if I changed light, values changed (on serial) but nothing inside my app - very obfuscated -

And (as I wrote), same problem with LCD. It seems, that my local server CAN send from APP to HW but not vice versa

short info: My log lib works as printf on serial with a couple of different possible parameters. INT, CHAR, DOUBLE, CHAR*, BOOL, …

In my above example the output should be as example : read LDR (798)

Please post full sketch. Regarding

Sorry, but i do not understand. It is should be or it is? As I understood you see this in serial output, right? Please put (int)value to log too. We need to be 100% that this is not an issue.

Hi Dmitriy,

yes, I saw the values during output on serial. Sorry for my english :open_mouth: -
Today it’s late in Germany - I setup my hardware again tomorrow and come back with some serial outputs for your.

Thanks for your assistance.

(ups formatting is not good - tabs lost, and #xxxx rows ???)
`
/*

  • This sketch demonstrates how to scan WiFi networks.
  • The API is almost the same as with the WiFi Shield library,
  • the most obvious difference being the different file you need to include:
    */
    //#define BLYNK_PRINT Serial // Comment this out to disable prints and save
    // space
    #include "Logging.h"
    #include <BlynkSimpleEsp8266.h>
    #include <ESP8266WiFi.h>
    #include <SimpleTimer.h>

#define LDR_GPIO A0
#define LED_RED_GPIO 15
#define LED_GREEN_GPIO 12
#define LED_BLUE_GPIO 13
#define BUTTON_GPIO 4

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “df83a5ee97094ec78ba3c0da45ac4687”;

char pass[] = “xxxxxxxxxxxxxxxxx”;
char ssid[] = “WLAN-BHxxxx”;
char host[] = “192.168.0.250”;

WidgetLCD lcd(V0);
WidgetLED led(V1);

SimpleTimer timer;

void setup() {

pinMode(LED_BLUE_GPIO, OUTPUT);
pinMode(LED_RED_GPIO, OUTPUT);
pinMode(LED_GREEN_GPIO, OUTPUT);
pinMode(LDR_GPIO, INPUT);
analogWrite(LDR_GPIO, LOW);
pinMode(BUTTON_GPIO, INPUT);

Log.Init(4, 115200);
delay(5000);
Log.Info("------------------------------------" CR);
Log.Info(" BLYNK-Server" CR);
Log.Info("------------------------------------" CR);
Log.Info(“connect to local blynk-server SSID[%s] [%s] " CR, ssid, pass);
Log.Info(“set blynk authentication…” CR);
Blynk.begin(auth, ssid, pass, host);
while (Blynk.connected()) {
delay(500);
Log.Debug(“waiting…” CR);
}
Log.Info(” " CR);
boolean result;

// timer.setInterval(1000, Display);
// timer.setInterval(5000, LDR);

uint8_t count = 0;
delay(1000);

Widget
}

void loop() {
// timer.run();
Blynk.run();
// Blynk.virtualWrite(V5, analogRead(LDR_GPIO));
}

void LDR() {
uint16_t value = analogRead(LDR_GPIO);
Log.Info(“timer => read LDR (%i)” CR, value);
Blynk.virtualWrite(V5, value);
}

void Display() {
lcd.print(0, 0, “BeVo-Lamp V01”);
lcd.print(0, 1, millis() / 1000);
}

BLYNK_WRITE(V2) {
uint8_t value = param.asInt();
Log.Info(“Slider RED [%i]” CR, value);
analogWrite(LED_RED_GPIO, value);
}
BLYNK_WRITE(V3) {
uint8_t value = param.asInt();
Log.Info(“Slider GREEEN [%i]” CR, value);
analogWrite(LED_GREEN_GPIO, value);
}
BLYNK_WRITE(V4) {
uint8_t value = param.asInt();
Log.Info(“Slider BLUE [%i]” CR, value);
analogWrite(LED_BLUE_GPIO, value);
}

BLYNK_READ(V5) {
uint16_t value = analogRead(LDR_GPIO);
Log.Info(“read LDR (%i)” CR, value);
Blynk.virtualWrite(V5, (int)value);
Blynk.virtualWrite(V1, (int)value);
}

BLYNK_CONNECTED() {
Log.Info(“device connected” CR);
lcd.clear();
lcd.print(0, 0, “device connected”);
}

`

You can use </> sign for formatting code

Does

lcd.print(0, 0, "device connected");

printed on LCD?

You don’t call Display() method anywhere. Before we proceed. Please put (int)value into log :slight_smile:. If it is late we can continue tomorrow.

Hi Dimitry,

so some news from my side :slight_smile:

Some infos to this pic

LED (not very good viewable on picture, is green, because GREEN value was set via app to 106 - works fine (see “Slider GREEN [107]”)
Output is from my serial log output. As you can see, values from LDR are around 800-900 .
But nothing is sent to APP back, neither on gauge (LDR) else on LCD widget.

BTW. today I saw an other strange behaviour (and maybe this is a hint for you).
If I put my thumb on the LDR, some seconds later I get an “device connected” message (from BLYNC_CONNECTED function). It seems, that under some circumstances, connection is lost and reestablished again.

I hope, I described my situation more clearly as yesterday :slight_smile:
cheers
Bernd

(Dimitry/Pavel: I used backticks for “source formatting” but maybe I do something wrong, but it didn’t work :frowning: - I found the mistake - I used to big blocks - smaller ones works - see below

BLYNK_READ(V5) {
  uint16_t value = analogRead(LDR_GPIO);
  Log.Info("read virtual pin (%i) => send value from LDR (%i)" CR, V5, value);
  Blynk.virtualWrite(V5, (int)value);
  Blynk.virtualWrite(V1, (int)value);
} 
BLYNK_CONNECTED() {
  Log.Info("device connected" CR);
  lcd.clear();
  lcd.print(0, 0, "device connected");
}```



below some log messages from my local server - maybe they help 

0:16:12.017 TRACE - Incoming HardwareMessage{id=27895, command=Hardware, length=15, body='1863415459vr1'}
20:16:12.187 TRACE - Incoming LoginMessage{id=1, command=Login, length=32, body='df83a5ee97094ec78ba3c0da45ac4687'}
20:16:12.188 DEBUG - Re registering hard channel. [id: 0x3ac78088, L:/192.168.0.250:8442 - R:/192.168.0.105:31828]
20:16:12.189 DEBUG - completeLogin. [id: 0x3ac78088, L:/192.168.0.250:8442 - R:/192.168.0.105:31828]
20:16:12.189 TRACE - Sending 1863415459 to app [id: 0x6ac42f4b, L:/192.168.0.250:8443 - R:/192.168.0.109:56679]
20:16:12.189 INFO  - berndklein42@gmail.com hardware joined.
20:16:12.198 TRACE - Incoming HardwareInfoMessage{id=5, command=HardwareInfo, length=76, body='ver0.3.5-betah-beat10buff-in256devESP8266buildApr 13 2016 20:09:46'}
20:16:12.203 TRACE - Incoming HardwareMessage{id=6, command=Hardware, length=8, body='vw0clr'}
20:16:12.207 TRACE - Incoming HardwareMessage{id=7, command=Hardware, length=28, body='vw0p00device connected'}
20:16:12.536 TRACE - Incoming HardwareMessage{id=23826, command=Hardware, length=15, body='1863415459vr5'}
20:16:13.019 TRACE - Incoming HardwareMessage{id=22749, command=Hardware, length=15, body='1863415459vr1'}
20:16:13.536 TRACE - Incoming HardwareMessage{id=20587, command=Hardware, length=15, body='1863415459vr5'}
20:16:14.019 TRACE - Incoming HardwareMessage{id=31270, command=Hardware, length=15, body='1863415459vr1'}
20:16:14.542 TRACE - Incoming HardwareMessage{id=27059, command=Hardware, length=15, body='1863415459vr5'}
20:16:15.019 TRACE - Incoming HardwareMessage{id=2904, command=Hardware, length=15, body='1863415459vr1'}
20:16:15.459 TRACE - Incoming HardwareMessage{id=5374, command=Hardware, length=18, body='1863415459vw326'}
20:16:15.530 TRACE - Incoming HardwareMessage{id=23158, command=Hardware, length=18, body='1863415459vw378'}
20:16:15.601 TRACE - Incoming HardwareMessage{id=16556, command=Hardware, length=15, body='1863415459vr5'}
2

Hi Dmitriy, no news, no idea what’s going wrong on my environment?

It would be very helpful for me, if I’m able to go further on with my project.

Thanks
Bernd

Hello. Please try

uint16_t value = 255;

Does that resolve issue?

no not :frowning: - This was one of my first tests.

What about

Log.Info("read virtual pin (%i) => send value from LDR (%i)" CR, V5, value);

Does commenting it help?

So, i did following

  • Generating a random number between 0-255
  • logging this value via serial output (see below logoutput)
  • sending value via Blynk.virtualWrite on V5

Result: no update on APP

BLYNK_READ(V5) {
 uint16_t value = random(255);
Log.Info("set value(%i) on virtual pin(%i)" CR, value, V5);
Blynk.virtualWrite(V5, value);
}

Logoutput

[VERBOSE - 0:0:25] ( 25712) set blynk authentication...
[VERBOSE - 0:0:25] ( 25717)  <done>
[VERBOSE - 0:0:25] ( 25720) attach button interrupt on Pin (1075858764)
[VERBOSE - 0:0:26] ( 26751) device connected
[VERBOSE - 0:0:38] ( 38846) set value(253) on virtual pin(5)
[VERBOSE - 0:0:40] ( 40370) set value(199) on virtual pin(5)
[VERBOSE - 0:0:41] ( 41376) set value(106) on virtual pin(5)
[VERBOSE - 0:0:43] ( 43371) set value(0) on virtual pin(5)
[VERBOSE - 0:0:45] ( 45372) set value(181) on virtual pin(5)
[VERBOSE - 0:0:47] ( 47370) set value(199) on virtual pin(5)
[VERBOSE - 0:0:49] ( 49373) set value(161) on virtual pin(5)
[VERBOSE - 0:0:51] ( 51368) set value(43) on virtual pin(5)
[VERBOSE - 0:0:53] ( 53370) set value(183) on virtual pin(5)

I mean. Could you remove this string?

Dmitry - question:
is it possible to log something more on the local server? I set loglevel to TRACE, but I do not see something, if my ESP8266 try to send something back to APP.

Below messages are logged (currently) - unfortunately I do not understand the log in all :confused:

16:45:08.708 TRACE - Incoming HardwareMessage{id=7200, command=Hardware, length=15, body='1863415459vr1'}
16:45:08.711 TRACE - Incoming HardwareMessage{id=7200, command=Hardware, length=8, body='vw1512'}
16:45:08.774 TRACE - Incoming HardwareMessage{id=25161, command=Hardware, length=15, body='1863415459vr5'}
16:45:08.778 TRACE - Incoming HardwareMessage{id=25161, command=Hardware, length=7, body='vw577'}

just a moment :slight_smile:

ok, I removed all my Log.Info… and changed them against BLYNK_LOG
no better results - nothing send to APP

If I remove log output in BLYNK_READ() - no better results,too: No output to APP

any possible better log mechanism available on server - maybe we can see something in logs there

Logoutput with BLYNK_LOG

[25677] Connected to WiFi
[25677] My IP: 192.168.0.106
[25677] Blynk v0.3.5-beta
[26677] Connecting to 192.168.0.250:8442
[26700] Ready (ping: 4ms).
device connected
[26734] set value(181) on virtual pin(5)

[28703] set value(209) on virtual pin(5)

[30017] Slider RED [36]

What local server version do you have?