Hello I am doing a little project where ESP8266 is supposed to send the data it got from Arduino Uno(which works completely fine) to Blynk and also get a signal to turn a water pump on or off.
The problem is that even with BLYNK_PRINT defined the standard Blynk begin doesn’t show up on the Serial Monitor. Not only that, the device itself seems to not be working, so nothing is posted on it and the ESP8266 recieves nothing.
Here is my sketch for the esp:
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#define BLYNK_PRINT Serial
char auth[] = "726vbF21w7UyF4C9KngX6rizCZKksXlz";//Enter your Auth token
char ssid[] = "ALHN-89E5";//Enter your WIFI name
char pass[] = "6161294651";//Enter your WIFI password
BlynkTimer timer;
bool Relay = 0;
int data[3] = {0, 0, 0};
//Define component pins
#define waterPump 12
void setup() {
Serial.begin(74880);
Wire.begin(D1, D2);
Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
timer.setInterval(1000L, req);
timer.setInterval(1000L, processCall);
}
BLYNK_WRITE(V0) {
Relay = param.asInt();
if (Relay == 1) {
digitalWrite(waterPump, LOW);
} else {
digitalWrite(waterPump, HIGH);
}
}
void processCall(){
Blynk.virtualWrite(V1, data[0]);
Blynk.virtualWrite(V2, data[1]);
Blynk.virtualWrite(V3, data[2]);
}
void req(){
Wire.requestFrom(8, 3); /* request & read data of size 13 from slave */
int i=0;
while(Wire.available())
{
data[i]=Wire.read();
i++;
}
}
void loop(){
Blynk.run();//Run the Blynk library
timer.run();//Run the Blynk timer
}
Thanks in advance!
Edit: It think the problem is in Blynk begin but I can’t figure out what is it.
I tried it, but while the serial monitor started at least working the Blynk message(?)/logo still isn’t showing up. I should also probably mention that while the Arduino/Esp8266 communication is working when I am not using the Blynk timer, I am suspecting that the Blynk timer is also not working because I tried to debug it through Serial monitor, but it also shows nothing.
@Oleksii-QA it doesn’t matter which baud rate you use in the sketch, provided your serial monitor is set to the same baud rate.
It is usually best to set the baud rate to the native baud rate used by the board/MCU you’re using, so you can see MCU related messages at start-up.
Most ESP8266 based dev boards use 74880 as their default native baud rate, and most ESP32s use 15200.
Pin D3 (GPIO0) is a strapping pin, which puts the board into Flash mode when pulled LOW. When it’s in flash mode it is waiting for a code upload and doesn’t enter run mode.
I’d recommend changing this to a more appropriate pin - see this link for more info…
I’d also suggest using GPIO numbers in your code, rather than “D” numbers.
If you still have issues then try removing all connections from your board, other than the USB connection.
If you still have issues then make sure you aren’t using any Digital datastreams.
Thank you for responding! Sadly, the problem still persists. I tried everything you said including changing to gpio pins, isolating the esp and checking the datastreams. It still just outputs garbage character in the Serial Monitor. I am not sure what to do here.
I used the baud rate you suggested and it is still outputing nonesense every time I load the ESP8266 up. I think there may be some problems from Blynk.begin() because after it the code completely stops executing. I just don’t know why, because the Wi-Fi connection seems to be fine.
Maybe if you told us EXACTLY what baud rate you’re now using in your sketch, and also told us EXACTLY which baud rate you’re selecting in your serial monitor, we’d be one step closer to being able to help you with this problem.
The serial monitor output will almost certainly tell you why, once you’ve managed to get it working correctly.