Jump to content

MDM331AID/Experiment 8: Difference between revisions

From cognifront
CogWikiEditor (talk | contribs)
CogWikiEditor (talk | contribs)
Line 50: Line 50:
== Theory ==
== 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.
'''Internet of Things (IoT)''' is a technology in which physical devices equipped with sensors, processing units and communication capabilities collect and exchange data over a network. IoT enables sensor data to be transmitted to a remote server or cloud platform for storage, monitoring, analysis and visualization.


An RFID system generally consists of:
An IoT-based sensor data transmission system generally consists of:
* '''RFID tag:''' Stores identification information. Passive tags obtain operating energy from the reader's electromagnetic field.
* '''Sensor:''' Measures a physical quantity and produces an electrical signal corresponding to the measured value. In this experiment, the LM35 is used to measure temperature.
* '''RFID reader:''' Communicates with the tag and retrieves its identification information.
* '''IoT device / Controller:''' Reads the sensor output, processes the data and provides network connectivity. In this experiment, the ESP32 acts as the IoT device.
* '''Controller:''' Processes the information received from the reader. In this experiment, the Arduino UNO acts as the controller.
* '''Communication network:''' Provides connectivity between the IoT device and the server or cloud platform. The ESP32 uses Wi-Fi for communication.
* '''Monitoring system:''' Displays the received tag ID. In this experiment, the Arduino IDE Serial Monitor is used.
* '''Cloud server:''' Receives and stores the sensor data transmitted by the ESP32. The cloud platform used in this experiment provides facilities for storing and visualizing the sensor data.
* '''Data storage and analysis:''' The collected data can be exported in CSV format and analyzed or visualized using Microsoft Excel or other data-processing tools.


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.
'''LM35''' is an analog temperature sensor that produces an output voltage proportional to the temperature. It has a sensitivity of approximately 10 mV per degree Celsius. The ESP32 reads the analog voltage from the LM35 using its analog input and converts the measured voltage into temperature.


RFID is a short-range communication technology. The reading distance depends on the reader, tag, antenna, operating conditions and tag type.
The ESP32 is a microcontroller-based development board with built-in Wi-Fi connectivity. After reading the temperature from the LM35, the ESP32 connects to a Wi-Fi network and transmits the sensor data to the cloud server using the configured cloud communication mechanism.


'''Note:''' The UID is used here for demonstration and identification only. UID-based checking alone is not a secure authentication mechanism.
The cloud server receives the temperature readings and stores them as data records. In this experiment, the readings are collected at regular intervals and can be exported as a '''CSV (Comma-Separated Values)''' file. The CSV file can then be opened in Microsoft Excel for further analysis, tabulation and visualization.
 
The overall data flow of the system is:
 
<pre>
LM35 Temperature Sensor
          ↓
      ESP32
          ↓
      Wi-Fi
          ↓
    Cloud Server
          ↓
  Data Storage / CSV
          ↓
  Microsoft Excel
</pre>
 
This type of IoT-based data logging system can be used for applications such as environmental monitoring, machine condition monitoring, temperature logging and other systems where sensor measurements need to be collected remotely and analyzed.


== Pin Connections ==
== Pin Connections ==

Revision as of 16:43, 5 October 2026

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

Internet of Things (IoT) is a technology in which physical devices equipped with sensors, processing units and communication capabilities collect and exchange data over a network. IoT enables sensor data to be transmitted to a remote server or cloud platform for storage, monitoring, analysis and visualization.

An IoT-based sensor data transmission system generally consists of:

  • Sensor: Measures a physical quantity and produces an electrical signal corresponding to the measured value. In this experiment, the LM35 is used to measure temperature.
  • IoT device / Controller: Reads the sensor output, processes the data and provides network connectivity. In this experiment, the ESP32 acts as the IoT device.
  • Communication network: Provides connectivity between the IoT device and the server or cloud platform. The ESP32 uses Wi-Fi for communication.
  • Cloud server: Receives and stores the sensor data transmitted by the ESP32. The cloud platform used in this experiment provides facilities for storing and visualizing the sensor data.
  • Data storage and analysis: The collected data can be exported in CSV format and analyzed or visualized using Microsoft Excel or other data-processing tools.

LM35 is an analog temperature sensor that produces an output voltage proportional to the temperature. It has a sensitivity of approximately 10 mV per degree Celsius. The ESP32 reads the analog voltage from the LM35 using its analog input and converts the measured voltage into temperature.

The ESP32 is a microcontroller-based development board with built-in Wi-Fi connectivity. After reading the temperature from the LM35, the ESP32 connects to a Wi-Fi network and transmits the sensor data to the cloud server using the configured cloud communication mechanism.

The cloud server receives the temperature readings and stores them as data records. In this experiment, the readings are collected at regular intervals and can be exported as a CSV (Comma-Separated Values) file. The CSV file can then be opened in Microsoft Excel for further analysis, tabulation and visualization.

The overall data flow of the system is:

LM35 Temperature Sensor
          ↓
       ESP32
          ↓
       Wi-Fi
          ↓
    Cloud Server
          ↓
   Data Storage / CSV
          ↓
   Microsoft Excel

This type of IoT-based data logging system can be used for applications such as environmental monitoring, machine condition monitoring, temperature logging and other systems where sensor measurements need to be collected remotely and analyzed.

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

  1. Write ESP32 code to read temperature data from the LM35 sensor and send it to a cloud server using Wi-Fi.
  2. Develop a method to export or sync stored data to Excel for analysis and visualization.
  3. (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
   
Step 1
Visit www.cognifront.com and scroll down to the footer section.
   Step 2
   
Step 2
Click on the IoT Cloud option.
   Step 3
   
Step 3
Click on Login or Sign Up / Registration to access your account.
   Step 4
   
Step 4
After logging in, navigate to the Dashboard section.
   Step 5
   
Step 5
Click on Create New App to start a new cloud application.
   Step 6
   
Step 6
Enter your app name — for example, Data Logger.
   Step 7
   
Step 7
Your dashboard will update and display the newly created app.
   Step 8
   
Step 8
Each app shows buttons for Edit, Delete, Launch, and API Key.
   Step 9
   
Step 9
Click Edit App to open your app and create variables.
   Step 10
   
Step 10
Click on Create Variable to define a new data variable.
   Step 11
   
Step 11
Enter a variable name and select its type (defines input/output behavior).
   Step 12
   
Step 12
For example: Name – LM35, Type – Continuous.
   Step 13
   
Step 13
Return to the home page and click View App to launch your application. Congratulations! Your cloud app is now ready.
   Step 14
   
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.
   Step 15
   
Step 15
Ensure the cogcloudesp.h header file is included properly in your project.
   Step 16
   
Step 16
Update your code with your Wi-Fi SSID, password, and API key. A stable internet connection is required.
   Step 17
   
Step 17
Change the variable name in your code to match the one you created in the cloud app.
   Step 18
   
Step 18
Connect your ESP32 to your computer and upload the code.
   Step 19
   
Step 19
Open or launch your cloud app to visualize real-time sensor data from the LM35.
   Step 20
   
Step 20
In the app settings, click the Download .CSV button to export data.
   Step 21
   
Step 21
Set the desired time range for data export, or leave it blank to download all records.
   Step 22
   
Step 22
Open the downloaded .CSV file in Microsoft Excel to view the logged data.

Circuit & Board Connections

   Circuit Diagram
   
Circuit Diagram
The complete connection diagram of ESP32-based setup.
   Board Connections
   
Board Connections
Actual board wiring layout showing sensor and module 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)
Board Connections
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.