Example Code for Arduino-Temperature Sending (Based on IFTTT)
This tutorial guides you through setting up the Arduino UNO, WiFi IoT module, and LM35 sensor to send real-time temperature alerts via email using IFTTT.
Hardware Preparation
- Arduino UNO board x1
- IO Expansion board x1
- WiFi IoT module x1
- LM35 Temperature Sensor x1
- Digital Push Button x1
- Wires
Software Preparation
- Arduino IDE
- Download and install the WiFi IoT Module Library. (About how to install the library?)
Wiring Diagram

Sample Code
#include "DFRobot_WiFi_IoT_Module.h"
#include <SoftwareSerial.h>
int button = 7;
//UART mode
//Use software serialport: D/R: 10, C/T: 11
SoftwareSerial mySerial(10, 11);
DFRobot_WiFi_IoT_Module_UART IoT(&mySerial);
//Configure WiFi name and password
const char *WIFI_SSID = "hitest";
const char *WIFI_PASSWORD = "12345678";
//Configure IFTTT
const char *IFTTT_ADDRESS = "maker.ifttt.com";
const char *IFTTT_ENVENT = "Temperature";
const char *IFTTT_KEY = "cdvP-sL1L9m3eld_T0xR3r";
//IFTTT Send message
const char *IFTTT_VALUE_1 = "Value1";
const char *IFTTT_VALUE_2 = "Value2";
const char *IFTTT_VALUE_3 = "Value3";
/********************************************************************************************
Function : getTemp
Description : Get temperature detected by LM35
Params :
Return : Converted temperature value
********************************************************************************************/
float getTemp()
{
uint16_t val;
float dat;
val = analogRead(A0);
dat = (float)val * (5/10.24);
return dat;
}
void setup() {
//Use software serialport 9600 as communication port
mySerial.begin(9600);
//Use serialport 115200 as print port
Serial.begin(115200);
//Init communication port
while(IoT.begin() != 0){
Serial.println("init ERROR!!!!");
delay(100);
}
Serial.println("init Success");
//Connect to WiFi
while(IoT.connectWifi(WIFI_SSID, WIFI_PASSWORD) != 0){
Serial.print(".");
delay(100);
}
Serial.println("Wifi Connect Success");
//Init HTTP
while(IoT.HTTPBegin(IFTTT_ADDRESS) != 0){
Serial.println("Parameter is empty!");
delay(100);
}
Serial.println("HTTP Configuration Succeeded");
//Init IFTTT
while(IoT.IFTTTBegin(IFTTT_ENVENT, IFTTT_KEY) != 0){
Serial.println("Parameter is empty!");
delay(100);
}
Serial.println("IFTTT Configuration Succeeded");
pinMode(button,INPUT);
}
void loop() {
String data =(String)getTemp();
//Press down button to send an Email recording the current temperature
if(digitalRead(7) == 1)
{
IoT.IFTTTSendMessage("reminder","The current temperature is",data.c_str());
Serial.println("send message success!");
}
}
Result
Press down the button, IFTTT sends an Email recording the current temperature to the corresponding mail box.

Was this article helpful?
