Program an ESP8266 from Arduino on MacOS

There are a lot cheap ESP8266 boards available on the market. The modules are quite powerful and come with WiFi. While this is a problem for ultra-low-power applications (there are tricks to deal with this), it is a great platform for simple sensors or notification applications. You can even program them with the Arduino IDE. This guide shows how to do this.

Install the Arduino IDE

You can download the IDE from the Arduino web site

Connect the ESP8266 module to your computer with an USB cable

Many ESP8266 modules already come with an integrated USB interface. Just connect the module with your Mac.
Note: Some modules have a USB port on the board that can only be used to power the board but isn’t made for communication.

Check that the device is recognised

Open the “About this Mac” dialog and click on “System report”
systemreport

You should now see the a USB2.0 serial device. usbserial

Install the driver

If you now start the Arduino IDE, you can select a device like /dev/cu.usbmodem147741 (the numbers can be different) as the serial interface. However, if you try to communicate with the board, it won’t work. While MacOS recognised that the device is a serial interface, it does not come with the driver for the cheap Chinese CH340G USB/serial converters (in the past some companies used fake FTDI chips until FTDI implemented counter-measurements in their drivers that disabled some fakes). However, installing the driver is not complicated. Download it, and install it. After a reboot, you Arduino IDE should now offer an devices named like /dev/wchusbserial14460. This is the correct serial interface device now.

Install the ESP8266 modules for the Arduino IDE

Arduino does not come with out-of-the-box support for the ESP chip. To install the software, go to the preference dialog and enter
http://arduino.esp8266.com/versions/2.2.0/package_esp8266com_index.json
under “Additional board manager URLs”.

arduino-settings

Now click on “Tools/Board/Board Manager” and install the ESP8266 modules from the “Contributed section”.

espcontrib

That’s it. You have successfully installed all necessary tools to start programming your new IoT device.

If you can’t program your ESP device from the Arduino GUI, have a look at esptool.py. This seems to work better than esptool bundled with Arduino. I did not find a simple way to integrate it directly into Arduino. However, starting it from command line is not very complicated. Just check the command line arguments.