Sunday, March 8, 2015

How to configure ESP8266 to the newest firmware

I got quite trouble for setting up ESP8266, so I'd like to share the way to configure it here (or memo it -_-)

HW configuration

ESP8266 uses all 3.3v for VCC, input, output. So I used 3.3v Adapter to power-up ESP8266, and FTDI USB-to-Serial with 3.3v. The basic PIN connection is as the following.
My module is ESP-07 which is different from the article, but the pin out is the same.

Pin configuration :
ESP8266 GPIO15 -> GND

How to update FW :
  1. GPIO0 to GND
  2. connect ESP8266 to TX/RX/GND of FTDI
  3. Download the following ESP8266 SDK and downloader
    SDK :
    Flash Downloader : 
  4. There is a README file. :  esp_iot_sdk_v0.9.5_15_01_23\esp_iot_sdk_v0.9.5\bin\at. I used "new" way, and the following is the address for each images.
    boot_v1.2.bin      0x00000  0x01000
    blank.bin          0x3e000
    balnk.bin          0x7e000
  5. GPIO0 to HIGH
  6. Set the default configuration and update FW through OTA. The settings are stored in the flash, so this is just a one time thing.
    AT+CWMODE=1 -> Station mode

    AT+CWAUTOCONN=0 -> auto AP connection disable
    AT+RSTAT+CWJAP="leekwon2G","x" -> AP connection
    AT+CIUPDATE -> OTA update
    AT+UART=9600,8,1,0,0 -> UART setting
  7. The final version after the procedure. :
    AT version:
    SDK version:0.9.5

Tuesday, March 3, 2015

Using optiboot for Arduino pro mini 3.3v to enable watchdog with Arduino IDE 1.6

My Arduino Mega and Arduino Pro Mini does not reset properly after watchdog. In case of Arduino Mega, the watchdog works properly after writing down bootloader using another Arduino, but Pro Mini does not reset properly even after writing bootloaer. After some Googling I found that optiboot is a default for Arduino IDE 1.6.0 for Mega, and Pro Mini has traditional bootloader image. In short, watchdog reset works fine with optiboot image. The following is a stitch of various material that I googled to burn the optiboot to Pro Mini 3.3v 8MHz.

1. building optiboot contained in Arduino IDE 1.6
Arduino IDE 1.6 does not have make utility. So I had to use external make utility from cygwin.

2. Modifying the Makefile
Open C:\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders\optiboot\Makefile and modify the following line. I got the information that FTDI USB serial chipset cannot handle 115200bps download and reset speed properly.

atmega328_pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=57600'

3. Build the bootloader for Pro Mini 3.3v
In the cygwin, run the following command

$ make atmega328_pro8

4. Adding entry to boards list.

Edit the following file to look like this. :
C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt

## Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328 - Optiboot 57.6k
## -------------------------------------------------- (3.3V, 8 MHz, Optiboot 57.6k)

## Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328
## -------------------------------------------------

5. Restart Arduino IDE

References :

Sunday, March 1, 2015

It looks like peek() of AltSoftSerial is not working

It looks like peek() function of AltSoftSerial is not working. I think the following is the right code fragment. (Working for me anyways).

int AltSoftSerial::peek(void)
    uint8_t head, tail;

    head = rx_buffer_head;
    tail = rx_buffer_tail;
    if (head == tail) return -1;
    if (tail + 1 < RX_BUFFER_SIZE)
        return rx_buffer[tail+1];
        return rx_buffer[0];