REQUEST: Could someone with an Arduino (UNO) + WiFiShield and an analog sensor please test the following script, I have believe you’ll have the same problem as I do which is that as soon as Blynkrun() is run … the values returned by the analog sensor will be overwritten and be set to 1023. See also my post in the Issues and Errors forum.
I would like to verify/prove my point that there’s a problem with BlynkSimpleWifi.h by having other people perform the same test. I’ve already done so myself with another Arduino (same issue) and switching from WiFi to Ethernet (problem resolved)… so I believe it’s a specific issue with the BlynkSimpleWifi.h library.
Sketch :
#define BLYNK_DEBUG
#define BLYNK_PRINT Serial
#include <BlynkSimpleWifi.h>
#include <SimpleTimer.h>
char auth[] = "your authentication code";
char ssid[] = "your SID"; // Network SSID (name)
char pass[] = "your password"; // Network password
int sensor_output = 0;
SimpleTimer timer_Sensor;
SimpleTimer timer_Blynk;
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
timer_Sensor.setInterval(1000L, SensorGet);
timer_Blynk.setInterval(15000L, BlynkTalk);
}
void SensorGet()
{
sensor_output = analogRead(A0);
Serial.print("Analog Sensor: ");
Serial.println(sensor_output);
}
void BlynkTalk()
{
Serial.println("Blynk.run() now ");
Blynk.run();
}
void loop()
{
timer_Sensor.run();
timer_Blynk.run();
}
Output:
[0] Connecting to Misseeuw…
[15001] My IP: 192.168.2.7
[15002] Blynk v0.3.1
Analog Sensor: 439
Analog Sensor: 438
Analog Sensor: 434
Analog Sensor: 434
Analog Sensor: 434
Analog Sensor: 435
Analog Sensor: 437
Analog Sensor: 437
Analog Sensor: 438
Analog Sensor: 438
Analog Sensor: 438
Analog Sensor: 436
Analog Sensor: 436
Analog Sensor: 435
Blynk.run() now
[30002] Connecting to cloud.blynk.cc:8442
[31099] <msg 2,1,32
<1a06fbd9fb65460888ec0af956aadb85
�nalog Sensor: 436
�nalog Sensor: 1023
�nalog Sensor: 1023
�nalog Sensor: 1023
�nalog Sensor: 1023
�nalog Sensor: 1023
�nalog Sensor: 1023
…
…