CO Detector Hack – Part 5

CO Detector Hack – Part 5

In this post I’ll be covering the programing of the ESP8266 with the Arduino IDE

The first step is to download and install the Arduino IDE, go to https://www.arduino.cc/en/Main/Software. It is at version 1.8.5 as of this writing. Refer to the online guide for install steps, https://www.arduino.cc/en/Guide/HomePage.

Once installed, you’ll need to be sure that your have the needed rights to run and upload sketches. On Linux systems, your user account will need to be a member of the dialout group. The program can be ran and next you will need to add device support for the ESP8266.

Follow these steps to install support for the ESP8266 board in the Arduino IDE. Open the preferences window in the Arduino IDE, then go to File > Preferences. Enter in http://arduino.esp8266.com/stable/package_esp8266com_index.json at the “Additional Board Manager URLs” field, click “OK” when done. Next, go to Tools > Board … > Boards Manager, scroll down until you see an entry for ESP8266, click it then press the Install button once it appears.

I like to close and reopen the IDE to be sure all the added features take. Now is a good time to test and verify that sketches install on a regular UNO. Select an example sketch, I use Blinky and make changes to the blink rate just to be sure it took. First I’ll be sure my board is selected, next I’ll verify my communication port. My initial upload failed due to permissions. Running this command verified what I suspected.

sudo chmod 666 /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 Mar 8 03:40 /dev/ttyACM0
sudo chmod 666 /dev/ttyACM0
crw-rw-rw- 1 root dialout 166, 0 Mar 8 03:40 /dev/ttyACM0

Again, I closed and reopened the IDE then repeated my initial test upload with my UNO. This time it worked. While I’m in the IDE, I’ll verify that my ESP8266 board is listed in the boards available. It is listed as Generic ESP8266. Now on to connecting the ESP8266 to the IDE. One thing to note is that the ESP8266 uses a voltage of 3.3 vdc and supplying 5 vdc to it is likely to result in a hardware malfunction. I’m using Sparkfuns FTDI Basic that is pre set to 3.3 vdc via a pad connection. Here is the wiring I used to connect the FTDI Basic with the ESP8266.

With everything connected, I loaded the WiFiScan sketch from the IDE examples. Then I verify that my port is set correctly and the board is set to the ESP8266 module. I then uploaded the sketch when all was set. The FTDI Basic has indicator LEDs that are useful to know when activity is occurring. Now with the sketch loaded, I change my wiring so I can monitor the serial data the ESP8266 is generating from its loaded sketch.

I prefer to run Putty and monitor the serial communications that way, mainly because it lets me log the readings. If you’re following along, you should see the ESP8266 display local wireless networks it detects and a few details about those networks on the terminal screen.

The purpose of the ESP8266 is provide link between CO Detector and a mobile device. Now we have all the parts to start programing the ESP8266 for this use.

Comments are closed.