These have to be the very first two lines of your sketch.
Pete.
These have to be the very first two lines of your sketch.
Pete.
@PeteKnight Thank you for your advice. I have changed the program like this.
#define BLYNK_TEMPLATE_ID "***"
#define BLYNK_DEVICE_NAME "DHT22"
#define BLYNK_PRINT Serial
//Libraries
#include <DHT.h>;
#include <ESP8266_Lib.h>
//#include <ESP8266WiFi.h>;
#include "WiFiEsp.h"
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif
#define DHTPIN 10 // connect the dht output to 10(pwm)
#define DHTTYPE DHT22 // DHT 22 (AM2302)
#define led 8 //connect to led to pin 8-->change to motor later
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
#include <BlynkSimpleShieldEsp8266.h>
#define EspSerial Serial
#define ESP8266_BAUD 115200
#define BLYNK_AUTH_TOKEN "***";
However, the results remains like this
AT+CIPCLOSE=1
AT+CIPCLOSE=1
AT+CIPSTART=1,"TCP","blynk.cloud",80
@PeteKnight is it related to the problem of simpletimer??? if yes where and what should i add to the code?
The problem is that you are using the serial port for communication with Blynk (via the ESP-01) and for debug output.
Change this line
to this:
#define EspSerial Serial1
Pete.
@PeteKnight Thx for the help. Now, it show
Ready (ping: 22ms).
I think it should be fine.
However, when I get into the blynk IOT app or blynk webpage. The connection seems not very stable, it keep disconnected and connecting. Is there my problem of the code??
Also, if I would like to control light bulb(pin8) with the app, what should I set for it?? I saw people can set the pin when thay are using the old app.
Moreover, I am not able to detect the temperture anymore. It keep repeating
Ready (ping: 22ms).
but not showing the temperature in the serial monitor.
Yes, now your problem is being caused by your void loop and delays, instead of using BlynkTimer.
Read this…
Use a virtual pin, and read this…
Pete.
@PeteKnight Thank you for your advice. After reading the 2 pages. I changed the code to this. However, it still doesn’t connected.
//Libraries
#include <DHT.h>;
#include <ESP8266_Lib.h>
//#include <ESP8266WiFi.h>;
#include "WiFiEsp.h"
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif
#define DHTPIN 10 // connect the dht output to 10(pwm)
#define DHTTYPE DHT22 // DHT 22 (AM2302)
#define led 8 //connect to led to pin 8-->change to motor later
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
#define BLYNK_TEMPLATE_ID "***"
#define BLYNK_DEVICE_NAME "DHT22"
#define BLYNK_PRINT Serial
#include <BlynkSimpleShieldEsp8266.h>
//#include <SimpleTimer.h>
#define EspSerial Serial1
#define ESP8266_BAUD 115200
#define BLYNK_AUTH_TOKEN "***";
//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value
char ssid[] = "GoCO"; //You can replace the wifi name to your wifi
char pass[] = "29882992"; //Type password of your wifi.
int status = WL_IDLE_STATUS; // the Wifi radio's status
char auth[] = "nfxC29MO9ja1n6hzopoqMg2EA56Znw6N";
ESP8266 wifi(&EspSerial);
SimpleTimer timer;
//int virtual_pin_value = param.asInt();
//param.asStrng()
//param.asFloat()
//BlynkTimer timer;
void setup()
{
// initialize serial for debugging
Serial.begin(115200);
// initialize serial for ESP module
Serial1.begin(115200);
// initialize ESP module
WiFi.init(&Serial1);
pinMode(LED_BUILTIN, OUTPUT);
dht.begin(); //start running the dht
pinMode (led, OUTPUT); //set the led(pin8) as output
pinMode (LED_BUILTIN, OUTPUT); //set the led on board as output
WifiStatus();
}
void WifiStatus()
{
// check for the presence of the shield
if (WiFi.status() == WL_NO_SHIELD) {
digitalWrite(LED_BUILTIN, LOW); //no on board led if no wifi
Serial.println("WiFi is not connected");
// don't continue
while (true);
}
// attempt to connect to WiFi network
while ( status != WL_CONNECTED) {
digitalWrite(LED_BUILTIN, HIGH);//connecting have on board led
Serial.print("Connecting to ");
Serial.println(ssid);
// Connect to WPA/WPA2 network
status = WiFi.begin(ssid, pass);
}
// you're connected now, so print out the data
Serial.println("You're connected to the network");
timer.setInterval(1000L, sensorDataSend); //timer will run every sec
EspSerial.begin(ESP8266_BAUD);
Blynk.begin(auth, wifi, ssid, pass);
sensorDataSend();
}
void sensorDataSend()
{
delay(2000);
digitalWrite(LED_BUILTIN, HIGH);
delay(200);
digitalWrite(LED_BUILTIN, LOW);
delay(200);
hum = dht.readHumidity();
temp = dht.readTemperature();
//Print temp and humidity values to serial monitor(help checking the data)
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
if (temp >= 20) //running the motor with sensor
{
digitalWrite(led, HIGH); //switch on motor
delay(1000);
}
else
{
digitalWrite(led, LOW); //switch off motor
delay(1000);
}
delay(1000); //Delay 2 sec.
// sensorValue = analogRead(A5); // reading sensor from analog pin
// Blynk.virtualWrite(V1, sensorValue); // sending sensor value to Blynk app
}
BLYNK_WRITE(V1) // Executes when the value of virtual pin 1 changes
{
if(param.asInt() == 1)
{
// execute this code if the switch widget is now ON
sensorDataSend();
}
else
{
// execute this code if the switch widget is now OFF
digitalWrite(led, LOW);
}
}
void loop()
{
Blynk.run();
timer.run(); // Initiates SimpleTimer
}
Like already told before you’ll need to put the template id and device name lines on top of the code.
@bazzio oh I know, I tried both way and it seems they are the same. The problem that I am facing is the connection is not that stable. It keep disconnected and all the time in the app. However, in the serial monitor, it keep replying
Ready (ping: 22ms).
You can’t use delays with Blynk!
Pete.
Yes, you can’t use delay with blynk, especially in the loop. Check this out :
https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean
You should use blynktimer or simpletimer instead.
@PeteKnight @John93 Thank you for the advice
So I should change all the delay() to
timer.setInterval(1000L, sensorDataSent);
what should I replace with the " sensorDataSent", if I just want a delay??
@PeteKnight @John93
Here is my update. I created a new void and change all the delay to simple timer. but nothing changed. the connection is still not stable.
void delaytimer()
{
int count = 0;
Serial.print("delay");
Serial.print(count);
count++;
}
void sensorDataSend()
{
timer.setInterval(200L, delaytimer);
digitalWrite(LED_BUILTIN, HIGH);
timer.setInterval(20L, delaytimer);
digitalWrite(LED_BUILTIN, LOW);
timer.setInterval(20L, delaytimer);
hum = dht.readHumidity();
temp = dht.readTemperature();
//Print temp and humidity values to serial monitor(help checking the data)
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
if (temp >= 20) //running the motor with sensor
{
digitalWrite(led, HIGH); //switch on motor
timer.setInterval(100L, delaytimer);
}
else
{
digitalWrite(led, LOW); //switch off motor
timer.setInterval(100L, delaytimer);
}
timer.setInterval(100L, delaytimer); //Delay 2 sec.
// sensorValue = analogRead(A5); // reading sensor from analog pin
// Blynk.virtualWrite(V1, sensorValue); // sending sensor value to Blynk app
}
For your reference here is the full version of my code
//Libraries
#include <DHT.h>;
#include <ESP8266_Lib.h>
//#include <ESP8266WiFi.h>;
#include "WiFiEsp.h"
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif
#define DHTPIN 10 // connect the dht output to 10(pwm)
#define DHTTYPE DHT22 // DHT 22 (AM2302)
#define led 8 //connect to led to pin 8-->change to motor later
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
#define BLYNK_TEMPLATE_ID "TMPL5vzGTnYc"
#define BLYNK_DEVICE_NAME "DHT22"
#define BLYNK_PRINT Serial
#include <BlynkSimpleShieldEsp8266.h>
//#include <SimpleTimer.h>
#define EspSerial Serial1
#define ESP8266_BAUD 115200
#define BLYNK_AUTH_TOKEN "***";
//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value
char ssid[] = "GoCO"; //You can replace the wifi name to your wifi
char pass[] = "***"; //Type password of your wifi.
int status = WL_IDLE_STATUS; // the Wifi radio's status
char auth[] = "***";
ESP8266 wifi(&EspSerial);
SimpleTimer timer;
//int virtual_pin_value = param.asInt();
//param.asStrng()
//param.asFloat()
//BlynkTimer timer;
void delaytimer()
{
int count = 0;
Serial.print("delay");
Serial.print(count);
count++;
}
void setup()
{
// initialize serial for debugging
Serial.begin(115200);
// initialize serial for ESP module
Serial1.begin(115200);
// initialize ESP module
WiFi.init(&Serial1);
pinMode(LED_BUILTIN, OUTPUT);
dht.begin(); //start running the dht
pinMode (led, OUTPUT); //set the led(pin8) as output
pinMode (LED_BUILTIN, OUTPUT); //set the led on board as output
WifiStatus();
}
void WifiStatus()
{
// check for the presence of the shield
if (WiFi.status() == WL_NO_SHIELD) {
digitalWrite(LED_BUILTIN, LOW); //no on board led if no wifi
Serial.println("WiFi is not connected");
// don't continue
while (true);
}
// attempt to connect to WiFi network
while ( status != WL_CONNECTED) {
digitalWrite(LED_BUILTIN, HIGH);//connecting have on board led
Serial.print("Connecting to ");
Serial.println(ssid);
// Connect to WPA/WPA2 network
status = WiFi.begin(ssid, pass);
}
// you're connected now, so print out the data
Serial.println("You're connected to the network");
timer.setInterval(1000L, sensorDataSend); //timer will run every sec
EspSerial.begin(ESP8266_BAUD);
Blynk.begin(auth, wifi, ssid, pass);
sensorDataSend();
}
void sensorDataSend()
{
timer.setInterval(200L, delaytimer);
digitalWrite(LED_BUILTIN, HIGH);
timer.setInterval(20L, delaytimer);
digitalWrite(LED_BUILTIN, LOW);
timer.setInterval(20L, delaytimer);
hum = dht.readHumidity();
temp = dht.readTemperature();
//Print temp and humidity values to serial monitor(help checking the data)
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
if (temp >= 20) //running the motor with sensor
{
digitalWrite(led, HIGH); //switch on motor
timer.setInterval(100L, delaytimer);
}
else
{
digitalWrite(led, LOW); //switch off motor
timer.setInterval(100L, delaytimer);
}
timer.setInterval(100L, delaytimer); //Delay 2 sec.
// sensorValue = analogRead(A5); // reading sensor from analog pin
// Blynk.virtualWrite(V1, sensorValue); // sending sensor value to Blynk app
}
BLYNK_WRITE(V1) // Executes when the value of virtual pin 1 changes
{
if (param.asInt() == 1)
{
// execute this code if the switch widget is now ON
sensorDataSend();
}
else
{
// execute this code if the switch widget is now OFF
digitalWrite(led, LOW);
}
}
void loop()
{
Blynk.run();
timer.run(); // Initiates SimpleTimer
}
It must be in the beginning of the sketch.
Try this :
/*************************************************************
WARNING!
It's very tricky to get it working. Please read this article:
http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware
This example shows how value can be pushed from Arduino to
the Blynk App.
WARNING :
For this example you'll need Adafruit DHT sensor libraries:
https://github.com/adafruit/Adafruit_Sensor
https://github.com/adafruit/DHT-sensor-library
App project setup:
Value Display widget attached to V5
Value Display widget attached to V6
*************************************************************/
// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID "TMPLxxxxxx"
#define BLYNK_DEVICE_NAME "Device"
#define BLYNK_AUTH_TOKEN "YourAuthToken"
// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <DHT.h>
char auth[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 38400
ESP8266 wifi(&EspSerial);
#define DHTPIN 2 // What digital pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21 // DHT 21, AM2301
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
}
void setup()
{
// Debug console
Serial.begin(115200);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, wifi, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);
dht.begin();
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}
@John93 As I said before, i don’t think this change help much but I follow your advice and change it to this
#define BLYNK_TEMPLATE_ID "TMPL5vzGTnYc"
#define BLYNK_DEVICE_NAME "DHT22"
#define BLYNK_AUTH_TOKEN "***";
#define BLYNK_PRINT Serial
//Libraries
#include <DHT.h>;
#include <ESP8266_Lib.h>
//#include <ESP8266WiFi.h>;
#include "WiFiEsp.h"
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif
#define DHTPIN 10 // connect the dht output to 10(pwm)
#define DHTTYPE DHT22 // DHT 22 (AM2302)
#define led 8 //connect to led to pin 8-->change to motor later
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
#include <BlynkSimpleShieldEsp8266.h>
//#include <SimpleTimer.h>
#define EspSerial Serial1
#define ESP8266_BAUD 115200
//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value
char ssid[] = "GoCO"; //You can replace the wifi name to your wifi
char pass[] = "29882992"; //Type password of your wifi.
int status = WL_IDLE_STATUS; // the Wifi radio's status
char auth[] = "***";
ESP8266 wifi(&EspSerial);
SimpleTimer timer;
//int virtual_pin_value = param.asInt();
//param.asStrng()
//param.asFloat()
//BlynkTimer timer;
void delaytimer()
{
int count = 0;
Serial.print("delay");
Serial.print(count);
count++;
}
void setup()
{
// initialize serial for debugging
Serial.begin(115200);
// initialize serial for ESP module
Serial1.begin(115200);
// initialize ESP module
WiFi.init(&Serial1);
pinMode(LED_BUILTIN, OUTPUT);
dht.begin(); //start running the dht
pinMode (led, OUTPUT); //set the led(pin8) as output
pinMode (LED_BUILTIN, OUTPUT); //set the led on board as output
WifiStatus();
}
void WifiStatus()
{
// check for the presence of the shield
if (WiFi.status() == WL_NO_SHIELD) {
digitalWrite(LED_BUILTIN, LOW); //no on board led if no wifi
Serial.println("WiFi is not connected");
// don't continue
while (true);
}
// attempt to connect to WiFi network
while ( status != WL_CONNECTED) {
digitalWrite(LED_BUILTIN, HIGH);//connecting have on board led
Serial.print("Connecting to ");
Serial.println(ssid);
// Connect to WPA/WPA2 network
status = WiFi.begin(ssid, pass);
}
// you're connected now, so print out the data
Serial.println("You're connected to the network");
timer.setInterval(1000L, sensorDataSend); //timer will run every sec
EspSerial.begin(ESP8266_BAUD);
Blynk.begin(auth, wifi, ssid, pass);
sensorDataSend();
}
void sensorDataSend()
{
timer.setInterval(200L, delaytimer);
digitalWrite(LED_BUILTIN, HIGH);
timer.setInterval(20L, delaytimer);
digitalWrite(LED_BUILTIN, LOW);
timer.setInterval(20L, delaytimer);
hum = dht.readHumidity();
temp = dht.readTemperature();
//Print temp and humidity values to serial monitor(help checking the data)
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
if (temp >= 20) //running the motor with sensor
{
digitalWrite(led, HIGH); //switch on motor
timer.setInterval(100L, delaytimer);
}
else
{
digitalWrite(led, LOW); //switch off motor
timer.setInterval(100L, delaytimer);
}
timer.setInterval(100L, delaytimer);
// sensorValue = analogRead(A5); // reading sensor from analog pin
// Blynk.virtualWrite(V1, sensorValue); // sending sensor value to Blynk app
}
BLYNK_WRITE(V1) // Executes when the value of virtual pin 1 changes
{
if (param.asInt() == 1)
{
// execute this code if the switch widget is now ON
sensorDataSend();
}
else
{
// execute this code if the switch widget is now OFF
digitalWrite(led, LOW);
}
}
void loop()
{
Blynk.run();
timer.run(); // Initiates SimpleTimer
}
and the result is remains the same
14:03:22.700 -> [36283] Connected to WiFi
14:03:58.008 -> [71605] Ready (ping: 14ms).
14:04:58.433 -> [132027] Ready (ping: 13ms).
14:05:33.753 -> [167344] Ready (ping: 28ms).
14:06:09.052 -> [202650] Ready (ping: 14ms).
14:06:44.361 -> [237958] Ready (ping: 13ms).
14:07:19.650 -> [273276] Ready (ping: 13ms).
You’ve totally mis-understood the way in which timers are supposed to be used.
You aren’t meant to be using a timer to simulate a delay.
The main delay in your original code was there to ensure that the sensor was only read once every 2 seconds. In reality, when using a DHT sensor, that really ought to be every 5 seconds.
To achieve this without a delay, a timer is defined which will call the code to read the sensor once every 2 (but preferably 5) seconds.
If you also want to flash an LED on and off when the sensor is read then you’d either use a timeout timer, or a 3rd party library like Ticker.
You can read about timeout timers, along with the correct way to use interval timers, here…
but for now I would simply focus on using a timer to read the sensor, then add-in the LED flashing code later.
Pete.
@PeteKnight I deleted some of the timer and delay.
#define BLYNK_TEMPLATE_ID "TMPL5vzGTnYc"
#define BLYNK_DEVICE_NAME "DHT22"
#define BLYNK_AUTH_TOKEN "";
#define BLYNK_PRINT Serial
//Libraries
#include <DHT.h>;
#include <ESP8266_Lib.h>
//#include <ESP8266WiFi.h>;
#include "WiFiEsp.h"
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif
#define DHTPIN 10 // connect the dht output to 10(pwm)
#define DHTTYPE DHT22 // DHT 22 (AM2302)
#define led 8 //connect to led to pin 8-->change to motor later
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
#include <BlynkSimpleShieldEsp8266.h>
//#include <SimpleTimer.h>
#define EspSerial Serial1
#define ESP8266_BAUD 115200
//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value
char ssid[] = "GoCO"; //You can replace the wifi name to your wifi
char pass[] = ""; //Type password of your wifi.
int status = WL_IDLE_STATUS; // the Wifi radio's status
char auth[] = "";
ESP8266 wifi(&EspSerial);
SimpleTimer timer;
//int virtual_pin_value = param.asInt();
//param.asStrng()
//param.asFloat()
//BlynkTimer timer;
void delaytimer()
{
int count = 0;
Serial.print("delay");
Serial.print(count);
count++;
}
void setup()
{
// initialize serial for debugging
Serial.begin(115200);
// initialize serial for ESP module
Serial1.begin(115200);
// initialize ESP module
WiFi.init(&Serial1);
pinMode(LED_BUILTIN, OUTPUT);
dht.begin(); //start running the dht
pinMode (led, OUTPUT); //set the led(pin8) as output
pinMode (LED_BUILTIN, OUTPUT); //set the led on board as output
WifiStatus();
}
void WifiStatus()
{
// check for the presence of the shield
if (WiFi.status() == WL_NO_SHIELD) {
digitalWrite(LED_BUILTIN, LOW); //no on board led if no wifi
Serial.println("WiFi is not connected");
// don't continue
while (true);
}
// attempt to connect to WiFi network
while ( status != WL_CONNECTED) {
digitalWrite(LED_BUILTIN, HIGH);//connecting have on board led
Serial.print("Connecting to ");
Serial.println(ssid);
// Connect to WPA/WPA2 network
status = WiFi.begin(ssid, pass);
}
// you're connected now, so print out the data
Serial.println("You're connected to the network");
EspSerial.begin(ESP8266_BAUD);
Blynk.begin(auth, wifi, ssid, pass);
timer.setTimeout(3600000L, [] () {} ); // dummy/sacrificial Function
timer.setInterval(5000L, sensorDataSend); // call the take_sensor_reading() function every 5 seconds
sensorDataSend();
}
void sensorDataSend()
{
//timer.setInterval(200L, delaytimer);
digitalWrite(LED_BUILTIN, HIGH);
timer.setTimeout(20, delaytimer);
digitalWrite(LED_BUILTIN, LOW);
timer.setTimeout(20, delaytimer);
hum = dht.readHumidity();
temp = dht.readTemperature();
//Print temp and humidity values to serial monitor(help checking the data)
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
if (temp >= 20) //running the motor with sensor
{
digitalWrite(led, HIGH); //switch on motor
}
else
{
digitalWrite(led, LOW); //switch off motor
}
// sensorValue = analogRead(A5); // reading sensor from analog pin
// Blynk.virtualWrite(V1, sensorValue); // sending sensor value to Blynk app
}
BLYNK_WRITE(V1) // Executes when the value of virtual pin 1 changes
{
if (param.asInt() == 1)
{
// execute this code if the switch widget is now ON
sensorDataSend();
}
else
{
// execute this code if the switch widget is now OFF
digitalWrite(led, LOW);
}
}
void loop()
{
Blynk.run();
timer.run(); // Initiates SimpleTimer
}
But it doesnt help, what should I do? am I still misunderstanding sth?
14:48:38.646 -> [255444] Ready (ping: 14ms).
14:49:03.957 -> [280749] Ready (ping: 14ms).
Please post your full serial monitor output from device boot-up.
Pete.
@PeteKnight thank you for your quick reply. here is the serial monitor output
15:17:38.094 -> [WiFiEsp] Initializing ESP module
15:17:39.102 -> [WiFiEsp] >>> TIMEOUT >>>
15:17:44.046 -> [WiFiEsp] >>> TIMEOUT >>>
15:17:44.046 -> [WiFiEsp] End tag not found
15:17:44.046 -> [WiFiEsp] Warning: Unsupported firmware
15:17:48.063 -> Connecting to GoCO
15:17:53.782 -> [WiFiEsp] Connected to GoCO
15:17:53.782 -> You're connected to the network
15:17:53.782 -> [15685]
15:17:53.782 -> ___ __ __
15:17:53.782 -> / _ )/ /_ _____ / /__
15:17:53.782 -> / _ / / // / _ \/ '_/
15:17:53.782 -> /____/_/\_, /_//_/_/\_\
15:17:53.782 -> /___/ v1.0.1 on Arduino Uno
15:17:53.829 ->
15:17:54.298 -> [16198] Connecting to GoCO
15:18:07.348 -> [29230] AT version:1.6.2.0(Apr 13 2018 11:10:59)
15:18:07.348 -> SDK version:2.2.1(6ab97
15:18:13.382 -> [35286] +CIFSR:STAIP,"192.168.1.201"
+CIFSR:STAMAC,"24:a1:60:3d:86:6b"
15:18:13.382 ->
15:18:13.382 -> [35287] Connected to WiFi
15:18:23.678 -> [45596] Ready (ping: 13ms).
15:18:59.194 -> [81078] Ready (ping: 18ms).
15:19:34.510 -> [116410] Ready (ping: 28ms).
You’re using SoftwareSerial on an Uno and attempting to use a baud rate of 115200, yet SoftwareSerial for AVR devices doesn’t work successfully at rates higher than 9600.
I have no idea what the WiFiEsp library does, but it’s throwing some error messages that you’re ignoring.
Exactly what hardware are you using?
Pete.