I'm using a headless raspberry pi as my programmer as my laptop is rather locked down. I'm not familiar with the espota.py
, but this process below works fully from the command line to compile and upload .ino code. The arduino-cli
is pretty full featured and I've had success on it with Adafruit's Huzzah (using an FTDI cable) and the Wemos D1 Mini (direct USB)
The first thing to do is add esp8266 boards. I'm not exactly sure how I did this, but you can see which additional boards are available with the config dump
command:
pi@dogwood:~/sketchbook $ arduino-cli config dump
proxy_type: auto
sketchbook_path: /home/pi/Arduino
arduino_data: /home/pi/.arduino15
So I crack open the /home/pi/.arduino15/
directory and there is a arduino-cli.yaml
file. In there, I add the ESP8266 package, making the arduino-cli.yaml
look like this:
pi@dogwood:~/sketchbook $ cat /home/pi/.arduino15/arduino-cli.yaml
proxy_type: auto
sketchbook_path: /home/pi/Arduino
arduino_data: /home/pi/.arduino15
board_manager:
additional_urls:
- http://arduino.esp8266.com/stable/package_esp8266com_index.json
(I fought with this a couple times, so that may not be 100% but the config dump
should reflect what data directory it uses and in there should be a .yaml file with the additional_urls)
Without the D1 plugged in, run this to see what ports are listed:
arduino-cli board list
Then plug in the D1 and the output should be something like:
Port Type Board Name FQBN Core
/dev/ttyAMA0 Serial Port Unknown
/dev/ttyUSB0 Serial Port (USB) Unknown
For both the Huzzah and the D1 I get that Board Name unknown, but they are both ESP8266 boards. The board listall
command will show all the boards and their FQBN, which you'll need for compiling and uploading:
pi@dogwood:~/sketchbook $ arduino-cli board listall
Board Name FQBN
4D Systems gen4 IoD Range esp8266:esp8266:gen4iod
Adafruit Circuit Playground arduino:avr:circuitplay32u4cat
Adafruit Feather HUZZAH ESP8266 esp8266:esp8266:huzzah
....snip.....
LOLIN(WEMOS) D1 R2 & mini esp8266:esp8266:d1_mini
LOLIN(WEMOS) D1 mini Lite esp8266:esp8266:d1_mini_lite
LOLIN(WEMOS) D1 mini Pro esp8266:esp8266:d1_mini_pro
WeMos D1 R1 esp8266:esp8266:d1
From there, I copy the FQBN.
Then (or before maybe), I create a new sketch:
pi@dogwood:~/sketchbook $ arduino-cli sketch new MyFirstSketch
Sketch created in: /home/pi/sketchbook/MyFirstSketch
Then edit the .ino file and complile:
pi@dogwood:~/sketchbook $ vim ./MyFirstSketch/MyFirstSketch.ino
pi@dogwood:~/sketchbook $
pi@dogwood:~/sketchbook $ SKETCH=MyFirstSketch
pi@dogwood:~/sketchbook $ arduino-cli compile --fqbn esp8266:esp8266:d1_mini $SKETCH
Sketch uses 257680 bytes (24%) of program storage space. Maximum is 1044464 bytes.
Global variables use 26572 bytes (32%) of dynamic memory, leaving 55348 bytes for local variables. Maximum is 81920 bytes.
pi@dogwood:~/sketchbook $
Then upload:
pi@dogwood:~/sketchbook $ arduino-cli upload -p /dev/ttyUSB0 --fqbn esp8266:esp8266:d1_mini $SKETCH
No new serial port detected.
esptool.py v2.6
2.6
esptool.py v2.6
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP8266EX
Features: WiFi
MAC: ec:fa:bc:61:0e:31
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 261840 bytes to 191242...
Wrote 261840 bytes (191242 compressed) at 0x00000000 in 7.4 seconds (effective 282.8 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
I had to reset the Huzzah after uploading, but the D1 mini did fine after the upload and correctly ran my code.
To get the serial monitor use something like screen
like so:
screen /dev/ttyUSB0 115200