A network connected thermometer implemented with ESP8266 and DHT22.
SmarTherm uses a single common anode (+) RGB LED to visually signal various events and states of the device:
SmarTherm not only collects data, but forwards them to cloud services.
Blynk is a platform with iOS and Androids apps to control and query IoT devices over the Internet. It is a digital dashboard where you can build a graphic interface for your project by simply dragging and dropping widgets.
An example dashboard for Smartherm may look like this:
To set up Blynk follow these steps:
BLYNK_AUTH_TOKEN
parameter in config.h
.V16
virtual pin.V17
virtual pin.In case of any problem connect your device to a serial port monitor and check the logs. For normal operation you should see the following in the log in every measurement cycle:
Sending data to Blynk...DONE.
This error is written to the log if the Blynk service rejects your auth token. It can happen if you made a typo, or (and this is interesting) also if you copy-pasted the token from the e-mail. I recommend deleting and manually typing back the first and the last few characters, including the opening and closing quotation marks. (I know it sounds crazy, but worked for me and others also.)
SmarTherm is capable of sending notifications about the following events:
Events are sent to the free IFTTT Maker service webhooks in a HTTP POST request. The request has the following parameters:
IFTTT_WEBHOOK_EVENT_NAME
variable in config.h
.IFTTT_WEBHOOK_API_KEY
variable in config.h
.value1
parameter contains a title-like short summary of the event (e.g. "Starting").value2
parameter contains the detailed description of the event.value3
parameter contains information about the device (name, version, IP and MAC addresses).IFTTT allows you to forward these events to your e-mail mailbox, to your phone, to trigger an action - almost anything you want, it is totally up to you.
The following configuration shows how to forward the events sent by SmarTherm to your Gmail inbox:
Webhooks
as the source ("this").Receive a web request
.IFTTT_WEBHOOK_EVENT_NAME
value in config.h
, for example SmarTherm
, and click the "Create Trigger" button.Gmail
as the target ("that").Send an email
.[SmarTherm] {{Value1}}
{{Value2}}<br>
<br>
Device: {{Value3}}<br>
<br>
When: {{OccurredAt}}
To get your API key, navigate to the https://ifttt.com/maker_webhooks page and click the "Documentation" link on the top. Copy the API key from that page and paste it into the IFTTT_WEBHOOK_API_KEY
variable in config.h
.
ESP8266 supports over the air updates out of the box, so you can load the firmware to the ESP using Wi-Fi connection rather than a serial port.
Make sure you read the Security disclaimer and other security related sections in the official documentation to understand the risks!
config.h
:
OTA_UPDATE_HOSTNAME
parameter defines the name for your device as it should appear during the update, for example in the Arduino IDE.OTA_UPDATE_PASSWORD
parameter defines a secret that is requested by the device to allow loading a new firmware. Make sure you set a strong password! If it is set to NULL
, then anyone can modify the code on your device who has access to your wireless network. Note: Visual Studio Code does not support OTA with password yet.config.h
and the IP address of your device).config.h
, because you did set one, right?Visual Studio Code has limited support for OTA updates:
It does not support passwords for OTA, so you have two options:
NULL
in config.h
, and use VS Code for your pleasure. Make sure that in this way you add just another insecure IoT device into the existing world of insecure IoT devices.VS Code is not able to discover devices on your network, so you can't conveniently select the IP address in the Port menu. To resolve this, you have to manually replace the serial port with the IP address of your device in arduino.json
. For example:
{
...
"port": "192.168.0.107",
...
}
You may receive the following error after starting an OTA update:
Start updating sketch
Connect Failed
Error[2]: Connect Failed
Error[4]: End Failed
ERROR[0]: No Error
Or the following error:
Uploading...
[ERROR]: No response from device
An error occurred while uploading the sketch
During OTA update your ESP device tries to connect to your computer to download the new code. To enable this make sure that you have a hole in your firewall, and your antivirus software (e.g. ESET) does not block this kind of requests.
You may receive the following error after starting as OTA update, even if you have selected to add python.exe to the Path during installation on Windows:
Cannot run program "python.exe": CreateProcess error=2, The system cannot find the file specified
This error may come in VS Code even if OTA upload works successfully in Arduino IDE.
The solution is to edit platform.txt
in the C:\Users\<YOURNAME>\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.2
folder, and set the full path to python.exe
:
tools.esptool.network_cmd.windows=C:/Python27/python.exe
During upload your ESP device will send debug log messages through the serial port. So if OTA does not work, connect your device to your computer, start a serial monitoring tool (e.g. Termite), and start the OTA update through the wireless network.
You can customize the messages in the ota-updater.cpp
file.
This project is maintained by György Balássy.