MDM331AID/Experiment 8
Experiment: Transmit sensor data between an IoT device and a server
Aim
To develop an IoT application that uses the communication protocol to transmit sensor data between an IoT device and a server
Objectives
- To understand the concept of IoT-based sensor data communication.
- To interface an LM35 temperature sensor with an ESP32 development board.
- To read temperature data from the LM35 sensor using the ESP32.
- To connect the ESP32 to a Wi-Fi network and transmit sensor data to a cloud server.
Components Required
| Sr. No. | Component | Quantity |
|---|---|---|
| 1 | ESP32 development board | 1 |
| 2 | LM35 temperature sensor | 1 |
| 3 | USB cable | 1 |
| 4 | Patch cords / jumper wires | As required |
| 5 | Wi-Fi network / Internet connection | 1 |
| 6 | Computer with Arduino IDE | 1 |
| 7 | Cloud IoT platform / server (Cognifront IoT Cloud) | 1 account per user/student |
Theory
Radio Frequency Identification (RFID) is a wireless identification technology that uses radio waves to exchange information between an RFID reader and an RFID tag.
An RFID system generally consists of:
- RFID tag: Stores identification information. Passive tags obtain operating energy from the reader's electromagnetic field.
- RFID reader: Communicates with the tag and retrieves its identification information.
- Controller: Processes the information received from the reader. In this experiment, the Arduino UNO acts as the controller.
- Monitoring system: Displays the received tag ID. In this experiment, the Arduino IDE Serial Monitor is used.
The MFRC522 reader communicates with the Arduino UNO using the SPI (Serial Peripheral Interface) protocol. When a compatible RFID tag is brought close to the reader, the reader detects the tag and retrieves its UID. The Arduino then displays the UID on the Serial Monitor.
RFID is a short-range communication technology. The reading distance depends on the reader, tag, antenna, operating conditions and tag type.
Note: The UID is used here for demonstration and identification only. UID-based checking alone is not a secure authentication mechanism.
Pin Connections
The following connections assume an MFRC522 RFID module and an Arduino UNO.
| RFID Module Pin | Arduino UNO Pin | Description |
|---|---|---|
| SDA / SS | D10 | SPI chip select |
| SCK | D13 | SPI clock |
| MOSI | D11 | SPI data from Arduino to reader |
| MISO | D12 | SPI data from reader to Arduino |
| RST | D9 | Reset |
| 3.3V | 3.3V | Power supply |
| GND | GND | Ground |
| IRQ | Not connected | Not required for this program |
Important electrical precaution: The MFRC522 operates at 3.3 V. Do not connect its power pin to 5 V. The Arduino UNO uses 5 V logic, while the MFRC522 chip uses 3.3 V logic. Check the specifications of your RFID breakout board. If it does not provide suitable logic-level compatibility, use a 5 V-to-3.3 V logic-level shifter for the Arduino output signals connected to the reader. The MISO signal from the reader is generally accepted by the UNO as a logic HIGH, but verify module specifications.
Connection Diagram
Connect the MFRC522 RFID reader to the Arduino UNO according to the pin connection table.
The USB cable connects the Arduino UNO to the computer. The computer runs the Arduino IDE and displays the received tag ID through the Serial Monitor.
Task
- Write ESP32 code to read temperature data from the LM35 sensor and send it to a cloud server using Wi-Fi.
- Develop a method to export or sync stored data to Excel for analysis and visualization.
- (Optional) Plot real-time or historical temperature data in Excel or a web-based dashboard.
⚠️ Disconnect your ESP32 from the computer while making or removing component connections.
Setting Up Cloud
![]()
Step 1
Visit www.cognifront.com and scroll down to the footer section.
![]()
Step 13
Return to the home page and click View App to launch your application. Congratulations! Your cloud app is now ready.
![]()
Step 14
Open the program folder — you will find two files: eecit-exp-06-data-logger.ino (main program) and cogcloudesp.h (library header file). Open the .ino file in Arduino IDE.
Circuit & Board Connections
Connections
| LM35 Pins | ESP32 Pins |
|---|---|
| GND | GND |
| VCC (3.3V) | 3.3V |
| DATA | GPIO34 |
ESP32 Code
// © 2025, Cognifront. Member of The IoT Kits Family.
//Experiment 6: Data Logging Using ESP32 and Excel (Cloud Communication)
#include "cogcloudesp.h"
//int cogLed = 15;
const int lm35_pin = 34;
String ssid = "Airtel_Tapas"; //wifi name
String pass = "wifi@CogLab#1"; //wifi password 2.4 hz banfd only
String apikey = "0CC262DFF7D978DB4102A02774215D37"; //api key from app
void setup ()
{
// pinMode (cogLed,OUTPUT);
pinMode (lm35_pin, INPUT);
Serial.begin(115200);
while (!Serial)
delay(100);
cogInitCloud (ssid,pass,apikey);
// cogBindPin (cogLed, "LED");
}
void loop ()
{
cogAppLoop();
int voltage_mv = analogReadMilliVolts(lm35_pin);
float temp_val = voltage_mv / 10.0; // LM35 = 10 mV per °C
// Send value to cloud
cogStoreCloudVariable("LM35", String(temp_val, 2));
delay(2000);
}
⬇ Click Here to Download Code File
(Contains ESP32 source code)
![]()
Connect your ESP32 to your computer and upload the code make sure right port selected.
Observation
- The ESP32 successfully reads temperature data from the LM35 sensor.
- Data is stored in a CSV file on the cloud at two-second intervals.
- Using PLX-DAQ or Python, data can be visualized in real time in Excel.
Conclusion
This experiment demonstrates how to log real-time sensor data from ESP32 to a computer using cloud communication. Storing data in CSV format enables easy analysis and plotting in Excel or any other data-processing tool.
Real Life Example
Condition Monitoring in Machines and Data Logging: Sensors collect data such as vibration, temperature, or pressure from mechanical systems, which is logged and analysed in Excel for predictive maintenance and fault diagnosis. Also this data can be fed for training a machine learning model.