After finding fvollmers project, it was possible to create this firmware. Thanks for the inspiration and the helpful details like GPIOs and pinouts.
The initial upload requires the following steps:
GNDis also required for programming, but depending on your programming cable this signal is easily accessible even when the PCB is put back in place. Soldering to the ESP8266 module will result in fragile connections. Because of that, I decided to provide cable support afterwards by applying hot-melt-glue, otherwise the connections would not last long when handled. A labeled picture certainly helps.
Tx. If you want to check correct wiring, power up the lamp and use the serial-monitor for any activity. Most likely it will just print gibberish due to mismatched baudrate, but this is enough to see
Txshould be wired correctly; if there is no activity when powering the lamp try swapping the
Once the firmware has uploaded initially, you can reupload through WiFi using the BASH script (assuming the desk-lamp got the IP adress 192.168.2.99):
# ./flash.sh 192.168.2.99
The stdout-messages should look as follows:
./flash.sh 192.168.2.99 enableUpdates: 1 <META http-equiv="refresh" content="15;URL=/">Update Success! Rebooting...
To monitor the log messages, use the
log.sh BASH script. It refreshes the log messages every second.
The internal webserver serves files from device-internal-flash-filesystem. To fill the internal flash-filesystem, the most convenient way is creating a subfolder
data in the sketch-folder and upload with the provided BASH-file
Uploading all files from
./data to flash-filesystem:
Upload a single file file to flash-filesystem:
./upload_files.sh 192.168.2.99 myfile
To send commands to the desk lamp or read the state, the following HTTP-handlers are implemented:
update). To prevent unauthorized flashing of (malicious) firmware or webserver files at least a hardcoded password is required. If you worry about this password change it in the sourcedode and notice that HTTP does not encrypt it.