Arduino with ESP8266 Basic Setup
Shopping list
- ESP8266 Serial WIFI Wireless Transceiver Module Send Receive LWIP AP+STA arduino
(Ebay Store) - New IIC I2C Logic Level Converter Bi-Directional Module 5V to 3.3V For Arduino
(Ebay Store) - Arduino Mega
(Ebay Store)
Setup
The ESP communicates via the serial link with Arduino. Connection is easy:
RX -- TX1 via the I2C level converter.
TX -- RX1 via the I2C level converter.
GND -- Ground
VCC -- 3.3V source
CH_PD -- 3.3V source
GPIO0 -- 3.3V source
GPIO1 -- 3.3V source
Note: For TX and RX I used the I2C level converter which is working without any problem. Only confusing thing is that if you measure the voltage via multimeter on the HVx or LVx you always get the HV or LV value, no matter what goes in on the other side.
Programming
For Arduino Mega the situation is easier since we have the Serial1 right away, otherwise the SoftwareSerial needs to be used (not verified).
The program is very easy:
void setup()
{
Serial.begin(9600);
Serial1.begin(115200);
delay(500);
Serial.println("Starting");
}
void loop()
{
while (Serial1.available()) {
Serial.write(Serial1.read());
}
while (Serial.available()) {
Serial1.write(Serial.read());
}
}
For sending the commands to the ESP module, configure the Arduino IDE so that CR and LF is sent, you choose that at the bottom right corner of the serial monitor window.
Note: Be aware that the ESP module may have different baudrate on the serial connection that is expected. For the the 115200 baudrate for the ESP serial worked.
External Sources
- http://dalpix.com/blog/connecting-your-arduino-wifi-esp-8266-module
(program the serial forwarding to ESP) - http://www.allaboutcircuits.com/projects/update-the-firmware-in-your-esp8266-wi-fi-module/
(how to connect it) - http://www.rei-labs.net/esp8266-connecting-to-internet/
(connecting to the internet)