Introduction: ESP8266 Temperature Logger With Email Alarm
In this tutorial we will show how to build ESP8266 DS18B20 temperature logger with Email alarm notification. We will connect it to EasyIoT Cloud. Sensor is Plug and Play - no configuration is needed to add sensor to the EasyIoT Cloud.
Step 1: Materials
1. ESP8266 WiFi module
2. DS18B20 temperature sensor
3. 4.7K resistor
4. 3.3V power supply or 2 AA batteries
Step 2: Hardware
Connection diagram is shown below. Instead of ESP8266-01 you can use different type of ESP8266. Also you can use 3.3V power supply instead (AMS1117-3.3) of 2 AA batteries.
Step 3: Program
Program is written in Arduino ESP8266 IDE. See Arduino ESP8266 IDE tutorial how to connect ESP8266 module to computer. If you are not experienced it's recommended to use ESP8266 Node MCU board - just connect it to computer USB port.
Download program from our GitHub. Also download EIoTCloudRestApiV1.0 library and add it to your library folder in Arduino IDE. In program you need to change only three lines: set access point name, access point password and your instance ID. To get instance ID you need to register to EasyIoT Cloud service. Instance Id can be found under Configure->User Info->Instance Id.
// change those lines
#define AP_USERNAME "xxxx"
#define AP_PASSWORD "xxxx"
#define INSTANCE_ID "xxxx"
Step 4: Setting Email Alarm Notification
To use temperature sensor you do not need to configure anything, because sensor is Plug and Play. If you want to set temperature email alarm configure following automation program. Go to Configure->Automation and press Add automation button.
In automation program configure following: Enable program, select program type "Condition". In If condition select your newly added sensor module and Sensor.Parameter1 and set condition to ">= rising edge". Rising edge means that you will be notified only once when temperature raise at certain value. In condition value select "Fixed value" and set fixed value (in our case fixed value is 27). Then set action "Send email" and set email address and message. If you want to see value in message use {value}. At least save program with button save.
In this example if sensor for 9 - room temperature sends temperature equal or greater than 27 we will be notified once (on rising edge) to email address with message.