So my team tried to connect arduino MEGA 2560 + ESP-01
we flash the necessary AT firmwares, download the latest blynk libraries but could not make the ESP 01 connect to the blynk server. There are times that it connects, but the connection will drop after 20 to 30 seconds.! Here’s my serial monitor after uploading the code to the MEGA board
[9]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.5.1 on Arduino Mega
[592] Connecting to PLDTHOMEDSLPAKABITKADIN
[3642] AT version:1.1.0.0(May 11 2016 18:09:56)
SDK version:1.5.4(baaeaebb)
Ai-Thinker Technology Co. Ltd.
Jun 13 2016 11:29:20
OK
[10771] +CIFSR:STAIP,"192.168.1.10"
+CIFSR:STAMAC,"60:01:94:4c:94:d4"
[10779] Connected to WiFi
[21219] Redirecting to 45.55.96.146:8080
And the nothing happens.
any suggestions on what might be the problem?
here’s my code
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <DHT.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "MYAUTHTOKEN";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "MYSSID";
char pass[] = "MYPASSWORD";
// 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 115200
ESP8266 wifi(&EspSerial);
#define DHTPIN 22 // What digital pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT22 // DHT 11
//#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21 // DHT 21, AM2301
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
void myTimerevent ()
{
Blynk.virtualWrite(V7, millis() / 1000);
}
// 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(9600);
// 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.com", 8442);
//Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8442);
dht.begin();
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
timer.setInterval(1000L, myTimerevent);
}
void loop()
{
Blynk.run();
timer.run();
}