Tag Archives: ESP8266

Problems with ESP32 configures as both Client and AP

In one project I had an ESP32 configured both as Access Point (AP) and as a Wifi Client. Everything was fine, until I changed my home Wifi password.

After changing the home Wifi password I wanted to change the Wifi password set on the device through the Web UI I made and hosted on the device. The problem started there. I was unable to access the UI.

Reviewing the code realised that the Wifi Client is continuously trying to re-establish the connection in a loop. And hence is unable to process the incoming request and process the page.

So either need to stop the scanning from time to time or stop the scanning when an AP client is connected. For short and fast resolution I stopped the wifi connection retry when a client is connected to AP.

WiFi.softAPgetStationNum()

ESP-01 Serial.println() or Serial.print() not working

I went crazy, mad trying to understand why the module is not printing anything to the Serial Monitor or receiving any AT commands.

I went through lots of articles on the internet and was on the verge of throwing the module away. Just that my mind was not willing to believe that it is dead – because I was able to burn OS / Firmware to the module every time I tried and the status showed success. And my suspicion was confirmed accidentally – I put some Serial.print code in loop instead of setup and it did throw output to serial monitor. It confirmed that something is wrong with the settings of Arduino IDE.

After lots of tweaking and trials I found that – the “Built In Led” settings of Arduino that mattered.  The built in LED is on the TX line of the module, hence just after printing some output when I toggled the LED, the print function didn’t get enough time to write to the monitor. To solve the matter a delay can be used also.

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("");
  Serial.println("Hello");
  delay(1000);
  pinMode(1, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(1, LOW); // turn the LED on (HIGH is the voltage     level)
  delay(500); // wait for a second
  digitalWrite(1, HIGH); // turn the LED off by making the voltage LOW
  delay(300); 
  digitalWrite(1, LOW); 
  delay(500); // wait for a second
  digitalWrite(1, HIGH); 
  delay(2000); 
}

In my module the LED is on PIN 1.

ESP-01 and ESP-01S Burning AT ROM- New and Updated

Few years back I had posted an article on burning ROM on ESP-01. The method worked good on my older boards but not working on the newer chips.

I needed to spend quite some hours to figure out the problem. And then it turned out that it is the SPI mode that is the matter. Also the new Flash tool (v 3.9.2 ) is not robust. It often becomes unresponsive.

  • Upload a blank sketch to Arduino Uno
  • The new ones need DOUT, 26 Mhz Xtal (check the board), SPI Speed 40 Mhz, 8Mbit. Burning with other modes may result in success but the chip will not work and will end up with boot errors. I got reset reason: 2, boot(3,7)
  • Connect RX to RX and TX to TX
  • GPIO_0 will go to GND
  • VCC and CH_PD will go to the 3.3v supply line
  • Select the appropriate ESP8266 board from Tools > Board menu.
  • Select the appropriate Flash mode (Only DOUT works for new chips. Old chips work with both QIO and DOUT)
  • Select baudrate as 115200
  • Start upload
  • RESET the module. This is a critical step and the timing matters. It may need a few tries to get it perfect.

The new Flash tool (v 3.9.2 ) is not robust. It often becomes unresponsive. The quick fix solution I found is pressing enter in the console (black window that it opens) and then disconnecting and reconnecting the Arduino (USB cable).

Wrong flashing may cause boot problems. To correct ERASE and FLASH OR FLASH all memory locations like shown below

The appropriate addresses can be found in the folder \ESP8266_AT_Bin_V1.6\bin\at\README.md

Please note – DoNotChgBin is unchecked.

After flashing Firmware version 1.6

AT+GMR
AT version:1.6.0.0(Feb 3 2018 12:00:06)
SDK version:2.2.0(f28eaf2)
compile time:Feb 6 2018 14:36:23
Bin version(Wroom 02):1.6.0
OK

All diagnostic messages  are sent at 74880 Bauds.
But AT commands are available only at 115200 Bauds.

After flashing disconnect GPIO_0 from GND and RESET

On proper flashing it will show ready like below

 

Here is the latest flash tool
Here is the ROM Version 1.6
Here is the ROM Version 1.6.2

NOTES:

  • Adequate power supply is needed for burning. I am using a buck convertor capable of delivering upto 1 amp.
  • Burning new chips with QIO will result in a successful burning but the code will not run.

 

 

ESP 8266 – ESP-12E Hello World – Blinking LED

We are using Arduino IDE to program our ESP8266. Please see this article regarding how to setup the Arduino IDE for programming ESP8266.

Here is a blinking LED code for ESP8266 written in Arduino IDE.

#define ESP8266_LED 5 
void setup() 
{   
   pinMode(ESP8266_LED, OUTPUT); 
} 
void loop() 
{   
   digitalWrite(ESP8266_LED, HIGH);   
   delay(500);   
   digitalWrite(ESP8266_LED, LOW);   
   delay(500); 
}

Instructions:

  • Connect a LED (with a resistor in series) to an I/O pin of your ESP8266. Change the pin number to an appropriate one in the first line of the code.
  • Select the appropriate ESP Board/Version fromthe Boards Menu of the Arduino IDE. If your board is not listed then you can select Generic and then set the parameters according to the chip or module version (ESP-01, ESP-06, ESP-12E etc) you are using.
  • Upload the code to the module.
  • The LED should be blinking now.

 

Connect Arduino and BMP 180 to Cloud

BMP 180 connect to Cloud

 

BMP-180

  1. SCL – Grey wire
  2. SDA – Orange Wire

 

Notes:

  • Here the hardware TX and RX has been used for performance.

 

The code:

See Arduino – Communicate with Server – Part 1

Updated code will be posted here some time soon.

For more details on ESP 8266 please see the article “https://www.kolkataonweb.com/code-bank/arduino/esp8266-esp-01/

ESP 8266 – ESP 01 – Installing Non-OS SDK

After a bit of trial and error got the Non-OS SDK installed. To flash the Non-OS SDK, two sets of files are needed. Below are the download links

 

The flashing tool is attached here for convenience.

 

Now the important part, the mapping (where I was going wrong) and flashing. Please check the documentation for the appropriate mapping. This is for Flash Size & Map: 8Mbit(512KB+512KB)

  • ESP8266_NONOS_SDK_V1.5.2_16_01_29\esp_iot_sdk_v1.5.2\bin\blank.bin    —         0x7e000
  • AT_V0.60_on_ESP8266_NONOS_SDK_V1.5.2_20160203\at\noboot\eagle.flash.bin       —      0x00000
  • ESP8266_NONOS_SDK_V1.5.2_16_01_29\esp_iot_sdk_v1.5.2\bin\esp_init_data_default.bin  —    0xfc000
  • ESP8266_NONOS_SDK_V1.5.2_16_01_29\esp_iot_sdk_v1.5.2\bin\blank.bin           —   0xfe000
  • AT_V0.60_on_ESP8266_NONOS_SDK_V1.5.2_20160203\at\noboot\eagle.irom0text.bin    —     0x40000

 

Non OS SDK Firmware Image Mapping

 

Here is the AT command manual for ESP 8266

 

As on date of writing a Patch has been released which can be downloaded from here or here  —  this patch didn’t work for me. The module is constantly sending some garbage making it unusable. 

ESP8266 ESP-01 – Part 2 – Useful AT Commands And Their Outputs

Below are some AT commands for ESP8266 and their outputs

AT
OK
AT+GMR
This will display firmware version and some other details 
AT+CIPMUX=1 
OK
AT+CWMODE=3 
OK
AT+CWJAP="WIRELESS-ROUTER","password"
[WIFI DISCONNECTED] (if it is already connected)
WIFI CONNECTED
WIFI GOT IP
OK
AT+CIPSTART=4,"TCP","x.x.x.x",80
4,CONNECT
OK
AT+CIPSEND=4,205
OK
> [at this point HTTP request will be made, read below for details]
Recv 205 bytes
SEND OK
+IPD,4,203:HTTP/1.1 200 OK
Date: Sun, 14 Feb 2016 20:33:16 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.14
Content-Length: 15
Connection: close
Content-Type: text/html

led_1=0|led_2=14,CLOSED

[The blue colored text above is what the server has sent in reply to the HTTP request]
AT+UART_CUR=2400,8,1,0,0
OK

[This command work with AT ver 6.0 and SDK ver 1.5.2. The changes will be temporary and will be restored to default on resetting. Use ]
AT+UART_DEF=2400,8,1,0,0

[This will make the change permanent. In case things gets wrong then reflash]

If AT+UART doesn't work then use 
AT+IPR

 

An extensive guide can be found here
https://github.com/espressif/ESP8266_AT/wiki/CWSAP

https://docs.espressif.com/projects/esp-at/en/latest/AT_Command_Set/Basic_AT_Commands.html

 

ESP8266 ESP-01 – Part 1 – Flashing and AT commands

This article is about the one that looks like this (aka ESP-01).

esp8266-esp-01-wifi-module-for-iot

 

Flasher version is 2.3
Firmware version is 1.5

Firmware update might be necessary just after purchase. Without firmware update mine was not able to connect to Wi-fi routers (though they were able to find them)

The current firmware available for this is “ESP8266_AT_v0.51”. The direct link to the download http://bbs.espressif.com/viewtopic.php?f=46&t=1451 . The download is at the bottom of the page as an Attachment.

firware files and readme

The flasher (for flashing firmware) can be found here http://bbs.espressif.com/viewtopic.php?f=57&t=433. The .rar version contains the necessary files to update the firmware.

WARNING: read the readme file that came with the firmware.

esp8266-flasher

Please note New chips need DOUT specifically, whereas old ones work with both QIO and DOUT

 Latest Flasher and Firmware Downloads (6th Feb, 2016):

 

Pin configuration of the module

esp8266 - pin

IMPORTANT NOTES:

  • This board runs on 3.3v
  • The default Baud rate is 115200
  • Boot errors are output over 74800. This is default and fixed.
  • For the RX TX line voltage divider using resistors doesn’t work. Using a 150 ohms in series for now, waiting for my Logic Level converter. But then so far (many years now) direct connection didn’t damage the ESP-01.

 

Flashing

  1. Used an Arduino Uno to flash the firmware.
  2. Upload a blank sketch to the Arduino.
  3. The module’s RX will go to Arduino RX and similarly TX will go TX.
  4. GPIO_0 will go to GND
  5. VCC and CH_PD will go to the 3.3v supply line
  6. Load the flasher
  7. Mine one came with “Ai-Cloud insid8” written. This module has a Flash size of 8Mbit: 512KB+512KB. QuadIO and 26MHZ crystal.
  8. Select the appropriate files in the “Download Path Config” section in the flasher tool. Some of the addresses might also need to be adjusted. READ the readme file that came with the firmware.
  9. Select the COM port on which Arduino is connected and the set the Baud rate to 115200 (the default of this board)
  10. Press start. If all goes well it will show finish to the left of the “Start” and “Stop” button
  11. If it fails – press “Stop”. Reset the board by Grounding RESET pin. And press Start again
  12. If the flashing is going on properly then the TX light of Arduino and the Blue light of the module will flash.
  13. Once firmware has been flashed disconnect the GPIO_0 pin from GND. Reset the module and start working

Useful links:
http://www.electrodragon.com/w/Category:ESP8266_Firmware_and_SDK

 

AT Commands

  1. Used Arduino Serial monitor for sending AT commands to the Module.
  2. The RX and TX pin configuration will remain same as above.
  3. Start with the AT command.
  4. List of some useful AT commands : http://www.pridopia.co.uk/pi-doc/ESP8266ATCommandsSet.pdf

 

Notes

  • After flashing the default baud rate becomes 115200. And also the CWMODE might need to be changed to 1 or 3 manually (mine somehow went to mode 2 that is AP mode)
  • If the RTOS firmware is flashed then the “user1.1024.new.2.bin” file inside the AT directory cannot be flashed – it makes the chip non-responsive.
  • The required files for RTOS firmware comes in the zip file named “AT_V0.60_on_ESP8266_NONOS_SDK_V1.5.2_20160203” and is inside “noboot” folder.

 

Updated version of this here: https://www.kolkataonweb.com/code-bank/arduino/esp-01-burning-at-rom-new-and-updated/