I would like to introduce ESPEasy firmware. So far every sensor and communication was done by using Arduino and coding communication with ESP8266 to have MQTT implementation and integration with OpenHAB instance. Now everything has changed. ESPEasy firmware has Web interface for configuration, auto detection addresses of sensors connected to the almost any ESP8266 type of board. List of supported sensors is also quite impressive.
I will use ESP-01 with DS18B20 which will be used as WiFi temperature sensor. As you may see between VCC and GPIO1 we require resistor 4.7k
Download firmware as binary including flash tool
ESPEasy repository is here: https://github.com/letscontrolit/ESPEasy/releases
Download the latest version and unzip to the folder. Please download also esptool.py as described in http://iot.formatx.net/esp8266-flashing/.
Flashing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
greg-lap /home/greg/sonoff # ./esptool-2.7/esptool.py --port /dev/ttyUSB0 write_flash -fs 1MB -fm dout 0x0 bin/ESP_Easy_mega-20190903_normal_core_241_ESP8266_1M.bin esptool.py v2.7 Serial port /dev/ttyUSB0 Connecting.... Detecting chip type... ESP8266 Chip is ESP8266EX Features: WiFi Crystal is 26MHz MAC: 5c:cf:7f:14:1a:14 Uploading stub... Running stub... Stub running... Configuring flash size... Compressed 837376 bytes to 542653... Wrote 837376 bytes (542653 compressed) at 0x00000000 in 48.1 seconds (effective 139.4 kbit/s)... Hash of data verified. Leaving... Hard resetting via RTS pin... |
Initial setup
Restart ESP. Now search again for available wifi networks. New WiFi AP “ESP_Easy_0” will appear, password: configesp
If you’re not automatically taken to the log-in page, browse to 192.168.4.1
Search for you routers WiFi and connect
Now device will restart and you will see screen with IP details. Take note IP and and connect back to your normal WiFi AP.
After connection to Web Interface first we configure Controllers (MQTT + OpenHAB)
1. Download firmware as binary including flash tool
↓
2. Connect the ESP to Windows PC
Using either USB/UART of board or separate USB/TTL adapter
↓
3. Write firmware using flash tool
Note necessity for GPIO to be LOW to enter flashmode
↓
4. Restart ESP. WiFi AP “ESP_Easy_0” will appear, password: configesp
(prior to 2.0 the AP was named ESP_0)
If you’re not automatically taken to the log-in page, browse to 192.168.4.1
↓
5. Search for you routers WiFi and connect
(if you have multiple AP they will all show up with the same SSID name multiple times)
↓
6. Reconnect to your WiFi and enter IP adress shown on previous screen
adding details
Click on Devices and now add right type of device. In our case DS18b20
Now let’s configure our temperature sensor. Go to Devices and select GPIO2 and set Name. After submitting ESPEasy automatically scan connected devices and should put and address.
If everything went good, you should be able to see sensor value.
The same is sent to defined MQTT server:
1 2 3 4 |
iot@sabayon ~ $ /usr/local/bin/mosquitto_sub -v -h localhost -p 1883 -t '#' ESP_Easy/status/LWT Connected ESP_Easy/temp-sensor/Temperature 22.05 ESP_Easy/temp-sensor/Temperature 22.05 |
If for some reason Values are not accurate you may consider to correct them by adding some arithmetic: