Com reprogramar el ESP8266EX (ESP01S) (P25Q80H) satisfactòriament

ESP01S (ESP8266EX 1MB)
PinOut
Direccionament de memòria de la flash

Recursos per trobar els SDK d’aquest mòdul a: https://www.espressif.com/en/support/download/sdks-demos?keys=&field_type_tid%5B%5D=14

El SDK que finalment estic utilitzant és: https://github.com/espressif/ESP8266_NONOS_SDK/releases/tag/v2.2.1

Fitxer: ESP8266_AT_Bin_V1.6.2_0.zip

echo "Versió: ESP8266_AT_Bin_V1.5.1" 
esptool.py --port /dev/ttyUSB0 erase_flash 
echo "Fes un reset amb GPIO0+GND quan estigui a punt prem enter" 
read 
esptool.py --baud 460800 --port /dev/ttyUSB0 write_flash -fm qio -ff 40m -fs detect \ 
0x00000 boot_v1.7.bin \ 
0x01000 at/512+512/user1.1024.new.2.bin \ 0xFC000 esp_init_data_default.bin \ 
0xFE000 blank.bin
linux# screen /dev/ttyUSB0 115200 

AT+RST 
OK  
ets Jan  8 2013,rst cause:2, boot mode:(3,6) 
load 0x40100000, len 2592, room 16 
tail 0 chksum 0xf3 
load 0x3ffe8000, len 764, room 8 tail 4 chksum 0x92 
load 0x3ffe82fc, len 676, room 4 tail 0 chksum 0x22 
csum 0x22 2nd boot version : 1.7(5d6f877) 
SPI Speed : 40MHz 
SPI Mode : QIO 
SPI Flash Size & Map: 8Mbit(512KB+512KB) 
jump to run user1 @ 1000 ����o�;��g|��d�prlc��|s�d�g��g�ld`��r�$�d��l`��s�l�l�l`��{�dǟ�l$`rlǃ
;$ğ�#Č#x|c��b�|�$c��g���dp����l�lČ����l�o�ğ�#dl��c���b$�c;l{l 
ready 
AT+GMR 
AT version:1.5.0.0(Oct 24 2017 12:03:18) 
SDK version:2.1.0(ace2d95) compile time:Oct 24 2017 15:48:02 
Bin version(Wroom 02):1.5.1 
OK 

Molt important. Baudrate a 115200. A no ser que específicament digui el firmware que va a 9600. Després les comandes AT s’han de fer en MAJÚSCULES premem el ENTER i després el CTRL-J si es fa des d’un “screen”

Perquè funcioni de forma autònoma el VCC i el CH_PD han d’anar a 3.3V

Variants que m’han funcionat també

echo "Versió: ESP8266_AT_Bin_V1.5.1" 
esptool.py --port /dev/ttyUSB0 erase_flash 
echo "Fes un reset amb GPIO0+GND quan estigui a punt prem enter" 
read 
esptool.py --baud 460800 --port /dev/ttyUSB0 write_flash -fm qio -ff 40m -fs detect \ 
0x00000 boot_v1.7.bin \ 
0x01000 at/512+512/user1.1024.new.2.bin \ 
0x81000 at/512+512/user2.1024.new.2.bin \ 
0xFC000 esp_init_data_default.bin \ 
0xFE000 blank.bin 
esptool.py v2.6-beta1 Serial port /dev/ttyUSB0 
Connecting.... 
Detecting chip type... ESP8266 
Chip is ESP8266EX 
Features: WiFi 
MAC: 84:f3:eb:31:b2:7f 
Uploading stub... 
Running stub... 
Stub running... 
Erasing flash (this may take a while)... 
Chip erase completed successfully in 0.0s 
Hard resetting via RTS pin... 
Fes un reset amb GPIO+GND quan estigui a punt prem enter 
esptool.py v2.6-beta1 Serial port /dev/ttyUSB0 
Connecting.... 
Detecting chip type... ESP8266 
Chip is ESP8266EX 
Features: WiFi 
MAC: 84:f3:eb:31:b2:7f 
Uploading stub... 
Running stub... 
Stub running... 
Changing baud rate to 460800 Changed. 
Configuring flash size... 
Auto-detected Flash size: 1MB 
Flash params set to 0x0020 
Compressed 4080 bytes to 2936... 
Wrote 4080 bytes (2936 compressed) at 0x00000000 in 0.1 seconds (effective 472.5 kbit/s)... 
Hash of data verified. 
Compressed 408388 bytes to 293527... 
Wrote 408388 bytes (293527 compressed) at 0x00001000 in 23.1 seconds (effective 141.7 kbit/s)... 
Hash of data verified. 
Compressed 408388 bytes to 293525... 
Wrote 408388 bytes (293525 compressed) at 0x00081000 in 23.0 seconds (effective 142.1 kbit/s)... 
Hash of data verified. 
Compressed 128 bytes to 75... 
Wrote 128 bytes (75 compressed) at 0x000fc000 in 0.0 seconds (effective 174.2 kbit/s)... 
Hash of data verified. 
Compressed 4096 bytes to 26... 
Wrote 4096 bytes (26 compressed) at 0x000fe000 in 0.0 seconds (effective 6681.8 kbit/s)... 
Hash of data verified. 
Leaving... 
Hard resetting via RTS pin... 
### Flash size 8Mbit: 512KB+512KB
#    boot_v1.2+.bin              0x00000 
#    user1.1024.new.2.bin        0x01000 
#    esp_init_data_default.bin   0xfc000 (optional) 
#    blank.bin                   0x7e000 & 0xfe000 

echo "Versió: ESP8266_AT_Bin_V1.6.2" 
esptool.py --port /dev/ttyUSB0 erase_flash 
echo "Fes un reset amb GPIO0+GND quan estigui a punt prem enter" 
read 
esptool.py --baud 460800 --port /dev/ttyUSB0 write_flash -fm qio -ff 40m -fs detect \ 
0x00000 boot_v1.7.bin \ 0x01000 at/512+512/user1.1024.new.2.bin \ 
0x81000 at/512+512/user2.1024.new.2.bin \ 
0xFC000 esp_init_data_default_v08.bin \ 
0xFE000 blank.bin 
AT+RST 
OK  
ets Jan  8 2013,rst cause:2, boot mode:(3,6) 
load 0x40100000, len 2592, room 16 tail 0 chksum 0xf3 
load 0x3ffe8000, len 764, room 8 tail 4 chksum 0x92 
load 0x3ffe82fc, len 676, room 4 tail 0 chksum 0x22 csum 0x22 2nd boot version : 1.7(5d6f877) 
SPI Speed : 40MHz 
SPI Mode : QIO 
SPI Flash Size & Map: 8Mbit(512KB+512KB) 
jump to run user1 @ 1000 
����g�s��n<��l�8{$b��|{�l�o��o�dl ��{�d�l��d`��;�$�d�$`��s�l���$l`{l��{l���c��c|$b
�����lb��o��g��l�|쏌$l�l�|�l�$�'����cld쌏c����cd�#{$sd 
ready 

AT+GMR AT version:1.6.2.0(Apr 13 2018 11:10:59) 
SDK version:2.2.1(6ab97e9) compile time:Jun  7 2018 19:34:26 
Bin version(Wroom 02):1.6.2 OK 

Variant amb Flash de 4MB

echo "ESP8266EX 25Q32CS1G" 
esptool.py --port /dev/ttyUSB0 erase_flash 
echo "Fes un reset amb GPIO0+GND quan estigui a punt prem enter" 
read 
esptool.py --baud 460800 --port /dev/ttyUSB0 write_flash -fm dio -ff 40m -fs detect \ 
0x00000 boot_v1.7.bin \ 
0x01000 at/512+512/user1.1024.new.2.bin \ 
0x3FC000 esp_init_data_default_v08.bin \ 
0x3FE000 blank.bin 

esptool.py v2.6-beta1 Serial port /dev/ttyUSB0 
Connecting.... 
Detecting chip type... ESP8266 Chip is ESP8266EX Features: 
WiFi MAC: 84:f3:eb:4c:34:20 
Uploading stub... 
Running stub... 
Stub running... 
Changing baud rate to 460800 Changed. 
Configuring flash size... 
Auto-detected Flash size: 4MB 
Flash params set to 0x0240 Compressed 4080 bytes to 2936... 
Wrote 4080 bytes (2936 compressed) at 0x00000000 in 0.1 seconds (effective 471.5 kbit/s)... 
Hash of data verified. 
Compressed 408388 bytes to 293527... 
Wrote 408388 bytes (293527 compressed) at 0x00001000 in 6.7 seconds (effective 487.3 kbit/s)... 
Hash of data verified. 
Compressed 128 bytes to 75... 
Wrote 128 bytes (75 compressed) at 0x003fc000 in 0.0 seconds (effective 170.2 kbit/s)... 
Hash of data verified. 
Compressed 4096 bytes to 26... 
Wrote 4096 bytes (26 compressed) at 0x003fe000 in 0.0 seconds (effective 6675.0 kbit/s)... 
Hash of data verified. 

linux# screen /dev/ttyUSB0 
AT+RST OK  
ets Jan  8 2013,rst cause:2, boot mode:(3,6) 
load 0x40100000, len 2592, room 16 tail 0 chksum 0xf3 
load 0x3ffe8000, len 764, room 8 tail 4 chksum 0x92 
load 0x3ffe82fc, len 676, room 4 tail 0 chksum 0x22 csum 0x22 2nd boot version : 1.7(5d6f877) 
SPI Speed : 40MHz SPI Mode : DIO 
SPI Flash Size & Map: 32Mbit(512KB+512KB) 
jump to run user1 @ 1000 ����'�{��o<�l$ld`c��|s�d�g��g�ld`��;�$�d��$`��s�l�$�l 
��{�l���ld`{l��{d����c��c|$b�����lb��o�g��l�|��d$�l�|�l�d�g����cll
䌎b���cl�csd;l 
ready 

AT+GMR 
AT version:1.6.2.0(Apr 13 2018 11:10:59) 
SDK version:2.2.1(6ab97e9) compile time:Jun  7 2018 19:34:26 
Bin version(Wroom 02):1.6.2 
OK

Prova de connexió a la xarxa wifi ssidtest com a client:

AT+CWMODE=1 
OK
AT+CWLAP 
+CWLAP:(4,"ssidtest",-63,"68:3a:6b:f5:72:c7",5,6,0,5,4,7,0) 
OK 
AT+CWJAP="ssidtest","PericodelosPalotes" 
WIFI CONNECTED 
WIFI GOT IP 
OK 
AT+CIFSR 
+CIFSR:STAIP,"192.168.1.153" 
+CIFSR:STAMAC,"84:f3:eb:31:b2:7f" 
OK 

Per poder interactuar amb un ARDUINO li hem de canviar la configuració per defecte de 115200 bauds a 9600 mitjançant la comanda AT:

AT+UART_DEF=9600,8,1,0,0

Aquesta configuració queda permanent amb el mòdul.

Un cop cablejat el mòdul a l’Arduino li podem aplicar un sketch d’exemple:

/*
 WiFiEsp example: WebClient

 This sketch connects to google website using an ESP8266 module to
 perform a simple web search.

 For more details see: http://yaab-arduino.blogspot.com/p/wifiesp-example-client.html
*/

#include "WiFiEsp.h"

// Emulate Serial1 on pins 2/3 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(2, 3); // RX, TX
#endif

char ssid[] = "ssidtest";            // your network SSID (name)
char pass[] = "PericodelosPalotes";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status

char server[] = "arduino.cc";

// Initialize the Ethernet client object
WiFiEspClient client;

void setup()
{
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial1.begin(9600);
  // initialize ESP module
  WiFi.init(&Serial1);

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  // you're connected now, so print out the data
  Serial.println("You're connected to the network");
  
  printWifiStatus();

  Serial.println();
  Serial.println("Starting connection to server...");
  // if you get a connection, report back via serial
  if (client.connect(server, 80)) {
    Serial.println("Connected to server");
    // Make a HTTP request
    client.println("GET /asciilogo.txt HTTP/1.1");
    client.println("Host: arduino.cc");
    client.println("Connection: close");
    client.println();
  }
}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client
  if (!client.connected()) {
    Serial.println();
    Serial.println("Disconnecting from server...");
    client.stop();

    // do nothing forevermore
    while (true);
  }
}


void printWifiStatus()
{
  // print the SSID of the network you're attached to
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength
  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

Si tot va bé ens hauria de donar un sortida semblant a aquesta:

[WiFiEsp] Initializing ESP module
[WiFiEsp] Initilization successful - 2.2.1
Attempting to connect to WPA SSID: ssidtest
[WiFiEsp] Connected to ssidtest
You're connected to the network
SSID: ssidtest
IP Address: 192.168.0.150
Signal strength (RSSI):-582 dBm

Starting connection to server...
[WiFiEsp] Connecting to arduino.cc
Connected to server
HTTP/1.1 200 OK
Server: nginx/1.4.2
Date: Wed, 31 Oct 2018 20:14:12 GMT
Content-Type: text/plain
Content-Length: 2263
Last-Modified: Wed, 02 Oct 2013 13:46:47 GMT
Connection: close
Vary: Accept-Encoding
ETag: "524c23c7-8d7"
Accept-Ranges: bytes


           `:;;;,`                      .:;;:.           
        .;;;;;;;;;;;`                :;;;;;;;;;;:     TM 
      `;;;;;;;;;;;;;;;`            :;;;;;;;;;;;;;;;      
     :;;;;;;;;;;;;;;;;;;         `;;;;;;;;;;;;;;;;;;     
    ;;;;;;;;;;;;;;;;;;;;;       .;;;;;;;;;;;;;;;;;;;;    
   ;;;;;;;;:`   `;;;;;;;;;     ,;;;;;;;;.`   .;;;;;;;;   
  .;;;;;;,         :;;;;;;;   .;;;;;;;          ;;;;;;;  
  ;;;;;;             ;;;;;;;  ;;;;;;,            ;;;;;;. 
 ,;;;;;               ;;;;;;.;;;;;;`              ;;;;;; 
 ;;;;;.                ;;;;;;;;;;;`      ```       ;;;;;`
 ;;;;;                  ;;;;;;;;;,       ;;;       .;;;;;
`;;;;:                  `;;;;;;;;        ;;;        ;;;;;
,;;;;`    `,,,,,,,,      ;;;;;;;      .,,;;;,,,     ;;;;;
:;;;;`    .;;;;;;;;       ;;;;;,      :;;;;;;;;     ;;;;;
:;;;;`    .;;;;;;;;      `;;;;;;      :;;;;;;;;     ;;;;;
.;;;;.                   ;;;;;;;.        ;;;        ;;;;;
 ;;;;;                  ;;;;;;;;;        ;;;        ;;;;;
 ;;;;;                 .;;;;;;;;;;       ;;;       ;;;;;,
 ;;;;;;               `;;;;;;;;;;;;                ;;;;; 
 `;;;;;,             .;;;;;; ;;;;;;;              ;;;;;; 
  ;;;;;;:           :;;;;;;.  ;;;;;;;            ;;;;;;  
   ;;;;;;;`       .;;;;;;;,    ;;;;;;;;        ;;;;;;;:  
    ;;;;;;;;;:,:;;;;;;;;;:      ;;;;;;;;;;:,;;;;;;;;;;   
    `;;;;;;;;;;;;;;;;;;;.        ;;;;;;;;;;;;;;;;;;;;    
      ;;;;;;;;;;;;;;;;;           :;;;;;;;;;;;;;;;;:     
       ,;;;;;;;;;;;;;,              ;;;;;;;;;;;;;;       
         .;;;;;;;;;`                  ,;;;;;;;;:         
                                                         
                                                         
                                                         
                                                         
    ;;;   ;;;;;`  ;;;;:  .;;  ;; ,;;;;;, ;;. `;,  ;;;;   
    ;;;   ;;:;;;  ;;;;;; .;;  ;; ,;;;;;: ;;; `;, ;;;:;;  
   ,;:;   ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;,`;, ;;  ;;  
   ;; ;:  ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;;`;, ;;  ;;. 
   ;: ;;  ;;;;;:  ;;  ;; .;;  ;;   ,;,   ;;`;;;, ;;  ;;` 
  ,;;;;;  ;;`;;   ;;  ;; .;;  ;;   ,;,   ;; ;;;, ;;  ;;  
  ;;  ,;, ;; .;;  ;;;;;:  ;;;;;: ,;;;;;: ;;  ;;, ;;;;;;  
  ;;   ;; ;;  ;;` ;;;;.   `;;;:  ,;;;;;, ;;  ;;,  ;;;;   

Disconnecting from server...

He provat d’utilitzar el ESP8266 a 115200 bauds amb l’Arduino i no acaba de funcionar correctament. A 9600 bauds sembla que ho fa sense problemes.

print

2 thoughts on “Com reprogramar el ESP8266EX (ESP01S) (P25Q80H) satisfactòriament

  1. Interessant, un gran xip el ESP8266, i el seu hereu ESP32 encara pot ser millor. Merci per la info recollida en aquest treball.

Deixa un comentari

L'adreça electrònica no es publicarà. Els camps necessaris estan marcats amb *

2 × 1 =