Hi,
I am trying to figure out a few old ESP8266 ESP-01s I have lying around. I have a few very simple projects in mind, using Arduino and Wifi.
But I have trouble uploading the most basic scripts, can someone help point out what I am doing wrong? Or point out if I'm completely misunderstanding how it works.
Here we go.
My setup is ESP8266 connected through a serial connecter (5v) passing through a bi-directional level switch. The ESP8266 is powered by a 3.3v external source, the serial connecter uses USB power. Communication works fine.
I am flashing ESP8266 with the nodemcu-1.5.4.1 version.
Successfully.
~/esptool$ python3 esptool.py --port /dev/ttyUSB0 write_flash -fm qio 0x00000 nodemcu-1.5.4.1-final-7-modules-2023-03-24-02-15-55-float.bin
esptool.py v4.6-dev
Serial port /dev/ttyUSB0
Connecting...................
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 5c:cf:7f:fd:cc:9d
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00062fff...
Compressed 404580 bytes to 258713...
Wrote 404580 bytes (258713 compressed) at 0x00000000 in 23.2 seconds (effective 139.8 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
Checking the firmware version with ESPlorer. Looks good. I can even run basic commands and send LUA scripts.
NodeMCU custom build by frightanic.com
branch: 1.5.4.1-final
commit: 9ad37255717e02120f43f213a892a845dbe40615
SSL: false
modules: file,gpio,net,node,tmr,uart,wifi
build created on 2023-03-24 02:15
powered by Lua 5.1.4 on SDK 1.5.4.1(39cb9a32)
lua: cannot open init.lua
But I want to integrate it in an Arduino project, so I want to use Arduino IDE to program it.
So I start with the simplest script:
void setup() {
Serial.begin(115200); // initialize serial communication
}
void loop() {
Serial.println("Hello, world!"); // print "Hello, world!" to the serial port
delay(1000); // wait for 1 second
}
And upload it with Arduino IDE:
. Variables and constants in RAM (global, static), used 28108 / 80192 bytes (35%)
║ SEGMENT BYTES DESCRIPTION
╠══ DATA 1496 initialized variables
╠══ RODATA 940 constants
╚══ BSS 25672 zeroed variables
. Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 59747 / 65536 bytes (91%)
║ SEGMENT BYTES DESCRIPTION
╠══ ICACHE 32768 reserved space for flash instruction cache
╚══ IRAM 26979 code in IRAM
. Code in flash (default, ICACHE_FLASH_ATTR), used 236132 / 1048576 bytes (22%)
║ SEGMENT BYTES DESCRIPTION
╚══ IROM 236132 code in flash
esptool.py v3.0
Serial port /dev/ttyUSB0
Connecting........_
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 5c:cf:7f:fd:cc:9d
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 1MB
Compressed 269696 bytes to 198407...
Writing at 0x00000000... (7 %)
Writing at 0x00004000... (15 %)
Writing at 0x00008000... (23 %)
Writing at 0x0000c000... (30 %)
Writing at 0x00010000... (38 %)
Writing at 0x00014000... (46 %)
Writing at 0x00018000... (53 %)
Writing at 0x0001c000... (61 %)
Writing at 0x00020000... (69 %)
Writing at 0x00024000... (76 %)
Writing at 0x00028000... (84 %)
Writing at 0x0002c000... (92 %)
Writing at 0x00030000... (100 %)
Wrote 269696 bytes (198407 compressed) at 0x00000000 in 17.6 seconds (effective 122.3 kbit/s)...
Hash of data verified.
ESPLorer result:
Communication with MCU...
Got answer! Communication with MCU established.
AutoDetect firmware...
Can't autodetect firmware, because proper answer not received (may be unknown firmware).
Please, reset module or continue.
<Somegibberish>
Hello, world!
Hello, world!
Hello, world!
The script works, but my firmware is gone.
Any idea what is going on?
Am I misunderstanding how this should work, and should stick to LUA scripts instead?
This is what my Arduino board looks like: