INDEX
Page Marks
S.No. Date Name of the Experiment Remarks
No. Awarded
SYLLABUS
LIST OF EXPERIMENTS
1. Explore AVR/ARM based controllers using Embedded C.
2. Write Basic and arithmetic Programs Using Embedded C.
3. Write Embedded C program to test interrupt and timers.
4. Develop Real time applications – clock generation, waveform generation, counter using
embedded C.
5. Explore different communication methods with IoT devices.
6. To interface LED/Buzzer with platform/ Aurdino /Raspberry Pi. and write an embedded C
program to turn on / off LED/Buzzer with specified delay.
7. To interface DC/stepper motor using relay with open platform/ Aurdino /Raspberry Pi. and
write an embedded C program to turn on motor if push button is pressed.
8. Develop simple application – testing infrared sensor – IoT Applications – using open
platform/Raspberry Pi.
9. Develop simple application to interface DHT11 sensor with and write a program to display
temperature humidity readings in LCD.
10. Develop IoMT Application using open platform/ Aurdino. /Raspberry Pi. and sensors such
as temperature, ECG, Pulse etc.
11. Deploy IoMT applications using platforms.
12. Mini Project.
TOTAL: 45 PERIODS
EXP.NO:1 AVR/ARM BASED CONTROLLERS
AIM:
To explore AVR/ARM based controllers using Embedded C.
APPARTUS REQUIRED:
PERSONAL COMPUTER
ARDUINO UNO SOFTWARE VERSION 1.8
ARDUINO UNO KIT
USB TO PRINTER INTERFACE CABLE
PROGRAM:
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
RESULT:
Thus the AVR/ARM based controllers using Embedded C was explored.
EXP.NO:2 ARITHMETIC PROGRAMS
AIM:
To write Basic and arithmetic Programs Using Embedded C.
APPARTUS REQUIRED:
PERSONAL COMPUTER
ARDUINO UNO SOFTWARE VERSION 1.8
ARDUINO UNO KIT
USB TO PRINTER INTERFACE CABLE
PROGRAM:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int a=5;
int b=10;
int c=a*b;
// print out the value you read:
Serial.println(c);
delay(1000); // delay in between reads for stability
RESULT:
Thus the Basic and arithmetic Programs Using Embedded C program successfully
verified.
EXP.NO:3 INTERRUPT AND TIMERS
AIM:
To Write Embedded C program to test interrupt and timers.
APPARTUS REQUIRED:
PERSONAL COMPUTER
ARDUINO UNO SOFTWARE VERSION 1.8
ARDUINO UNO KIT
USB TO PRINTER INTERFACE CABLE
PROGRAM:
String inputString = ""; // a String to hold incoming data
bool stringComplete = false; // whether the string is complete
void setup() {
// initialize serial:
Serial.begin(9600);
inputString.reserve(200);
pinMode(LED_BUILTIN, OUTPUT);
void loop() {
// print the string when a newline arrives:
if (stringComplete) {
Serial.println(inputString);
// clear the string:
inputString = "";
stringComplete = false;
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100);
void serialEvent() {
while (Serial.available()) {
char inChar = (char)Serial.read();
// add it to the inputString:
inputString += inChar;
if (inChar == '\n') {
stringComplete = true;
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(4000);
RESULT:
Thus the Embedded C program for interrupt and timers was tested successfully.
EXP.NO:4 CLOCK GENERATION, WAVEFORM GENERATION,
COUNTER
AIM:
To Develop Real time applications – clock generation, waveform generation using
embedded C.
APPARTUS REQUIRED:
PERSONAL COMPUTER
ARDUINO UNO SOFTWARE VERSION 1.8
ARDUINO UNO KIT
USB TO PRINTER INTERFACE CABLE
PROGRAM:
int pin = 2;
volatile unsigned int pulse;
const int pulses_per_litre = 450;
void setup()
Serial.begin(9600);
pinMode(pin, INPUT);
attachInterrupt(0, count_pulse, RISING);
void loop()
{ pulse=0;
interrupts();
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(10000); // delay in between reads for stability no Interrupts();
Serial.print("Pulses 10 second: ");
Serial.println(pulse);
}
void count_pulse()
pulse++;
RESULT:
Thus the clock generation, waveform generation,counter using embedded C was
developed successfully
CONNECTION DIAGRAM:
EXP.NO:5 TO INTERFACE LED/BUZZER WITH AURDINO
AIM:
To interface LED/Buzzer with Aurdino
APPARTUS REQUIRED:
PERSONAL COMPUTER
ARDUINO UNO SOFTWARE VERSION 1.8
ARDUINO UNO KIT
USB TO PRINTER INTERFACE CABLE
PROGRAM:
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
RESULT:
Thus the interfacing of LED/Buzzer with Aurdino was successfully implemeted
CIRCUIT CONNECTION:
Exp.No:6.A DIFFERENT COMMUNICATION METHODS WITH IOT
DEVICES-BLUETOOTH
AIM:
To explore different communication methods with IoT devices-Bluetooth using Embedded
C.
APPARTUS REQUIRED:
Personal Computer
Arduino Uno Software Version 1.8
Arduino Uno Kit
USB To Printer Interface Cable
Bluetooth Module HC-05
THEORY:
HC-05 Bluetooth Module
HC-05 is a Bluetooth device used for wireless communication with Bluetooth enabled devices (like
smartphone).
It communicates with microcontrollers using serial communication (USART).
Default settings of HC-05 Bluetooth module can be changed using certain AT commands.
As HC-05 Bluetooth module has 3.3 V level for RX/TX and microcontroller can detect 3.3 V level,
so, there is no need to shift TX voltage level of HC-05 module. But we need to shift the transmit
voltage level from microcontroller to RX of HC-05 module.
PROCEDURE:
Send Message using Bluetooth HC-05 With Arduino.
Here, we will transmit data from Smartphone via Bluetooth to the Arduino Uno and display
it on Serial Monitor of PC.
Download and install a Bluetooth terminal application on your phone and use it to connect
to the HC-05 Bluetooth module.
Data is sent from the Smartphone using the Bluetooth terminal application.
PROGRAM:
#include "SoftwareSerial.h"
SoftwareSerial mySerial(2, 3); //RX, TX
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
mySerial.begin(9600);
pinMode(13,OUTPUT);
}
void loop()
{
String str;;
if (mySerial.available()){
str = mySerial.readString();
Serial.println(str);
if((str[0] == 'o') && (str[1] == 'n'))
{
digitalWrite(13,HIGH);
}
if((str[0] == 'o') && (str[1] == 'f')&& (str[2] == 'f'))
{
digitalWrite(13,LOW);
}
}
if (Serial.available())
mySerial.write(Serial.read());
}
RESULT:
Thus the data send and received from Bluetooth module was explore
Exp.No:6.B DIFFERENT COMMUNICATION METHODS WITH IOT
DEVICES- GSM
AIM:
To explore different communication methods with IoT devices-GSM using Embedded C.
APPARTUS REQUIRED:
Personal Computer
Arduino Uno Software Version 1.8
Arduino Uno Kit
USB To Printer Interface Cable
GSM Module
PROGRAM:
#include <SoftwareSerial.h>
SoftwareSerial Sim(2, 3);
void setup()
{
Sim.begin(9600); // Setting the baud rate of Sim Module
Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
delay(100);
}
void loop()
{
if (Serial.available()>0)
{
switch(Serial.read()) // Read data given in Serial Monitor
{
case 's': // If data is 's', goto SendMessage() function
SendMessage();
break;
case 'r': // If data is 'r', goto ReceiveMessage() function
ReceiveMessage();
break;
}
}
if (Sim.available()>0)
{
Serial.write(Sim.read()); // If SIM module sendsmessages, print it to Serial monitor
}
}
void SendMessage()
{
Sim.println("AT+CMGF=1"); // Sets the Sim Module in send SMS mode
delay(1000); // Delay of 1 second
Sim.println("AT+CMGS=\"+916383917274\"\r"); // Replace x with mobile number
delay(1000); // Delay of 1 second
Sim.println("I am SMS from Sim Module"); // Type in the SMS text you want to send
delay(100); // Delay of 0.1 second
Sim.println((char)26); // ASCII code of CTRL+Z (to exit out)
delay(1000); // Delay of 1 second
}
void ReceiveMessage()
{
Sim.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
delay(1000); // Delay of 1 second
}
RESULT:
Thus the data send and received from GSM module was explored.
CIRCUIT CONNECTION:
L298 motor driver module:
EX:No:7 DC/STEPPER MOTOR
AIM:
To interface DC/stepper motor using relay with open platform/ Aurdino /Raspberry Pi. And
write an embedded C program to turn on motor if push button is pressed.
APPARATUS REQUIRED:
Arduino UNO kit
DC motot
L298 Motor driver module
USB to printer cable
Jumper wires
12V DC adapter
PROGRAM:
void setup() {
pinMode(8, OUTPUT); //IN2
pinMode(9, OUTPUT); //IN1
pinMode(10, OUTPUT); //Enable Pin
void loop() {
// Full speed forward
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
delay(3000);
// Full speed backward
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
delay(3000);
// 0 to 100% speed in forward mode
for (int i=0;i<256;i++)
{ digitalWrite(8, HIGH);
digitalWrite(9, LOW);
analogWrite(10, i);
delay(20);
delay(50);
// 0 to 100% speed in backward mode
for (int i=0;i<256;i++)
{ digitalWrite(8, LOW);
digitalWrite(9, HIGH);
analogWrite(10, i);
delay(20);
delay(50);
RESULT:
Thus the interfacing of DC motor using relay with Aurdino was executed successfully.
CIRCUIT DIAGRAM CONNECTION:
Exp.No:8 INTERFACING IR SENSOR WITH RASPBERRY PI (IR SENSOR )
AIM:
To Interface IR sensors with Raspberry PI
APPARTUS REQUIRED:
Personal Computer
Raspberry Pi 3 Model B
IR Sensor
5V Buzzer
Mini Breadboard
Connecting Wires
Power Supply
Computer
PROGRAM:
import RPi.GPIO as IO
import busio
import board
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
import time
buzzer_pin = 12 #32 buzzer IO.setwarnings(False)
IO.setmode(IO.BCM)
IO.setup(buzzer_pin, IO.OUT)
# Initialize the I2C interface
i2c = busio.I2C(board.SCL, board.SDA)
# Create an ADS1115 object ads = ADS.ADS1115(i2c)
# Define the analog input channel
channel = AnalogIn(ads, ADS.P0)
while True:
ir_value = int(channel.value)
print('IR_value',ir_value)
if(ir_value > 10000):
IO.output(buzzer_pin,True)
else:
IO.output(buzzer_pin,False)
time.sleep(1)
RESULT:
Thus the Interfacing IR sensors with Raspberry PI was constructed and object
detected successfully.
CONNECTION DIAGRAM:
Exp.No:09 SETUP A CLOUD PLATFORM TO LOG THE DATA
AIM:
To setup a cloud platform to log the data.
APPARATUS REQUIRED:
DHT11 Sensor
Arduino uno
Node MCU WiFi module
PROGRAM:
#include "ThingSpeak.h"
#include <ESP8266WiFi.h>
#include "dht11.h"
#define DHT11PIN 5
//----------- Enter you Wi-Fi Details---------//
char ssid[] = "raspberry_pi"; //SSID
char pass[] = "123456789"; // Password
//-------------------------------------------//
WiFiClient client;
unsigned long myChannelNumber = 1831217; // Channel ID here
const int FieldNumber = 1;
const char * myWriteAPIKey = "P47FDNAYU6MRM9WH"; // Your Write API Key here
dht11 DHT11;
float temp;
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
ThingSpeak.begin(client);
}
void loop() {
if (WiFi.status() != WL_CONNECTED)
{
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
while (WiFi.status() != WL_CONNECTED)
{
WiFi.begin(ssid, pass);
Serial.print(".");
delay(1000);
}
Serial.println("\nConnected.");
}
int chk = DHT11.read(DHT11PIN);
temp = (float)DHT11.temperature;
Serial.print("Temperature (C): ");
Serial.println(temp, 2);
ThingSpeak.writeField(myChannelNumber, FieldNumber, temp, myWriteAPIKey);
delay(1500);
}
RESULT:
Thus the cloud platform to log the data setup completed successfully.
EX:No:10.A ECG
AIM:
To Develop IoMT Application using open platform/ Aurdino. /Raspberry Pi. and sensors
such as ECG
APPARATUS REQUIRED:
S.N. Components Name Quantity
1 ESP32 Board 1
2 AD8232 ECG Sensor 1
3 Micro-USB Cable 1
5 Connecting Wires 10
5 Breadboard 1
THEORY:
AD8232 ECG Sensor
This sensor is a cost-effective board used to measure the electrical activity of the heart. This
electrical activity can be charted as an ECG or Electrocardiogram and output as an analog
reading. ECGs can be extremely noisy, the AD8232 Single Lead Heart Rate Monitor acts as an op
amp to help obtain a clear signal from the PR and QT Intervals easily.
The AD8232 is an integrated signal conditioning block for ECG and other biopotential
measurement applications. It is designed to extract, amplify, and filter small biopotential signals in
the presence of noisy conditions, such as those created by motion or remote electrode placement.
The AD8232 module breaks out nine connections from the IC that you can solder pins, wires, or
other connectors to. SDN, LO+, LO-, OUTPUT, 3.3V, GND provide essential pins for operating
this monitor with an Arduino or other development board. Also provided on this board are RA
(Right Arm), LA (Left Arm), and RL (Right Leg) pins to attach and use your own custom sensors.
Additionally, there is an LED indicator light that will pulsate to the rhythm of a heartbeat.
Circuit Diagram: Interfacing AD8232 ECG Sensor with ESP32
To interface AD8232 ECG Sensor with ESP32 IOT Chip, follow the circuit diagram above.
Supply the AD8232 with 3.3V from ESP32 and connect GND to GND. The output pin of AD8232
is an analog signal and is connected to VP pin of ESP32. Similarly LO+ and L0- of AD8232 is
connected to D2 & D3 of ESP32.
Remember, there are so many vendors who makes ESP32. All those ESP32 has different pin
mapping. I have used ESP32 wroom 32 Board. If you are using any other board then, please take
care of the ESP32 Pins while connecting to AD8232.
AD8232 ECG Sensor Placement on Body
It is recommended to snap the sensor pads on the leads before application to the body. The closer to
the heart the pads are, the better the measurement. The cables are color coded to help identify proper
placement.
Red:RA(RightArm)
Yellow: LA (Left Arm)
Green: RL (Right Leg)
I have connected by ESP32 with AD8232 to my hand or simply you can place in your chest as
shown in the figure below.
PROCEDURE:
Setting Up Ubidots Account
To publish the data to IoT Cloud, we need some IoT platform. So Ubidots is one such
platform. Ubidots offers a platform for developers that enables them to easily capture sensor
data and turn it into useful information. Use the Ubidots platform to send data to the cloud from
any Internet-enabled device.
Step 1: Creating Ubidots Account
Go to ubidots.com and create and account. You will get a trial period of 30 days.
Step 2: Creating Device & Adding Variables
Now setup an Ubidots Device. To create it, go to the Devices section (Devices > Devices). Create a
new Device with name esp32.
Once the device is created, create a new variable by renaming the variabale to sensor.
Step 3: Creating Dashboards
Let’s setup an Ubidots’ Dashboard. To create it, go to the Dashboard section (Data > Dashboard)
Step 4: Adding New Widgets
Click on the + sign in the right side and “Add new Widget”, and select your widget.
Now, Select the type of widget desired to be displayed. In my case, I choose the “Line Chart”:
Then, select the variable desired to display the data. Ubidots allows you assign a customize widget
name, color, period of data to be displayed and much more. To finish the widget creation, press the
green icon.
Selct your previously created Device and Variables as shown in the figure below.
Now select the following parameters from the tools and upload the code to ESP32. In some cases
the code does not get uploaded. So press boot button while uploading the code to ESP32.
Checking Data & ECG Graph on Ubidots
Once the code is uploaded to ESP32 Board, click on serial monitor. If the ESP32 connects to wifi,
it will start sending data to Ubidots Cloud.
You can now go to Ubidots Dashboard and click on esp32, there you will be able to see the ECG
Graph.
PROGRAM:
#include <WiFi.h>
#include <PubSubClient.h>
#define WIFISSID "Alexahome" // Put your WifiSSID here
#define PASSWORD "hngzhowxiantan" // Put your wifi password here
#define TOKEN "BBFF-RJ8ABBbh6G2ECGU0rkjRSOdXqhUnvj" // Put your Ubidots' TOKEN
#define MQTT_CLIENT_NAME "alexnewton" // MQTT client Name, please enter your own 8-12
alphanumeric character ASCII string;
//it should be a random and unique ascii string and different from all
other devices
#define VARIABLE_LABEL "sensor" // Assing the variable label
#define DEVICE_LABEL "esp32" // Assig the device label
#define SENSOR A0 // Set the A0 as SENSOR
char mqttBroker[] = "industrial.api.ubidots.com";
char payload[100];
char topic[150];
// Space to store values to send
char str_sensor[10];
/****************************************
* Auxiliar Functions
****************************************/
WiFiClient ubidots;
PubSubClient client(ubidots);
void callback(char* topic, byte* payload, unsigned int length) {
char p[length + 1];
memcpy(p, payload, length);
p[length] = NULL;
Serial.write(payload, length);
Serial.println(topic);
}
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.println("Attempting MQTT connection...");
// Attemp to connect
if (client.connect(MQTT_CLIENT_NAME, TOKEN, "")) {
Serial.println("Connected");
} else {
Serial.print("Failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 2 seconds");
// Wait 2 seconds before retrying
delay(2000);
}
}
}
/****************************************
* Main Functions
****************************************/
void setup() {
Serial.begin(115200);
WiFi.begin(WIFISSID, PASSWORD);
// Assign the pin as INPUT
pinMode(SENSOR, INPUT);
Serial.println();
Serial.print("Waiting for WiFi...");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi Connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
client.setServer(mqttBroker, 1883);
client.setCallback(callback);
}
void loop() {
if (!client.connected()) {
reconnect();
}
sprintf(topic, "%s%s", "/v1.6/devices/", DEVICE_LABEL);
sprintf(payload, "%s", ""); // Cleans the payload
sprintf(payload, "{\"%s\":", VARIABLE_LABEL); // Adds the variable label
float sensor = analogRead(SENSOR);
/* 4 is mininum width, 2 is precision; float value is copied onto str_sensor*/
dtostrf(sensor, 4, 2, str_sensor);
sprintf(payload, "%s {\"value\": %s}}", payload, str_sensor); // Adds the value
Serial.println("Publishing data to Ubidots Cloud");
client.publish(topic, payload);
client.loop();
delay(500);
}
RESULT:
Thus the IoMT Application using open platform/ Aurdino. Esp32 and sensors such as ECG
was verified successfully.
EX:No:10.B PULSE
AIM:
To Develop IoMT Application using open platform/ Aurdino. /Raspberry Pi. and sensors
such as PULSE.
APPARATUS REQUIRED:
Arduino UNO kit
Pulse sensor
USB to printer cable
Jumper wires
THEORY:
Heart Rate Pulse Sensor Pinout
This Module has 3 pins:
+: Module power supply – 5 V
–: Ground
S: Output
You can see the pinout of this module in the image below.
Interfacing Heart Rate Pulse Sensor with Arduino
Step 1: Circuit
The following circuit shows how you should connect Arduino to this sensor. Connect wires
accordingly.
Put the sensor on a black belt for better function.
Step 2: Installing Library
Go to Library manager and install the heart rate sensor library.
Step 3: Code
Upload the following code to Arduino. After that, open the Serial Plotter window.
THE OUTPUT:
PROGRAM:
int PulseSensorPurplePin = A0; // Pulse Sensor PURPLE WIRE connected to ANALOG PIN 0
int LED13 = 13; // The on-board Arduion LED
int Signal; // holds the incoming raw data. Signal value can range from 0-1024
int Threshold = 550; // Determine which Signal to "count as a beat", and which to ingore.
// The SetUp Function:
void setup() {
pinMode(LED13, OUTPUT); // pin that will blink to your heartbeat!
Serial.begin(9600); // Set's up Serial Communication at certain speed.
// The Main Loop Function
void loop() {
Signal = analogRead(PulseSensorPurplePin); // Read the PulseSensor's value.
// Assign this value to the "Signal" variable.
Serial.println(Signal); // Send the Signal value to Serial Plotter.
if (Signal > Threshold) { // If the signal is above "550", then "turn-on" Arduino's on-
Board LED.
digitalWrite(LED13, HIGH);
} else {
digitalWrite(LED13, LOW); // Else, the sigal must be below "550", so "turn-off" this LED.
delay(10);
RESULT:
Thus the IoMT Application using Aurdino and sensors such as Pulse sensor was
verified successfully.
CONECTION DIAGRAM:
Ex no: 1 1 Deploy IoMT applications using platforms
Date:
Aim
To deploy IoMT applications using platforms
Procedure
This program interfaces an HC-SR04 ultrasonic distance sensor with the Raspberry Pi. It uses
the GPIO library to control the GPIO pins. It continuously measures and prints the distance in
centimeters.
Program
Interfacing an Ultrasonic Distance Sensor (HC-SR04) with Raspberry Pi
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
trigger_pin = 18
echo_pin = 24
GPIO.setup(trigger_pin, GPIO.OUT)
GPIO.setup(echo_pin, GPIO.IN)
while True:
GPIO.output(trigger_pin, True)
time.sleep(0.00001)
GPIO.output(trigger_pin, False)
start_time = time.time()
stop_time = time.time()
while GPIO.input(echo_pin) == 0:
start_time = time.time()
while GPIO.input(echo_pin) == 1:
stop_time = time.time()
33
elapsed_time = stop_time - start_time
distance = (elapsed_time * 34300) / 2
print(f'Distance: {distance} cm')
time.sleep(1)
Interfacing an Pressure Sensor with Arduino Pi:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp;
void setup() {
Serial.begin(9600);
if (!bmp.begin(0x76)) {
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}
}
void loop() {
sensors_event_t pressureEvent;
bmp.getEvent(&pressureEvent);
if (pressureEvent.pressure) {
float pressurePa = pressureEvent.pressure;
float pressurePsi = pressurePa * 0.0001450377; // Conversion to psi
Serial.print("Pressure (Pa): ");
Serial.print(pressurePa);
Serial.print(" Pressure (psi): ");
Serial.println(pressurePsi);
}
34
delay(1000); // Adjust the delay as per your requirements
}
Result
Thus the program to deploy IoMT applications using platforms are verified
35
Exp.No:12 MINI PROJECT
AIM:
To design an iot based system
APPARATUS REQUIRED:
LDR Sensor
Arduino uno
Rasberrypi
Node MCU
PROGRAM:
#include "ThingSpeak.h"
#include <ESP8266WiFi.h>
const int LDR_pin = A0;
//----------- Enter you Wi-Fi Details---------//
char ssid[] = "raspberry_pi"; //SSID
char pass[] = "123456789"; // Password
//-------------------------------------------//
WiFiClient client;
unsigned long myChannelNumber = 1831217; // Channel ID here
const int FieldNumber = 1;
const char * myWriteAPIKey = "P47FDNAYU6MRM9WH"; // Your Write API Key here
unsigned short ADC;
unsigned char LDR_percentage;
void setup()
{
Serial.begin(115200);
pinMode(2,OUTPUT);
WiFi.mode(WIFI_STA);
ThingSpeak.begin(client);
}
void loop()
{
if (WiFi.status() != WL_CONNECTED)
{
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
while (WiFi.status() != WL_CONNECTED)
{
WiFi.begin(ssid, pass);
Serial.print(".");
delay(5000);
}
Serial.println("\nConnected.");
}
ADC = analogRead(LDR_pin); // Reading LDR Input.
LDR_percentage = map(ADC, 0, 1023, 0, 100);
Serial.print("LDR Percentage = ");
Serial.print(LDR_percentage);
Serial.println(" %");
if(LDR_percentage >70)
{
digitalWrite(2,HIGH);
}
else{
digitalWrite(2,LOW);
}
ThingSpeak.writeField(myChannelNumber,FieldNumber,LDR_percentage, myWriteAPIKey);
delay(15000);
}
RESULT:
Thus the IoT based system was implemented successfully.