0
\$\begingroup\$

I'm trying to understand how to talk to ESP8266, but I'm very confused. I don't understand how to connect ESP8266 to serial, so I can send it commands from terminal, as far as I understood I need special hardware to do this which I don't have.

I have raspberry Pi and want to use it's GPIO pins to send the 'AT+GMR' command and read the response from the ESP8266.

I want to do this at low level, but I don't know what to look for, because I don't understand the process.

If I set one GPIO as output and connect it to ESP8266 RX and other GPIO as input and connect it to ESP8266 TX, what's next? I would simply write my command byte by byte and new line at the end and ESP8266 should give out singnal from TX to GPIO input? There is no 'protocol' in between or some kind of timing? Thanks

\$\endgroup\$
5
  • 2
    \$\begingroup\$ Why are you not using the serial pins? \$\endgroup\$ Sep 20 '16 at 14:47
  • \$\begingroup\$ @IgnacioVazquez-Abrams What would be the benefit? \$\endgroup\$
    – 0x29a
    Sep 20 '16 at 14:48
  • \$\begingroup\$ Serial is an asynchronous (i.e. without clock) protocol, where the timing between transitions is important. You can't simply write a byte to a single pin - it doesn't fit. \$\endgroup\$ Sep 20 '16 at 14:52
  • 2
    \$\begingroup\$ Other than the fact that you can use the serial peripheral on the RPi's SoC instead of bitbanging out serial? \$\endgroup\$ Sep 20 '16 at 14:52
  • \$\begingroup\$ If you are a beginner I recommend getting a NodeMCU instead of bare-ESP modules. NodeMCU is still dirty cheap but has everything needed to get started. \$\endgroup\$
    – filo
    Sep 20 '16 at 16:18
0
\$\begingroup\$

Actually, there is a protocol, described here:

enter image description here

Technically, it should be possible to program such protocol manually, using GPIO pins, but you'll inevitably get issues at higher baud rates, as your program will fail to respect the timing properly.

It's much better to use UART hardware which is available on all the RPi boards. Locate Tx and Rx pins on your board, disable linux login console on UART device and connect your ESP8266 to these pins (Rx of ESP8266 to Tx of RPi and vice versa). Then you'll be able to simply write your AT strings to /dev/ttyAMA0 file and read responses from it.

\$\endgroup\$
7
  • \$\begingroup\$ Thank you! I connected the ESP8266 to RX/TX, but when I connect to /dev/ttyAMA0 nothing happens and I can't type. I tried to start the ESP8266, but I can see it blink once when it powers up, but no data sent/received, I'm guessing it's an software issue. \$\endgroup\$
    – 0x29a
    Sep 20 '16 at 15:56
  • 1
    \$\begingroup\$ Did you check which baud rate ESP8266 expects and configured /dev/ttyAMA0 to that baud rate? \$\endgroup\$ Sep 20 '16 at 16:01
  • \$\begingroup\$ I tried 9600, 115200, 57600 and 76800, but still the issue persists \$\endgroup\$
    – 0x29a
    Sep 20 '16 at 16:12
  • \$\begingroup\$ 1. Why did you have to try, don't you know which one it is? Did this device come with documentation of some kind? 2. How do you "connect" to the serial device exactly? Do you use a tool like putty, minicom or screen, or do you open it programmatically? Add the command line or the source code to your question. \$\endgroup\$ Sep 20 '16 at 16:33
  • 1
    \$\begingroup\$ Because there are many versions of this module and depending on the version the baud rate is different, that's why I decided to try the ones listen by other users. I also ran 'raspi-config' and disabled login shell via serial and set enable_uart=1 in /boot/config.txt, but nothing changed. I I'm trying to connect using screen command 'screen /dev/ttyAMA0 baud_rate'. \$\endgroup\$
    – 0x29a
    Sep 20 '16 at 16:49

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.