I am new to IOT and I've just started to learn. I am working on a project which involves sending sensor data to a server. So, I want to send my data over wifi and I decided on using a esp8266 01 for communication. Basically to get wifi on my arduino.
So I made the connections as specified here and this is the circuit diagram. However, I used an Arduino Uno and gave the 3.3V supply from the 3V3 of the arduino. The module does power on,but I'm unable to get it to respond to AT commands.
Do you know what the default baudrate of the ESP-01 is?
So you - have not shown your code but - must be using Software Serial for this. Reputedly does not work well at 115,200 Baud.
If you want WiFI, just use the ESP and drop the Arduino. An ESP-01 can read digital sensors quite well.
To program the ESP-01, you use a purpose-built USB programming adapter which works perfectly with the Arduino IDE: Aliexpress item
At least, that is the manual switching version; here is the automatic version which while it does have the reset button, initiates the programming directly from the Arduino IDE: Aliexpress item
Similarly, to actually use the ESP-01 in a project, a very convenient way is with the cheaper adapter board, plugged into a USB "phone charger" so you have both the 5 V and 3.3 V conveniently and adequately supplied. Aliexpress item
You have three GPIO conveniently available by soldering to the adapter, and the fourth - serial Rx - can be separated from the USB chip if necessary by cutting a track. Using those I/O you can connect port expanders for many more I/O connections and a variety of sensors.
It should be ok if it is an UNO, if you have issues connecting to WiFi this may be the cause however.
I Use my (original) UNO without issue.
You should also connect RST to 3.3v (through a 10K resistor if you want) not all ESP-01's have a pullup connected to it.
It is not reliable for reception at 115200, but ok for transmission. If your first AT command is to change the BAUD to 9600 you can take it from there. Mind you if the swSerial is the problem, you should be receiving something after sending. (broken bytes and all, but you should be getting some response.)
Totally, though you can program it using an Arduino (UNO) just fine. This is the link i tend to refer to.
If you want to stick to AT-commands (not recommended, but i do recommend getting AT-commands to work first) either you have to do a Serial passthrough, and make sure that your line-ending is 'Both CR & LF' or connect it straight to the Arduinos RX & TX and load an empty sketch onto it.
If everything looks correct, the esp module may not be working (I got a bad one off the internet). Try another esp module if you have one. If you have the money I find the arduino Uno WiFi board with the Nina library much simpler to use than the esp.
This is the code: #include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX
void setup()
{
Serial.begin(9600); // communication with the host computer
// Start the software serial for communication with the ESP8266
ESPserial.begin(9600);
Serial.println("");
Serial.println("Ready");
Serial.println("");
}
void loop()
{
// listen for communication from the ESP8266 and then write it to the serial monitor
if ( ESPserial.available() ) { Serial.write( ESPserial.read() ); }
// listen for user input and send it to the ESP8266
if ( Serial.available() ) { ESPserial.write( Serial.read() ); }
}
A very basic one. I'm not planning to stick to AT commands-I just wanted to check if everything works okay. I dont get any output at all if I give AT commands. Absolutely no response. My line ending is 'Both CR&LF'.
I will try to connect directly to Arduino Tx and Rx and check that out once,thanks.
I need to use an arduino as I have connected other sensors to it as well. My aim is to send data obtained from those sensors over wifi to my server. That's why, I doubt a USB adapter would be of much help to me.
For what it's worth...
Why not simply use an Arduino compatible board that already has WiFi, like the NodeMCU or Wemos D1 Mini?
Whenever I hear of someone using an ESP01 board to connect an Arduino to WiFi, I am reminded of the wisdom of Marvin: "This will all end in tears. I just know it."
Please follow the advice given in the link below when posting code , use code tags and post the code here to make it easier to read and copy for examination
Eh... An ESP-01 is also one of those boards, it just doesn't have a 'USB to Serial' on board. Or a 3.3v regulator for that matter.
ESPserial.begin(9600);
So the recommendation should be to try and send the AT-command to switch to 9600kbps
so instead you can try something like
ESPserial.begin(115200);
//-- more commands to verify the version etc.
ESPserial.print("AT+CIOBAUD=9600\r\n");
ESPserial.begin(9600);
Hoping that the firmware version responds correctly to that command.
You can send a couple more commands to verify what those commands are. Of course you do need to read the 'ESPserial' input buffer (whoich you only do during loop() atm), and i recommend doing that before the baudrate switch. I never actually used a a swSerial port to send AT-commands. It is just too clumsy. If you want to use AT-commands and find it's limitations i suggest you load an empty sketch onto the Arduino, and connect the ESP Rx & Tx to the Arduino Rx & Tx (like that, so not crossed) and set the Serial monitor to 115200 and CR & NL and type them in directly.
n.b i googled the baud-rate change command and it showed me that there are some issues with that, but found what i shared here
What exactly do you mean by "stepping down"? You mean with a regulator? That's what is on the modules I recommended.
You just use port expanders instead of an Arduino.
Keeping all the coding on one processor makes it much easier, no need to arrange a communications protocol whether "AT" commands or your own bespoke.
The USB adaptor plugs into a convenient power supply and contains the 3.3 V regulator.
Very little difference in cost between an ESP-01 and a WeMOS D1 Mini which then includes the 3.3 V regulator.