0% found this document useful (0 votes)
17 views33 pages

Devi Ahilya Vishwavidyalaya, Indore: School of Electronics

Uploaded by

Animesh Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views33 pages

Devi Ahilya Vishwavidyalaya, Indore: School of Electronics

Uploaded by

Animesh Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 33

SCHOOL OF ELECTRONICS

DEVI AHILYA VISHWAVIDYALAYA, INDORE


(A State Govt. Statutory University of M.P.)

Accredited by NAAC with Grade ‘A+’

Submitted by:- Internet of Things (IOT) Laboratory


Name: Animesh Jain
Roll no.: 20IMTEL02
i.Mtech 6th Sem. Report

Submitted to:-
Ms.Kirti panwar bhati
Master of Technology (Embedded Systems)
Batch 2020-25
EMBEDDED MICROCONTROLLER LAB FILE

Index
Sr.
Name of the Program Date Sign
No.
1.
Headless setup for Raspberry PI
2.
Configure Static IP for Raspberry PI
3.
Controlling Raspberry PI using GUI
4.
Controlling Raspberry PI using telegram

Create NodeRed flow and dashboard for


5.
controlling the equipment in two
different rooms.

6. Show R-Pi CPU temperature on NodeRed


flow.

Create mosquito client – install its server


7.
and create two client one for publisher
and one for subscriber.

Create the publisher and subscriber on


8.
IOT MQTT panel and communicate with
HIVEMQTT broker and its websocket.

Use python Q3 android application for


9.
accessing various component on mobile
phone.

Create a database “Student” with Roll-


No.(auto-increment),” Name”,”AGE”,”
percentage”.
10. Insert at least five tuples and sql queries.
1.Fetch all records.
2.Fetch all students above 75%.
3.Fetch all student above 19 years.

11. Arduino program for LED.

1 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Arduino program for buzzer when you


12. press a button.

Arduino LED program using touch


13. sensor.

Arduino program for Rotary angle


14.
sensor.
15.
Arduino program for Light sensor.

16.
Arduino program for Sound Sensor.

Arduino program for temperature


17.
sensor.
18.

Program 1 :-

2 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

->Headless setup for Raspberry PI

Hardware and Software Requirement:-

Block Diagram:-

Code:

Output:

Program 2 :-
3 | Page M.Tech.(ES) Sem-VI
EMBEDDED MICROCONTROLLER LAB FILE

->Configure Static IP for Raspberry PI

Hardware and Software Requirement:-

Block Diagram:-

Code:

Output:

Program 3 :-
4 | Page M.Tech.(ES) Sem-VI
EMBEDDED MICROCONTROLLER LAB FILE

->Controlling Raspberry PI using GUI

Hardware and Software Requirement:-


Raspberry pi 3b
Led,Resistor,connecting wire
Thorny Python
Code:

from tkinterimport * # imports the Tkinterlib


import RPi.GPIOas GPIO # imports the GPIOlib
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(23,GPIO.OUT) # LED connected to GPIO23
root = Tk() # create the root object
root.wm_title("GUI") # sets title of the
windowroot.configure(bg="#99B898") # change the background color
root.attributes("-fullscreen", True) # set to fullscreen
defbtnClicked():
if GPIO.input(23):
GPIO.output(23,GPIO.LOW)
ledButton["text"]="LED OFF"
else:
GPIO.output(23,GPIO.HIGH)
edButton["text"]="LED ON“
defbtnExit():
root.destroy() # we can exit when we press the escape key
defend_fullscreen(event):
root.attributes("-fullscreen", False)
label_1 = Label(root, text="Raspberry Pi Graphical User Interface",
font="Verdana 26 bold",fg="#000", bg="#99B898", pady= 60,padx = 100)

exitButton= Button(root, text="Exit", background = "#C06C84",


command=btnExit, height=10, width=40, font = "Arial 16 bold")
ledButton= Button(root, text="LED OFF",background= "#C06C84",
command=btnClicked, height=10, width=40, font = "Arial 16 bold")

label_1.grid(row=0, column=0)
exitButton.grid(row = 1 ,column = 0)
ledButton.grid(row = 1 ,column = 1)
root.bind("<Escape>", end_fullscreen)
root.mainloop() # starts the GUI loop
Output:

5 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Program 4 :-
-> Controlling Raspberry PI using telegram

Hardware and Software Requirement:-

6 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Raspberry PI model 3B,


Telegram, Thorny Python,
Led,resistor,connecting wire.
Code:
Import time
Import telepot
Import RPi.GPIO as GPIO
From telepot.loop import MessageLoop
#LED
def on(pin):
GPIO.output(pin,GPIO.HIGH)
return
def off(pin):
GPIO.output(pin,GPIO.LOW)
return
#touseRaspberryPiboardpinnumbers

GPIO.setmode(GPIO.BOARD)

#setupGPIOoutputchannel

GPIO.setup(11,GPIO.OUT)

def handle(msg):
print msg
chat_id= msg ['chat'] ['id']
print chat_id command = msg ['text']
print 'Gotcommand:%s' %command
if command == 'on':
bot.sendMessage(chat_id, "set led on")
on(11)
elif command =='off':
bot.sendMessage(chat_id, "set led off")
off(11)
bot=telepot.Bot(“5971834468:AAHo5vKznwoBf0C1lBiaMhNM-qADK-
pNY3E”)
MessageLoop(bot,handle).run_as_thread()
print ' I am listening...'

while1:
time.sleep(10)

7 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Output:

Program 5 :-
->Create NodeRed flow and dashboard for controlling the equipment in two
different rooms.
Hardware and Software Requirement:-

8 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Block Diagram:-

Code:

Output:

Program 6 :-
->Show R-Pi CPU temperature on NodeRed flow.

Hardware and Software Requirement:-

9 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Block Diagram:-

Code:

Output:

Program 7 :-
->Create mosquito client – install its server and create two client one for
publisher and one for subscriber.
Hardware and Software Requirement:-
10 | Page M.Tech.(ES) Sem-VI
EMBEDDED MICROCONTROLLER LAB FILE

Block Diagram:-

Code:

Output:

Program 8:-
->Create the publisher and subscriber on IOT MQTT panel and communicate
with HIVEMQTT broker and its websocket.
Hardware and Software Requirement:-
11 | Page M.Tech.(ES) Sem-VI
EMBEDDED MICROCONTROLLER LAB FILE

HiveMQ broker,
IoT MQTT mobile application
Code:
Output:

Program 9 :-
->Use python Q3 android application for accessing various component on
mobile phone.

12 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Hardware and Software Requirement:-


Python Q3 application,
Andriod Smartphone
Code:
Q1:Display text
import androidhelper
droid = androidhelper.Android()
droid.makeToast('Hello, Animesh jain!')
droid.makeToast('IoT Program 9')

Output:

Code:
Q2:Enable Bluetooth

13 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

import androidhelper
import time

droid = androidhelper.Android()
droid.toggleBluetoothState(True)
droid.dialogCreateAlert('Be a server?')
droid.dialogSetPositiveButtonText('Yes')
droid.dialogSetNegativeButtonText('No')
droid.dialogShow()
result = droid.dialogGetResponse()
is_server = result.result['which'] == 'positive'
if is_server:
droid.bluetoothMakeDiscoverable()
droid.bluetoothAccept()
else:
droid.bluetoothConnect()

if is_server:
result = droid.getInput('Chat', 'Enter a message').result
if result is None:
droid.exit()
droid.bluetoothWrite(result + '\n')

while True:
message = droid.bluetoothReadLine().result
droid.dialogCreateAlert('Chat Received', message)
droid.dialogSetPositiveButtonText('Ok')
droid.dialogShow()
droid.dialogGetResponse()
result = droid.getInput('Chat', 'Enter a message').result
if result is None:
break
droid.bluetoothWrite(result + '\n')

droid.exit()

14 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Output:

Program 10 :-
->Create a database “Student” with Roll-No.(auto-increment),”
Name”,”AGE”,” percentage”.

15 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Insert at least five tuples and sql queries.


1.Fetch all records.
2.Fetch all students above 75%.
3.Fetch all student above 19 years.
Hardware and Software Requirement:-

Block Diagram:-

Code:

Output:

Program 11. :-
->Arduino program for LED.

16 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Hardware and Software Requirement:-


Connecting wires, Arduino UNO, Arduino Uno Base shield, LED sensor,
Arduino desktop software
Block Diagram:-

Code:
#define LED 2 //connect LED to digital pin2
void setup() {
// initialize the digital pin2 as an output.
pinMode(LED, OUTPUT);
}

void loop() {
digitalWrite(LED, HIGH); // set the LED on
delay(1000); // for 500ms
digitalWrite(LED, LOW); // set the LED off
delay(1000);
}

Output:

17 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Program 12 :-
->Arduino program for buzzer when you press a button.

18 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Hardware and Software Requirement:-


Connecting wires, Arduino UNO, Arduino Uno Base shield, Buzzer sensor,
Arduino desktop software
Block Diagram:-

Code:
const int buttonPin = 2;
const int buzzer = A3;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(buzzer, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
19 | Page M.Tech.(ES) Sem-VI
EMBEDDED MICROCONTROLLER LAB FILE

if (buttonState == HIGH) {
tone(buzzer, 1000);
}
else {
noTone(buzzer);
}
}

Output:

Program 13 :-
->Arduino LED program using touch sensor.
Hardware and Software Requirement:-
Connecting wires, Arduino UNO, Arduino Uno Base shield, Touch sensor,

20 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Arduino desktop software


Block Diagram:-

Code:
const int TouchPin=2;
const int ledPin=3;
void setup() {
pinMode(TouchPin, INPUT);
pinMode(ledPin,OUTPUT);
}
void loop() {
int sensorValue = digitalRead(TouchPin);
if(sensorValue==1)
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
}
Output:

21 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Program 14 :-
->Arduino program for Rotary angle sensor.

22 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Hardware and Software Requirement:-


Connecting wires, Arduino UNO, Ardui0no Uno Base shield, Rotary angle
sensor, Arduino desktop software
Block Diagram:-

Code:

#define ROTARY_ANGLE_SENSOR A0
#define LED 3 //the Grove - LED is connected to PWM pin D3 of Arduino
#define ADC_REF 5 //reference voltage of ADC is 5v.If the Vcc switch on the
seeeduino
//board switches to 3V3, the ADC_REF should be 3.3
#define GROVE_VCC 5 //VCC of the grove interface is normally 5v
#define FULL_ANGLE 300 //full value of the rotary angle is 300 degrees

void setup()
{
Serial.begin(9600);
pinMode(ROTARY_ANGLE_SENSOR, INPUT);
pinMode(LED,OUTPUT);
}

void loop()
{

23 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

float voltage;
int sensor_value = analogRead(ROTARY_ANGLE_SENSOR);
voltage = (float)sensor_value*ADC_REF/1023;
float degrees = (voltage*FULL_ANGLE)/GROVE_VCC;
Serial.println("The angle between the mark and the starting position:");
Serial.println(degrees);

int brightness;
brightness = map(degrees, 0, FULL_ANGLE, 0, 255);
analogWrite(LED,brightness);
delay(1000);
}

Output:

Program 15 :-
->Arduino program for Light sensor.

24 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Hardware and Software Requirement:-


Connecting wires, Arduino UNO, Ardui0no Uno Base shield, Light sensor,
Arduino desktop software
Block Diagram:-

Code:
const int pinLight = A0;
const int pinLed = 7;

// Defines the light-sensor threshold value below which the LED will turn on.
// Decrease this value to make the device more sensitive to ambient light, or
vice-versa.
int thresholdvalue = 50;

void setup()
{
Serial.begin(9600);
// Configure the LED's pin for output signals.
pinMode(pinLed, OUTPUT);
}

void loop()
{
// Read the value of the light sensor. The light sensor is an analog sensor.
int sensorValue = analogRead(pinLight);

25 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Serial.println(sensorValue);
// Turn the LED on if the sensor value is below the threshold.
if(sensorValue < thresholdvalue)
{
digitalWrite(pinLed, HIGH);
}
else
{
digitalWrite(pinLed, LOW);
}
}

Output:

Program 16 :-
->Arduino program for Sound Sensor.
Hardware and Software Requirement:-

26 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Connecting wires, Arduino UNO, Ardui0no Uno Base shield, Sound Sensor,
Arduino desktop software.
Block Diagram:-

Code:
// Define the pins to which the sound sensor
// and LED are connected.
const int pinSound = A0;
const int pinLed = 7;

// Define the sound level above which to turn //on the LED.
// Change this to a larger value to require a
// louder noise level.
int thresholdValue = 400;

void setup()
{
// Configure LED's pin for output signals.
pinMode(pinLed, OUTPUT);
}

void loop()
{
// Read the value of the sound sensor.

27 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

int sensorValue = analogRead(pinSound);

// If the measured sound level is above the //threshold, blink the LED.
if(sensorValue > thresholdValue)
{
// Turn the LED on for 200ms, then turn it //back off.
digitalWrite(pinLed,HIGH);
delay(200);
digitalWrite(pinLed,LOW);
}
}
Output:

Program 17 :-
->Arduino program for temperature sensor.

Hardware and Software Requirement:-

28 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

Connecting wires, Arduino UNO, Ardui0no Uno Base shield, Temperature


sensor, Arduino desktop software

Block Diagram:-

Code:
// Demo of Grove - Starter Kit V2.0

// Reads the value of the Grove - Temperature Sensor, converts it to a Celsius


temperature,
// and prints it to the serial console.
// Connect the Grove - Temperature Sensor to the socket marked A0
// Open the Serial Monitor in the Arduino IDE after uploading

// Define the pin to which the temperature sensor is connected.


const int pinTemp = A0;

// Define the B-value of the thermistor.


// This value is a property of the thermistor used in the Grove - Temperature
Sensor,
// and used to convert from the analog value it measures and a temperature
value.

29 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

const int B = 3975;

void setup()
{
// Configure the serial communication line at 9600 baud (bits per second.)
Serial.begin(9600);
}

void loop()
{
// Get the (raw) value of the temperature sensor.
int val = analogRead(pinTemp);

// Determine the current resistance of the thermistor based on the sensor


value.
float resistance = (float)(1023-val)*10000/val;

// Calculate the temperature based on the resistance value.


float temperature = 1/(log(resistance/10000)/B+1/298.15)-273.15;

// Print the temperature to the serial console.


Serial.println(temperature);

// Wait one second between measurements.


delay(1000);
}

Output:

30 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

31 | Page M.Tech.(ES) Sem-VI


EMBEDDED MICROCONTROLLER LAB FILE

32 | Page M.Tech.(ES) Sem-VI

You might also like