0

I recently started playing around with Arduinos to connect a few sensors up. I used an Arduino Nano to measure temperature, humidity, air pressure and light level.

To store the data in a database, I used another Arduino that I connected to a Raspberry Pi, and let the two Arduinos talk wirelessly to each other via 433 MHz.

That all works pretty well, but the 433 MHz communication is not exactly the most reliable (I often miss a transmission). When I stumbled upon the ESP8266 module, it seemed like the optimal solution for communication. How cool would it be if I could just pull out the information via an HTTP call from the Raspberry Pi?

After toying around for many hours, uploading many different firmwares, getting more and more frustrated because I could not get it to do anything, I finally have it working through an FTDI module connected up like this:

enter image description here

I use an MB102 power module to provide the 3.3v required by the ESP8266. I turns out you need to connect the ground from the MB102 to the ground of the FTDI module to get any proper response. After doing that I was able to send AT commands and get the proper responses. I could even connect it to my home Wifi.

The next thing I want to do is connect it to the Arduino. I found a very simple schema for that (http://blog.huntgang.com/2015/01/20/arduino-esp8266-tutorial-web-server-monitor-example/), where you connect RX to TX and TX to RX. Using the MB102 I connected it like this:

enter image description here

Apparently I should now be able to upload a blank sketch to the Arduino, and then use the serial monitor again to sens AT command, exactly the same way I did it when using the FTDI module.

The problem is that I get nothing at all this way. I don't even see my own AT commands in the console. I do see the ESP8266 flashing every time I send a command (I even see it it still connected to my router, probably it remembered the info I send through the FTDI...?)

The question is, what am I going wrong? I read some posts about the TX from the Arduino also being 5v and that you need to do something to bring it back to 3.3v, but there are also many tutorials that say it's not required.

2

The easiest way to work with these devuces is to connect them to a spare pair of Arduino pins and use SoftwareSerial for communicating (unless you're using one of the Arduinos with more than one UART). SoftwareSerial work up to 9600 baud on 16MHz devices, 4800 on 8MHz devices, so you'll need to set the ESP8266 to accommodate that. They currently ship at 115200 baud. You can use the hardware UART on pins (0, 1) but then re-programming the Arduino means disconnecting & reconnecting the ESP temporarily each time, and gets old pretty quickly.

Here's what I do with new ESPs (If you've re-flashed your ESP, you'll need to download the AT instruction-set emulator and re-flash it with that, first):

# To configure a new ESP module:
# Connect the ESP and the FTDI as in your top diagram, set your
# terminal-emulator to 115200 baud, and enter the following:

AT                             # ESP should respond "OK"
AT+RST                         # Resets the ESP
AT+UART_DEF=9600,8,1,0,0       # Sets ESP UART: 9600,N,8,1,no flow ctl

# Now change the terminal emulator baud rate to 9600

AT+CWMODE=1                    # Set ESP to station mode (client)
ATE0                           # Set ESP's echo off  
AT+CWLAP                       # List access points - after a short pause
                               # the ESP returns a list of WiFi access points

For future reference, here is a link to the ESP8266 AT Instruction Set.

  • I just realized this question has been dredged up from the archive of unanswered questions from 6 months ago. Oh, well - maybe this answer will help someone else now or soon. – JRobert Jun 7 '16 at 19:35
0

There might be an issue with the baudrate from the Nano FTDI chip to the RX/TX and the ESP8266. Did you disconnect when uploading the sketch?

How about trying this instead?

Cheers!

  • When I work with the ESP8266, it works om 115200 baud, everything else just gives garbage. I've tried the code from the linked blog (only changing the baud rate) , I see it's sending command to the ESP8266 (blue light flashing), but it fails when it tries to execute the Serial.find(">") command. I also see nou output from the ESP8266 whatsoever. I did disconnect the ESP8266 while uploading. – ErikL Dec 16 '15 at 18:28
0

Stumbled on good tutorial here, tried and it does the job: https://blogs.msdn.microsoft.com/abhinaba/2016/01/23/esp8266-wifi-with-arduino-uno-and-nano/

  • That will work except for the CIOBAUD command which has been replaced. The current command for all UART functions is: AT+UART_DEF=<baud>,<databits>,<stopbits>,<parity>,<flowcontrol>, or AT+UART_DEF-9600,8,1,0,0 to be compatible with SoftwareSerial. Replace "_DEF" with "_CUR" if this change is only for the session; the first command makes it the power-on default. – JRobert Jun 7 '16 at 12:03
  • 1
    Please can you expand on the information from that blog into this answer if the link dies, but also to make it a better answer – RSM Jun 10 '16 at 17:07
0

Yes, if you are using different power sources the grounds always have to be connected, otherwise the boards don't know what zero volts is.

The TX of the Arduino is 5v, you need a level shifter to convert 5v to 3.3v, something like this (https://shop.pimoroni.com/products/adafruit-4-channel-i2c-safe-bi-directional-logic-level-converter?utm_medium=cpc&utm_source=googlepla&variant=302017581&gclid=CPqujsPxlc0CFcYcGwodb8YIoA)

The TX of the ESP8266 is 3.3v and the RX of the Arduino is 5V and you will need a level shifter to handle this. You can use the same one as listed above, because it can convert 4 high (5v) signals into 4 low (3.3v) signals.

People say you can so it with resistors, but I have also read that they don't perform well enough to handle fast switching digital signals (so 300 Baud on your serial might be OK, but not 115000 :) )

People also say you don't need level convertors. That's true things might work for a while without them, but sooner or later something will go pop. Increasing the voltage will speed up the process so you can imagine what will happen if you connected a 230v supply directly to a USB device.

One final point, do you know the ESP8266 is a 80/160MHz processor with 256KB of RAM, when you compare that to you Arduino its like programming you PC via your phone. What you could try is connecting the ESP8266 via a FTDI module and program it via the Arduino IDE in Arduino C. Its a lot easier than all this connection stuff.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.