Sending LM35 Sensor Data to Consentium IoT Cloud
This documentation outlines the steps and code required to read data from an LM35 temperature sensor using an ADC pin and send the data to the Consentium IoT cloud using the ConsentiumThings library. The code also enables firmware updates for Over-The-Air (OTA).
Dependencies
The code relies on the ConsentiumThings.h
library, facilitating communication with the Consentium IoT platform and enabling OTA updates.
Features
Connect to a WiFi network for cloud communication.
Send sensor data to the Consentium IoT platform.
Enable Over-The-Air (OTA) firmware updates.
Automatically check for updates after every 100 loops.
Constants
Firmware Version: The firmware version of the board is set to
0.1
.Interval: The loop runs every 5 seconds (5000 ms).
Update Interval: The firmware checks for updates every 100 loop cycles.
Code Overview
1. Initialization
The program begins by creating an ConsentiumThingsDalton
object to manage communication with the Consentium IoT platform. The initialization requires the firmware version, WiFi credentials, and Consentium IoT API keys.
The following variables are set for WiFi credentials and API keys:
2. Setup
The setup()
function initializes the WiFi connection, sets up data transmission to the Consentium IoT cloud, and enables OTA updates.
3. Main Loop
The loop()
function reads the temperature data from the LM35 sensor connected to an ADC pin, converts the ADC value to a voltage, and sends the data to the Consentium IoT platform.
a. Reading Data from LM35
The data from the LM35 sensor is read using the analogRead(ADC_IN)
function. The value is multiplied by a constant to convert the ADC value to a corresponding temperature (depending on the calibration).
b. Sending Sensor Data
The data is sent to the Consentium cloud using the sendData
function. In this example, the data array consists of one temperature sensor, but the setup allows for multiple sensors to be added in the future.
c. OTA Updates
Every 100 cycles, the firmware checks for available updates and performs the update if available.
4. Loop Control
The loop repeats every 5000 milliseconds (5 seconds).
5. Final code
Summary
This program reads temperature data from an LM35 sensor, sends the data to the Consentium IoT cloud, and periodically checks for OTA firmware updates. It provides a robust real-time sensor data monitoring system and easy firmware updates.
Last updated