The Arduino Uno R3 only has 1 HW UART that is connected to the on board USB – UART chip. I need a second one to interface with my recently purchased ESP8266 ($4 Wifi module).
- Challenge 1: Voltage Difference
- ESP8266 is 3.3V only IO
- Arduino Uno R3 is 5V IO
- Solution: Use simple R divider
- This only is good for slow speed signals. I plan on using only 9600 baud so this should work for now.
- To keep is simple, I am using just 2x 10K ohm R’s on the Arduino SW UART TX pin. The Arduino RX pin shouldn’t need anything. Hoping that 3.3V coming from the ESP8266 is high enough for the switching level of the Arduino.
- Here is the simple diagram of my plan…
Instead of jumping straight in, I am going to use an FTDI TTL-232R-3V3 cable to test the Arduino SW UART concept. This is easier to debug since I can use TeraTerm on the PC to connect to the FTDI cable and send / receive any characters at any time to test the connects and the Arduino SW sketch.
- Here is the connection diagram I used…
- Simple Arduino sketch for testing
- Concept is to pass all data from the FTDI cable connected to Arduino pins6,7 (which are NOT HW UARTs) to the Arduino HW UART.
- Here is my simple sketch
Software serial testReceives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.*/
SoftwareSerial mySerial(7, 6); // RX, TX
// Open serial communications and wait for port to open:
void loop() // run over and over
- It is based off of http://arduino.cc/en/Reference/softwareSerial
- Screen Capture of TeraTerm and Arduino
YAHOOO!!!!! It worked. Now to connect it up to the ESP8266 and see if it work.