Im having problem with my esp8266 and my arduino. My project is gas sensor using arduino uno and when it detect gas it will produce alarm, and led will turn on also will send noti to blynk. Everything works fine before i adding blynk coding to my arduino. When i put esp8266 blynk coding, all of this doesnt work . when i upload the coding , it doesnt show any error. The output of serial monitor is esp8266 is not responding , can u help me, this is my coding
#define BLYNK_PRINT Serial
SoftwareSerial EspSerial(2,3); // RX, TX
const int gasPin=A0;
const int buzpin=11;
const int threshold=100;
const int ledPin=13;
char auth = "497b411df81c4be184a6b8478d0e7218";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid = "babablacksheep";
char pass = "taikmu123";
#define ESP8266_BAUD 115200
pinMode (ledPin, OUTPUT);
// Set ESP8266 baud rate
Blynk.begin(auth, wifi, ssid, pass);
digitalWrite (ledPin, HIGH);
else if (gasValue<50)
digitalWrite (ledPin, LOW);
connection from my esp8266 to my arduino
and use blynkTimer to run the new function every 1 second (or whatever…)
// Debug console
// Setup a function to be called every second
digitalWrite (ledPin, HIGH);
timer.run(); // Initiates BlynkTimer
I dont know whether it is baud rate issue or not because when i.upload it doesnt show any error and success but still my led buzzer doesnt work and esp is not responding , if it was because baud rate issue , may i know how to solve it?
You’re using the Software Serial library to create a dummy serial port for communication between your Arduino and ESP.
The problem is that the library used to do this works reasonably well at low baud rates, but not at the type of baud rate that you’re using.
People who insist on doing this Arduino/ESP combination say that 9600 is the highest baud rate that you should be using.
However, you can’t just pick a random baud rate and expect communication between your Arduino and ESP to just work. You have to tell the ESP what baud rate it should use to communicate with your Arduino, then match this rate in your code. This is done by sending an AT command to the ESP to set it up at the correct rate. This only needs to be done once, but it does need to be done.
Searching this forum for Arduino + ESP-01 will give you more information than you could ever need!
It will work as a Wi-Fi modem if was shipped with AT firmware or you re-flash it with AT firmware.
However, the NodeMCU is much more powerful than the Arduino, so I’m not sure why you’d bother using the Arduino/NodeMCU combination.
The only issue you may have is if you need to connect more than one analogue device to your NodeMCU, or if your gas sensor is a 5v logic device rather than 3.3v. If that’s the case then a cheap and simple level shifter could be used to convert the 5v logic to 3.3v.
The Tx and Rx pins on your Arduino are connected to the built-in UART, which are also connected to the large USB connector and which is defined in your code as “Serial”. When you do commands like Serial.print, the data is sent to these pins.
If you were trying to communicate with your NodeMCU Wi-Fi modem using the same UART then the two sets of communication would clash with each other.
To give yourself an extra UART on the Arduino, you’re using the Software Serial library and in the line of code that I quoted you’re telling the software serial library that you want to use pins 2 and 3.
This second ‘dummy’ UART is referenced as “EspSerial” in your code, and as I’ve said earlier, you’re trying to use a baud rate that is too high for the software serial library to be able to handle.
As I’ve also said before, your NodeMCU needs to be configured by an AT command to use the same baud rate as you specify for your software serial dummy UART.
I still think you should throw your Arduino in the bin and work exclusively with the NodeMCU.