Sony Arouje

a programmer's log

Posts Tagged ‘ESP8266; Arduino; wdt reset

Program ESP8266 with Arduino IDE

with 4 comments

Last couple of days I was trying to setup an ESP8266 module to program using Arduino environment. By Default ESP8266 bootloaded with AT Bootloader. Initially I connected ESP to Arduino and communicated using AT Mode via WiFiESP library.

The intention of my experiments is to add internet support in my Aeroponic controller. But AT mode deals with strings and thus increase the flash size, and when I added MQTT functionality with rest of Aeroponic sketch, I almost filled the flash size of Atmega328. So I decided to look for alternative options.

One of the beauty of ESP8266 is, it has it’s own flash memory. Also the integration with Arduino IDE. This way I can write Arduino sketch and embed it into ESP8266 instead of writing it to Atmega328.

Installing ESP8266 addon to Arduino IDE.

Sparkfun have a nice post about setting up the IDE. At the end of tutorial they choose ‘Sparkfun ESP8266 Thing’, instead I selected ‘Generic Esp8266 Module’, see the screen shot below.

 esp_arduino_ide

Hardware Connection

To write Arduino sketches to ESP we need a USB TTL module. Connect the module as below.

  • ESP8266-> USB TTL
  • GND-> GND
  • TX-> RX
  • RX-> TX
  • GPIO0-> GND

I powered the ESP module from an external source, ESPs are really power hungry, I am not sure whether the USB module can give the required current.

  • ESP8266-> External power
  • VCC-> 3.3v
  • CH_PD->3.3v

Make sure you have a  common GND, for ESP, External power and USB TTL. That means connect all GNDs together. If there is no common GND then expect the unexpected, IDE will keep throwing fatal exception.

Once the sketch is uploaded, connect GPIO0 to VCC, then switch off/on the ESP module. Now the ESP will start running the sketch.

Challenges

Keep getting wdt reset message as shown below. To test I added the blink demo with a serial write. This simple program works well until I add ‘ESP8266WiFi.h’, after this header file and uploading the sketch will start throwing the below in Serial monitor.

ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld

I tried a lot of options to resolve this issue. First I thought the module is not receiving enough current, so I powered it with 5v. This doesn’t make any difference.

In one of ESP forums some one suggest to erase flash using ESPTool, so I setup ESPTool and issued command like

python esptool.py p com6 erase_flash

This didn’t work out either. In another forum one person suggest to write blank.bin to 0x7E000, also mentioned that some times the reset can occur because of corrupted flash. This leads me to believe that corrupted flash causing the reset. So I decided to start all over again.

As an initial step I decided to boot with default AT bootloader. Here is a great post to follow.

While trying to bootload, esptool crashes always with ‘fatal exception’. I changed my USB Serial and tried again, this time all the bootloading steps works and configured the ESP back to AT mode. Then again I tried to burn the arduino sketch via Arduino IDE and it worked really well.

So I believe the wdt reset caused by, an issue with USB Serial module or corrupted flash. Now ESP8266 is working fine without any reset.

Advertisements

Written by Sony Arouje

November 7, 2016 at 11:40 pm

Posted in Arduino

Tagged with

%d bloggers like this: