0

Solved : In Mac I went back to Tools --> Boards Manager, then removed 3.0 and downgraded to 2.5 and it started working. I found the solution in this thread.


The current connection between uno R3 and esp8266 is

UNO ----- ESP8266

RX — RX
TX — TX
GND — GND
3.3V — VCC (used bread board)
3.3V — CH_PD (used bread board)
GPIO - GND

UNO ----- UNO

Reset -- GND

Then ESP8266 send "OK" when I send AT from the serial monitor. When uploading the red light and blue blinks in esp8266 and rx and tx light blinks at uno r3.

I had to do sudo launchctl stop /dev/cu.usbmodemxxx before running below command.

Since I have GPIO connected to GND, I though that would trigger the programming mode, but for some reason it gives Invalid head of packet. I get same error when trying to upload code from arduino IDE.

I tried below command too from cmd line.

$sudo python esptool.py -t --chip esp8266  --port /dev/cu.usbmodemxxx --before no_reset flash_id
esptool.py v2.8
Serial port /dev/cu.usbmodemxxx
Connecting...TRACE +0.000 command op=0x08 data len=36 wait_response=1 timeout=0.100 data=
    0707122055555555 5555555555555555 | ... UUUUUUUUUUUU
    5555555555555555 5555555555555555 | UUUUUUUUUUUUUUUU
    55555555                          | UUUU
TRACE +0.000 Write 46 bytes: 
    c000082400000000 0007071220555555 | ...$........ UUU
    5555555555555555 5555555555555555 | UUUUUUUUUUUUUUUU
    5555555555555555 5555555555c0     | UUUUUUUUUUUUU.
TRACE +0.000 Read 3 bytes: f8fef0
TRACE +0.000 Read invalid data: f8fef0
TRACE +0.000 Remaining data in serial buffer: 
.TRACE +0.056 command op=0x08 data len=36 wait_response=1 timeout=0.100 data=
    0707122055555555 5555555555555555 | ... UUUUUUUUUUUU
    5555555555555555 5555555555555555 | UUUUUUUUUUUUUUUU
    55555555                          | UUUU
TRACE +0.000 Write 46 bytes: 
    c000082400000000 0007071220555555 | ...$........ UUU
    5555555555555555 5555555555555555 | UUUUUUUUUUUUUUUU
    5555555555555555 5555555555c0     | UUUUUUUUUUUUU.
TRACE +0.001 Read 1 bytes: f0
TRACE +0.000 Read invalid data: f0
TRACE +0.000 Remaining data in serial buffer: f0f0
.TRACE +0.056 command op=0x08 data len=36 wait_response=1 timeout=0.100 data=
    0707122055555555 5555555555555555 | ... UUUUUUUUUUUU
    5555555555555555 5555555555555555 | UUUUUUUUUUUUUUUU
    55555555                          | UUUU
TRACE +0.000 Write 46 bytes: 
    c000082400000000 0007071220555555 | ...$........ UUU
    5555555555555555 5555555555555555 | UUUUUUUUUUUUUUUU

......

A fatal error occurred: Failed to connect to ESP8266: Invalid head of packet (0xF0)

Below is the image of the arduino IDE with code and board selected as esp8266.

enter image description here

I am following this post https://iot-guider.com/esp8266-nodemcu/how-to-program-esp8266-with-arduino-uno/ and I have exact same hardwares.

UPDATE:

When I tried this connection in Windows it starts uploading code without error. So, my guess is its something to do with MAC.

10
  • This reads as if you're omitting some info... what is the role of the UNO? Are you using it to flash the ESP? Also, which GPIO are you pulling to GND? The ESP has many of these. Flashing an ESP also requires pulling three GPIOs up or down. Finally I note that you connect RX to RX and TX to TX -- normally, you need to connect TX (transmit) to RX (receive) on a serial connection. – orithena Jun 23 at 10:08
  • @orithena I was following this post iot-guider.com/esp8266-nodemcu/… I have the exact same hardware. – solti Jun 23 at 10:49
  • From that article: "Also, connect the RX and TX lines of both." -- this means to connect TX on UNO to RX on ESP and RX on UNO to TX on ESP. I'm repeating that because your question lists those connections wrong. I'm also a bit concerned that those instructions show to connect the 5V TX/RX of the UNO to the 3.3V TX/RX of the ESP... – orithena Jun 23 at 11:03
  • "Also, connect the RX and TX lines of both." this line does not necessarily say, I say this because the image connects RX of esp8266 to RX of uno and TX esp8266 to TX of uno. By the way I did tried connect RX-TX and TX-RX get the same error. I also tried connecting with 5 V and I get same error. – solti Jun 23 at 11:20
  • The Atmega328 is being held in reset - essentially dormant. This technique borrows the Uno's auxilliary 16U2 chip, the USB <-> TTL converter to program the ESP. The Rx & Tx connections are correct as viewed as between the PC and the ESP, and the '328 plays no part in the communication, in this case. I share your concern about driving the 3.3v ESPs receive pin with a 5v transmitter, however. – JRobert Jun 23 at 11:35
0

The tutorial you linked to can not be trusted! There are mayor mistakes:

  1. They connect a 3.3V device with a 5V devices without taking any measures to convert the logic levels.
  2. Connecting Rx to Rx (or Tx to Tx) is typically not what you do if you want to communicate between devices. A transmitting line must be connected to a receiving line for that. In case the arduino is Serial.print()ing something himself, a bus contention can cause a short circuit and harm the UART pins.
  3. They are plugging the ESP into a breadboard which simply doesn't work! This will short several pins and possibly kill some hardware. At least it can't work like that.

I don't know if the person who did this tutorial just has no idea or is trolling, but you need to find a different tutorial (and - I'm sorry to say - possibly get a new ESP).

If all you want is to use the arduino as a USB to UART bridge, I suggest to remove the atmega chip from its socket on the arduino or make sure that it doesn't run a sketch were it prints something. The UART pins should also be configured as inputs.

7
  • Every other tutorial in internet is using ESP with bread board though. – solti Jun 23 at 19:41
  • The 5 holes (A,B,C,D,E) of a row are connected together on those breadboards. Can you show me another example where an ESP01 is put onto a breadboard? Maybe they use one of the ESP-based modules, like the nodeMCUs, which can be used on a breadboard. Pin headers with two rows are generally not very suitable for breadboards... – Sim Son Jun 24 at 2:30
  • This is another one youtu.be/ZJnpgYlelEA?list=LL . Also I was able solve the issue, in my Mac I went back to Tools --> Boards Manager, then removed 3.0 (I had 3.0 version) and downgraded to 2.5 and it started working (meaning started uploading the code and the code in esp8266 was executed as expected). Yes, this is still using ESP01 on bread board. I have edited and mention this in top my question. – solti Jun 24 at 2:43
  • @solti in that video, the person uses jumper wires to connect the esp to the breadboard. What I wrote still applies... – Sim Son Jun 24 at 11:54
  • you point 2 is not valid. the goal is to use the USB of the Uno, not to connect to ATmega. – Juraj Jun 25 at 5:29

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.