There’s a really handly little development board called ESP8266 which is able to run Arduino code. My current home automation dashboard is pimatic (yes, lowercase p), and a community member from the pimatic forums koffienl created a project called ESPimatic which makes is (relatively) easy to use the ESP8266 board to interact with pimatic. You can connect various sensors, e.g. DHT22, DS18B20, etc. by wires to the ESP8266, which will connect by WiFi to your home router, and send the sensor information wirelessly to pimatic dashboard.
List of software used
- OS: Ubuntu 16.04 LTS
- Arduino IDE 1.6.5 (not older, not newer, this is important!)
First and foremost, read the official installation description of ESPimatic on the ESPimatic wiki, which contains the rough steps for the installation, but I’ve made a bit more detailed guide for those maker fellows who are less experienced in the Arduino world (like myself).
To start with, we need to download the Arduino IDE 1.6.5 from the old releases link to your desktop. Uncompress the archive, then open a terminal. With the folling commands, navigate to the Desktop folder where you have uncompressed the archive, list it’s contents to see if the install.sh script is present, set the install.sh script as executable, and run the install script.
cd ~/Desktop/arduino-1.6.5* ls -lah chmod +x install.sh ./install.sh
This will also create an icon “Arduino IDE” on your desktop.
Now, we’ll install git, which is needed to clone (download) the ESPimatic files from it’s git repository.
sudo apt-get install git -y
Then we clone the ESPimatic repo
git clone https://github.com/koffienl/ESPimatic.git
Now recursively copy the contents of the ESPimatic’s “libraries” folder to the Arduino libraries folder.
cp -ra ./ESPimatic/libraries/* ~/Arduino/libraries/
No start the Arduino IDE 1.6.5 using the link on the Desktop or from the Search “Arduino IDE”.
In the menu go to “Help > About Arduino”, and verify that the version is 1.6.5
We need to import the ESP8266 board manager to the Arduino IDE, for that in the menu go to “File > Preferences” and find the empty line of “Additional Boards manager URLS” and paste in “http://arduino.esp8266.com/stable/package_esp8266com_index.json” and click OK, then exit the Arduino IDE.
Start it again, and go to “Tools > Board > Boards Manager” and type “ESP8266” into the search bar, it will bring up 1 result “esp8266 by ESP8266 Community”, select version “2.0.0” from the dropdown menu and install it.
Then set the board “Tools > Board > Generic ESP8266 Module”
Then load in the .ino Arduino file into the Arduino IDE “File > Open > Browse to ESPimatic folder > load in .ino”
Set the correct settings for the board in Tools > Board, like:
Port is “/dev/ttyUSB0”
Upload Speed is “115200”
Flash Size is “4M (3M SPIFFS)”
That’s it for software.
List of hardware used
- USB to ESP8266 adapter board
- RobotDyn ESP-01 ESP8266 module with WiFi, 8Mb Flash memory
- 2cm of thin electrical wire
The tricky part is, that for the ESP8266 to enter “bootloader mode” which enables uploading/flashing software to it, we need to connect the GPIO00 and GND. This issue is outline in this post, make sure to read the comments too, where different solutions are presented to this problem.
I used a very simple solution: I bent a ~2cm electrical wire in a W shape, and connected the GPIO00 and GND pins on the ESP8266 with it. Then I pushed together the ESP8266 and the USB to ESP8266 adapter board, this way the short wire stays in place too.
Stick the USB to ESP8266 adapter into the PC, with grepping dmesg we’ll check which device got created this way.
dmesg | grep tty
[36164.787169] usb 2-1: ch341-uart converter now attached to ttyUSB0
This all for hardware.
Uploading the ESPimatic to ESP8266
In Arduino IDE “Sketch > Verify/Compile”; and if no errors come up “Sketch > Upload”
It uploads the sketch, and from here on, just follow the official steps on the ESPimatic Wiki installation steps.