When storing electronic components, medications or other environmentally sensitive items, temperature and humidity requirements are often necessary. However, monitoring these parameters manually can be time-consuming and labor-intensive. In this project, we will attempt to create a device that automatically alerts through buzzer when the temperature exceeds a certain threshold.
Additionally, you can view the temperature and humidity on a local LED screen or remotely via the TTN platform. So, it is also a remote temperature and humidity monitor!
Contents of the Tutorial- Basic idea:Overview of the project idea
- Connection:How to connect electronic components
- Add to TTN:How to Upload data to TTN platform
- Application:several examples this device can be used
- Code:Complete example code
The project will be carried out according to the following ideas:
Firstly, data will be collected using temperature and humidity sensors, and the LED display will show the data.
Then, check if the real-time data is greater than or less than the threshold we set, and if it is, the buzzer will sound an alarm.
Meanwhile, the E5 module will send the data to the TTN platform via LoRaWAN so that we can view the data remotely.
As you can see, this project is aimed at enabling local alerts for quick actions and remote monitoring of relevant data.
ConnectionStep 1 Preparation
Hardware:
E5 grove *1;XIAO ESP32S3 module *1;XIAO expansion board *1;Temperature and Humidity sensor *1;Piozer buzzer *1, Grove cable*3, USB-Type C cable*1.
Software:
Download Arduino IDE
Add ESP32 board package to your Arduino IDE
Step 2 Insert the ESP32S3 module into the XIAO expansion board.
note:You need to first install antenna and solder the header pins.refer to this.
Step 3 Connect other components to the XIAO expansion board.
note:Please make sure to connect the pins to the correct ports
Step 4 Connect to PC using USB-Type C cable, upload the code.If success, you can see temperature and humidity data in Serial Monitor.Buzzer will beeps if temperature greater than 30 degree.
Step 5 I have set the threshold values in advance, but you can also modify them according to your own needs in line 200 to 205.
if( temp > 30.00 ) {//Set your threshold values
analogWrite(Buzzer, 20);
delay(1000);
analogWrite(Buzzer, 0);
delay(1000);
}
Add to TTNStep 1 Register a TTN account, and add an application and the device on the TTN platform, refer to this.
In this part you can choose to use the AppEui, DevEui and APPKey in the code or write Eui and Key generated by TTN or pensonally into the device.Modify them in lines 140 to 148.
at_send_check_response("+ID: AppEui", 1000, "AT+ID\r\n");
at_send_check_response("+MODE: LWOTAA", 1000, "AT+MODE=LWOTAA\r\n");//select mode
at_send_check_response("+DR: EU868", 1000, "AT+DR=EU868\r\n");//select frequency band
at_send_check_response("+CH: NUM", 1000, "AT+CH=NUM,0-2\r\n");//select sub band
at_send_check_response("+ID: DevEui", 1000, "AT+ID=DevEui,\"2CF7F1C042900211\"\r\n");//write deveui
at_send_check_response("+ID: AppEui", 1000, "AT+ID=AppEui,\"0128944F83E7AF55\"\r\n");//write AppEui
at_send_check_response("+KEY: APPKEY", 1000, "AT+KEY=APPKEY,\"2B7E151628AED2A6ABF7158809CF4F3C\"\r\n");//write appkey
at_send_check_response("+CLASS: C", 1000, "AT+CLASS=A\r\n");//write device class
at_send_check_response("+PORT: 8", 1000, "AT+PORT=8\r\n");
Step 2 Decode the payload.
Locate End device>Payload fomatters>uplink
, choose Custom Javascript fomatter
Copy and paste this code into fomatter code, apply.You can see data massages in TTN now.
function Decoder(bytes, port) {
var decoded = {};
if (port === 8) {
decoded.temp = bytes[0] <<8 | bytes[1];
decoded.humi = bytes[2] <<8 | bytes[3];
}
return decoded;
}
- Storage of electronic components
- Storage of temperature and humidity sensitive drugs
- Cold chain transportation
- Environmental monitoring in daily life
Comments
Please log in or sign up to comment.