IoT Lab Manual
IoT Lab Manual
ACENAAR TECHNOLOGIES
IoT trainer Kit-MODEL-B
Welcome
The developments in Internet of Things (IoT) technology played a pivotal role in
spurring innovation and growth. It is a technological revolution and it is bringing
tremendous changes in socioeconomics. And it is occupying omni fields like home
automation, transport, agriculture and whatnot. IoT technology has demand for very huge
skillful manpower in near feature and apart from this, everyone needs to know about this
technology. As it is going to become the integral part of life. This technology fascinates
everyone to learn and use for self-empowerment and to utilize prospects of modern life
style of 21st century.
In the manual we are presenting programming procedure for resourceful
unequivocally designed IoT trainer kit. Special care is taken to keep instruction simple and
clear and yet cover utilization of all resources available in the kit.
In present manual we will focus on 20A05603P (JNTUA-CSE) IoT Lab Manual, which
gives information about getting started with Kit, and write Internet of Things (IoT) C++
programs for different resources of kit (Displays, Actuators, sensors and wireless
connectivity modules). At the end of the exercise, one will acquaint with kit and have
confidence to develop the IoT programs.
CONTENT
JNTUA-ATP: B.Tech. (CSE)-III-I 20A05603P – INTERNET OF THINGS LAB
s.no Experiments
ESP32 EXPERIMENTS……………………………………………………………………………………………………………
Experiment-1(b) Creating different LED patterns and controlling them using Push
button switches.
Experiment-1(c) Controlling servo motor with help of joystick.
Experiment-3(b) Basic Burglar alarm security system with the help of PIR sensor
and buzzer.
Experiment-3(c) Displaying humidity and temperature values on LCD.
Raspberry Pi EXPERIMENTS…………………………………………………………………………………………………..
EXPERIMENT-4(c) Advanced burglar alarm security system with help of PIR sensor,
buzzer and keypad.
EXPERIMENT-4(d) Automated LED light control based on input from PIR and LDR.
IoT Framework………………………………………………………………………………………………………………………
HTTP based…………………………………………………………………………………………………………………………
7 EXPERIMENT-7 (a) Introduction to HTTP, hosting a basic server from the ESP32 to
control various digital based actuator LED from a simple web-
page:
EXPERIMENT-7 ( b) Introduction to HTTP, Hosting a basic server from the ESP32 to
control various digital based actuator Buzzer from a simple web-
page:
EXPERIMENT-7 ( c) Introduction to HTTP, Hosting a basic server from the ESP32 to
control various digital based actuator Relay from a simple web-
page:
8 EXPERIMENT-8 Displaying various sensor readings on a simple web page hosted
on the ESP32:
MQTT based…………………………………………………………………………………………………………………………
UAV/Drone…………………………………………………………………………………………………………………………….
Appendices:
Appendix A: Esp32 board specifications.
Appendix B: Get fully acquainted with Raspberry pi and Thonny IDE.
Appendix C: Get fully acquainted with Blynk APP Installation.
This IoT Trainer kit is consisting Arduino Microcontroller, Raspberry Pi, sensors, activators, display
units and wireless connectivity modules in single board. It works with embedded C++ in open software
Arduino IDE.
Figure-8: Raspberry pi
Step-2: Connect one end of Micro USB cable to Esp32 board and other end connect to PERSONAL
COMPUTER or LAPTOP port USB-2.0/3.0.
STEP-3: Install Arduino IDE and libraries in PC/Laptop from software folder provided in CD
(windows OS is taken as reference in this entire guide). Or Install Arduino IDE from
https://www.arduino.cc/en/software
2.A new window pops up. Near the end, there is an option called “Additional Boards Manager URLs”. In
the space next to this option, paste the following URL and click on OK
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-
pages/package_esp32_index.json
4.In the search bar on the top, type “esp32” and hit enter. You will get a result saying “esp32 by Espressif
Systems”. Select this and click on install button. Arduino IDE will now download all the necessary files for
ESP32 like boards, tools, programmer etc., from the internet.
Make sure your computer has internet connectivity. This might take a minute or two. Once the
installation is successful, you can close the Boards Manager.
Step-6: for port selection Tools->Port-> com port for port selection.
STEP-5: To test the Esp32 and IDE installed, go to FILE -> example-> Basic -> Blink example.,
compile it and upload code by tap upload button. Observe Built-in LED Blinking on Esp32 board.
If you could see LED blinking on Esp32 board, congratulations you have Successfully installed IDE
and configured your board for programming.
Result:
Step-6: Install libraries (only once) as per the requirements of the experiment ( DHT-11 sensor,
LDC, 7segment, Wi-Fi, Keypad library,MQ135,TDS grove. Etc).
Note-1: Manually install USB-serial CH324 drivers for Arduino nano for Windows7 and 8.
Note-2: For further more information/ video content visit Acenaar Technology web site and
you tube channel.
Experiment-1
Controlling Actuators through serial monitor: Write C++
program for ESP32 Microcontroller to control Buzzer through serial
monitor
What is a Buzzer?
The pin configuration of the buzzer is shown below. It includes two pins namely positive and
negative. The positive terminal of this is represented with the ‘+’ symbol or a longer terminal.
This terminal is powered through 6Volts whereas the negative terminal is represented with the
‘-‘symbol or short terminal and it is connected to the GND terminal.
Experiment-
List of components
• Connect the micro-USB cable to the ESP-32 IOT module available on Acenaar IoT kit, and
UPLOAD the written C++ code using Arduino IDE.
• Connection of the peripherals: Connect the Buzzer module (C) to the ESP32 IoT Module
“GPIO”.
Sample Code-
/***************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32 Microcontroller to control
Buzzer through serial monitor *****************
* Experiment : Exp_01(a) *****************
* Connecting Wires : One 4 pin JST Connecting Wire *****************
* Connections : From ESP32 IoT Module “GPIO” to IoT Kit Buzzer (C). ******
**************************************************************************************************/
#define Buzzer 19
void setup() {
Serial.begin(9600);
pinMode(Buzzer, OUTPUT); // set the digital pin as output:
}
void loop() {
if (Serial.available())
{
String command = Serial.readStringUntil('\n');
int myInt = command.toInt();
Serial.println(myInt);
if (myInt== 1)
{
digitalWrite(Buzzer, HIGH); // turn on LED
Serial.println("Buzzer ON");
}
else if (myInt == 0)
{
digitalWrite(Buzzer, LOW); // turn off LED
Serial.println("Buzzer OFF");
}
}
}
Result-
Experiment-1(b)
Creating different LED patterns and controlling them using
Push button switches:
Write C++ program for ESP32 Microcontroller to display
different patterns using LEDs on Kit.
What Exactly is an LED?
An LED is a type of diode that turns electrical energy into light. Basically, an LED is an electrical
component that emits light when electricity flows through in one direction. LED is an acronym standing
for ‘Light Emitting Diode’. 5mm LEDs also run at much lower drive currents, maxing out at around 30mA.
LEDs emits the different colours. The symbol and model is given below.
Experiment-
List of components
About the Experiment - Here we control the 8 LEDS present on the kit by using the
Push buttons.
Sample Code-
/***************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32 Microcontroller to display
different patterns using LEDs on Kit. *****************
* Experiment : Exp_01(b) *****************
* Connecting Wires : One 4 pin, one - 10 port JST Connecting Wire*****************
* Connections : Esp-32 (LEDs) to Connector->logic(J) *****************
* Esp-32 (Keypad) to Connector -> keypad(M) ***************
Powered by AcenAAr Technology Pvt. Ltd. Kurnool
21
**************************************************************************************************/
#include <Keypad.h>
byte rowPins[ROWS] = {32, 33, 25, 26}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {27, 14, 12}; //connect to the column pinouts of the keypad
void setup() {
//Serial.begin(9600);
void loop() {
char key = keypad.getKey();
if (key){
Serial.println(key);
switch(key){
case '1':
allOn();
break;
case '2':
allOff();
break;
case '3':
allOff();
for(int ii = 1; ii <= 5;ii++)
blinkAll();
break;
case '4':
allOff();
for(int ii = 1; ii <= 5; ii++)
ledWalk();
break;
case '5':
allOff();
binaryCounter();
break;
}
}
}
void allOff()
{
for(int ii = 0;ii < 8; ii++){
//rightShiftValue = counterValue >> ii;
// extractLSB = rightShiftValue & 0x1;
//if(extractLSB == 1)
//digitalWrite(pins[ii], 0);
//else
digitalWrite(pins[ii], 1);
}
}
void allOn()
{
for(int ii = 0;ii < 8; ii++){
digitalWrite(pins[ii], 0);
}
}
void blinkAll()
{
for(int ii = 0;ii < 8; ii++){
digitalWrite(pins[ii], 1);
}
delay(500);
void ledWalk()
{
for(int ii = 0;ii < 8; ii++){
digitalWrite(pins[ii], 0);
delay(70);
}
for(int ii = 0;ii < 8; ii++){
delay(70);
digitalWrite(pins[ii], 1);
}
}
RESULT-
EXPERIMENT-1(c)
Controlling servo motor with help of joystick:
JOY STICK:
A joystick is an input device that can be used for controlling the movement of the cursor or a
pointer in a computer device. The pointer/cursor movement is controlled by a lever on the
joystick. The input device is mostly used for gaming applications and, sometimes, in graphics
applications. A joystick also can be helpful as an input device for people with movement
disabilities.
The joystick is mostly used when there is a need to perform a direct pointing or
when a precise function is needed. There are different types of joysticks such
as displacement joysticks, hand-operated joysticks, finger-operated joysticks,
thumb/fingertip-operated joysticks, hand-operated isometric joysticks, etc.
SERVO MOTOR:
The servo motor is an assembly of four things: a normal DC motor, a gear reduction unit, a
position-sensing device, and a control circuit The DC Servo motor is connected with a gear
mechanism that provides feedback to a position sensor which is mostly a potentiometer.
List of components
• Connect the micro-USB cable to the ESP-32 IOT module available on Acenaar IoT kit, and
UPLOAD the written C++ code using Arduino IDE.
• Connection of the peripherals: Connect the (X3) to the ESP-32 Module “ADC”.
Connect the Servo (A) to the ESP-32 Module “Ultrasonic”.
Sample code-
/***************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32 Microcontroller to control
servomotor using Joystick as INPUT device. *****************
* Experiment : Exp_01(c) *****************
* Connecting Wires : One 4 pin, JST Connecting Wire *****************
* Connections : Esp-32 (Ultra) to Connector servo(A) *****************
* Esp-32 (ADC) to Connector joystick(X3) *****************
***************************************************************************************************/
#define joyX 34
#define joyY 33
#include <Servo_ESP32.h>
Servo_ESP32 servo1;
int pos=0;
int xValue,yValue;
void setup() {
Serial.begin(115200);
Serial.println("Joy Stick in IDLE State");
servo1.attach(servoPin);
}
void loop()
{
xValue = analogRead(joyX);
yValue = analogRead(joyY);
Serial.print(xValue);
Serial.println(yValue);
delay(20);
Serial.println("Right!!!");
}
}
else if(xValue == 0 && yValue <= 3000)
{
Serial.println("Up!!!");
}
else if(xValue <= 400 && yValue ==4095)
{
for (pos = 0; pos <= 180; pos += 1)
{
servo1.write(pos);
delay(20);
Serial.println("Left!!!");
}
}
else if(xValue == 4095 && yValue == 4095){
Serial.println("Down!!!!");
}else{
Serial.println("Idle State");
}
delay(1000);
}
RESULT-
EXPERIMENT-2
Calculating distance to an object with help of an ultrasonic
sensor and display it on LCD:
Write C++ program for ESP32
Microcontroller to measure distance of an object with help of
Ultrasonic sensor and display it on LCD.
Ultrasonic:
This is a simple and easy to use ultrasonic sensor. It can detect objects Infront
of it within a range of 2-400cm. It is the perfect sensor to use in robotics,
obstacle detection, etc. It has a wide beam angle unlike IR Sensors, which
enables it to detect obstacles withing a wide angle. Signals can be read from
the 4-pin interface (Vcc, Trig, Echo, Gnd). One pin is used to trigger the
ultrasonic transmitter and another one is used to read the echo. This HC SR04
distance sensor offers both accuracy and stable readings that is not affected
by sunlight or object colour.
List of components
• Connect the micro-USB cable to the ESP-32 IOT module available on Acenaar IoT kit, and
UPLOAD the written C++ code using Arduino IDE.
• Connection of the peripherals: 1. Connect the Ultrasonic sensor (H) to the ESP32 IoT
Module "Ultrasonic".
2. From Acenaar IoT Kit Display Module(O) to ESP32 IoT
Module "LCD".
Sample code-
/***************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32 Microcontroller to
measure distance of an object with help
of Ultrasonic sensor and display it on LCD. **********
* Experiment : Exp_02 *****************
* Connecting Wires : Two 4 pin JST Connecting Wires *****************
* Connections : 1. From ESP32 IoT Module "Ultra"
to Acenaar IoT Kit Ultrasonic(H). ***********
* 2. From ESP32 IoT Module "LCD" to
Acenaar IoT Kit Display Unit(O). **********
***************************************************************************************************/
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3f, 16,2);
// defines variables
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement
void setup() {
lcd.init();
lcd.backlight();
pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
Serial.begin(9600); // // Serial Communication is starting with 9600 of baudrate speed
Powered by AcenAAr Technology Pvt. Ltd. Kurnool
32
}
void loop() {
// Clears the trigPin condition
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin HIGH (ACTIVE) for 10 microseconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (go and back)
// Displays the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
lcd.setCursor(0, 0);
lcd.print("Distance:");
lcd.setCursor(9,0);
lcd.print(distance);
lcd.setCursor(13,0);
lcd.print("CM");
delay(500);
lcd.clear();
}
RESULT-
EXPERIMENT-3(a)
Controlling actuators relay state based on ambient light level
using LDR sensor:
Write C++ program for ESP32 Microcontroller to
switch ON/OFF Relay based on ambient light intensity level
sensed using LDR sensor.
Relay:
Relays are most commonly used switching devices used in electronics. It can be used to switch
high current loads easily unlike transistors which are limited by the maximum current that can
flow through them and also can’t switch AC loads. This 5V 1A Relay
Module can switch both AC and DC loads. It is an Electromagnetic switch,
when the coil inside is energized with a small current, it can switch ON or
OFF the high current circuit. It has PCB screw terminals to directly
connect. They can be used in Home automation to switch ON or OFF the
appliances, in Electronic circuits to perform switching operations, in
safety circuits to disconnect or connect the heavy loads in case of any
dangerous situation, in Automobile applications like turning on
windscreen wipers, power windows fuel pump, cooling fan etc.
LDR sensor-
An LDR or light dependent resistor is also known as photo resistor, photocell, photoconductor. It
is a one type of resistor whose resistance varies depending on the amount of light falling on its
surface. When the light falls on the surface, then the resistance changes. When the LDR is in
darkness, then it can be used to turn ON a light or to turn OFF a light when it is in the light. A
typical light dependent resistor has a resistance in the darkness of 1 M Ohm, and in the brightness
a resistance of a couple of 1K Ohm. Symbol and example is given below.
Experiment-
• Connect the micro-USB cable to the ESP-32 IOT module available on Acenaar IoT kit, and
UPLOAD the written C++ code using Arduino IDE.
• Connection of the peripherals: 1. From ESP32 IoT Module “ADC” to Acenaar IoT Kit LDR(L)
2. From ESP32 IoT Module “GPIO” to Acenaar IoT Kit
RELAY(B)
3.from Esp32 IOT Module “LCD” to Acenaar IOT kit
Display unit (O)
Sample code-
/**************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32
Microcontroller to switch ON/OFF Relay
* based an ambient light intensity level
sensed using LDR sensor. *****************
* Experiment : Exp_03(a) *****************
* Connecting Wires : Two 4 pin JST Connecting Wires *****************
* Connections : 1. From ESP32 IoT Module “ADC”
to Acenaar IoT Kit LDR(L). **********
* 2. From ESP32 IoT Module “GPIO”
to Acenaar IoT Kit RELAY(B). ************
3. from Esp32 IOT Module “LCD”
to Acenaar IOT kit Display unit (O). ************
***************************************************************************************************/
#define Relay 19
#define LIGHT_SENSOR_PIN 34 // ESP32 pin GIOP36 (ADC0)
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16,2);
void setup() {
// initialize serial communication at 9600 bits per second:
lcd.init();
lcd.backlight();
Serial.begin(9600);
pinMode(Relay,OUTPUT);
}
void loop() {
// reads the input on analog pin (value between 0 and 4095)
int analogValue = analogRead(LIGHT_SENSOR_PIN);
RESULT-
EXPERIMENT-3(b)
Basic Burglar alarm security system with the help of PIR
sensor and buzzer:
Write C++ program to implement ESP32 based
Basic Burglar alarm security system with help of PIR sensor
and Buzzer.
Passive Infrared Sensor (PIR):
PIR sensors allow you to sense motion, almost always used to detect whether a human has
moved in or out of the sensors range. They are small, inexpensive, low-power, easy to use and
don't wear out. For that reason, they are commonly found in appliances and gadgets used in
homes or businesses. They are often referred to as PIR, "Passive Infrared", "Pyroelectric", or "IR
motion" sensors.
Experiment:
List of components
• Connect the micro-USB cable to the ESP-32 IOT module available on Acenaar IoT kit, and
UPLOAD the written C++ code using Arduino IDE.
• Connection of the peripherals: 1. From ESP32 IoT Module “ADC” to Acenaar IoT Kit PIR(G)
2. From ESP32 IoT Module “GPIO” to Acenaar IoT Kit
Buzzer(C)
Sample Code-
/***************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program to implement ESP32
based Basic Burglar alarm security system
with help of PIR sensor and Buzzer. ***************
* Experiment : Exp_03(b) ****************
* Connecting Wires : Two 4 pin JST Connecting Wires ****************
* Connections : 1. From ESP32 IoT Module “ADC” to
Acenaar IoT Kit PIR(G). **********
* 2. From ESP32 IoT Module “GPIO” to
Acenaar IoT Kit Buzzer(C). ************
***************************************************************************************************/
const int Buzzer =19; // the pin that the LED is atteched to
const int sensor = 34; // the pin that the sensor is atteched to
void setup() {
pinMode(Buzzer, OUTPUT); // initalize LED as an output
pinMode(sensor, INPUT); // initialize sensor as an input
Serial.begin(9600); // initialize serial
}
void loop(){
val = digitalRead(sensor); // read sensor value
Serial.println(val);
if (val == HIGH) { // check if the sensor is HIGH
digitalWrite(Buzzer, HIGH); // turn LED ON
Serial.println("Motion detected!");
delay(1000);
}
else {
digitalWrite(Buzzer, LOW);
Serial.println("Motion Not detected!");// turn LED OFF
delay(1000); // delay 200 milliseconds
}
}
Result-
EXPERMENT-3(c)
Displaying humidity and temperature values on LCD:
Write C++ program for ESP32
Microcontroller to measure humidity and temperature and
display on LCD.
DHT-11
The DHT11 is a commonly used Temperature and humidity sensor that comes with a dedicated
NTC to measure temperature and an 8-bit microcontroller to output the values of temperature
and humidity as serial data.
DHT11 Specifications
Applications
Experiment:
List of components
• Connect the micro-USB cable to the ESP-32 IOT Module available on Acenaar IoT kit, and
UPLOAD the written C++ code using Arduino IDE.
• Connection of the peripherals: 1. From Acenaar IoT Kit Display Unit(O) to ESP32 IoT
Module "LCD".
2. From ESP32 IoT Module "GPIO "to Acenaar IoT Kit "DHT
11"(I).
Sample Code-
/***************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32
Microcontroller to measure humidity
* and temperature and display on LCD. *****************
* Experiment : Exp_03(c) *****************
* Connecting Wires : Two 4 pin JST Connecting Wires *****************
* Connections :1. From Acenaar IoT Kit "Display Unit(O)" to
ESP32 IoT Module "LCD" **********
* 2. From ESP32 IoT Module "GPIO " to
Acenaar IoT Kit "DHT 11"(I). *************
***************************************************************************************************/
#include "DHT.h"
#define DHTPIN 19 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3f, 16,2);
void setup() {
lcd.init();
lcd.backlight();
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
dht.begin();
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
// Check if any reads failed and exit early (to try again).
if (isnan(humidity) || isnan(temperature) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
Serial.print(F("Humidity: "));
Serial.print(humidity);
Serial.print(F("% Temperature: "));
Serial.print(temperature);
Serial.println(F("°C "));
lcd.setCursor(0,0);
lcd.print("Temp");
lcd.setCursor(5,0);
lcd.print((char)223);
lcd.setCursor(6,0);
lcd.print("C");
lcd.setCursor(9,0);
lcd.print("Humi %");
lcd.setCursor(0,1);
lcd.print(temperature);
lcd.setCursor(9,1);
lcd.print(humidity);
}
Result-
EXPERIMENT-4 (a)
Controlling relay state based on input from IR:
Write Raspberry-Pi based Python program
to control relay state using IR sensor.
Experiment-
List of components
#*************************************************************************************************
#* AcenAAr Mini IoT Trainer Kit 2021 ********
#* Program Name : Write Raspberry-Pi based Python program to
#* control relay state using IR sensor. ********
#* Experiment : Exp_04(a) ********
#* Connector : two-4-pins JST cables ********
#* Connections : From RPI GPIO Board "j56" to IR (F) ********
#* From RPI GPIO Board “UART 2” to Relay (B). ********
#************************************************************************************************
import RPi.GPIO as IO
import time
IO.setwarnings(False)
IO.setmode(IO.BCM)
IRPin = 18
RelayOut= 14
IO.setup(IRPin, IO.IN) #GPIO 18 -> IR sensor as input
IO.setup(RelayOut, IO.OUT)
try:
while True:
if(IO.input(IRPin)==True):
print("Object is far away")
IO.output(RelayOut,IO.LOW)
print("Relay OFF")
elif(IO.input(IRPin)==False):
print("Object is near")
IO.output(RelayOut,IO.HIGH)
print("Relay ON")
time.sleep(1)
except KeyboardInterrupt: # Press 'Ctrl+C' To Stop The Program
GPIO.cleanup()
Result:
EXPERMENT-4(b)
Interfacing stepper motor with R-Pi:
Write Raspberry-Pi based Python program to
rotate stepper motor to different angles.
Experiment-
List of components
2. stepper stepper(A)
Sample code-
#**************************************************************************************************
#* AcenAAr Mini IoT Trainer Kit 2021 ********
#* Program Name :Write Raspberry-Pi based Python program
# to rotate stepper motor to different angles. ********
#* Experiment : Exp_04(b) ********
#* Connector : 10-pins JST cable ********
#* Connections : From RPI GPIO Board "colour" to
esp32 board (J21) ********
#*************************************************************************************************
IN1 = 4 # pin11
IN2 = 5
IN3 = 6
IN4 = 16
def stop():
setStep(0, 0, 0, 0)
setStep(0, 0, 0, 1)
time.sleep(delay)
def setup():
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM) # Numbers GPIOs by physical location
GPIO.setup(IN1, GPIO.OUT) # Set pin's mode is output
GPIO.setup(IN2, GPIO.OUT)
GPIO.setup(IN3, GPIO.OUT)
GPIO.setup(IN4, GPIO.OUT)
def loop():
while True:
print("backward...")
backward(0.003, 512) # 512 steps --- 360 angle
print("stop...")
stop() # stop
time.sleep(3) # sleep 3s
print("forward...")
forward(0.005, 512)
print("stop...")
stop()
time.sleep(3)
def destroy():
GPIO.cleanup() # Release resource
try:
loop()
except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the child function destroy() will
be executed.
destroy()
Result:
EXPERIMENT-4(c)
Advanced burglar alarm security system with help of PIR
sensor, buzzer and keypad:
Write Raspberry-Pi based Python program to
implement advanced Burglar Alarm with Buzzer Indication.
Use PIR sensor for person detection and key pad to accept
security code.
Experiment-
List of components
Sample code-
#**************************************************************************************************
#* AcenAAr Mini IoT Trainer Kit 2021 ********
#* Program Name : Write Raspberry-Pi based Python program to implement
# Advanced Burglar Alarm with Buzzer Indication.
# Use PIR sensor for person detection and key pad to
accept security code ********
#* Experiment : Exp_04(c) ********
#* Connector : two 4-pins JST cable ********
#* Connections : From RPI GPIO Board "j57" to IOT kit PIR (G) ********
#* From RPI GPIO Board “j58” to IOT kit Buzzer (C)
From RPI GPIO Board “Traffic” to IOT Kit Keypad(M). ***
#************************************************************************************************
Password = "111111"
Pass = ""
R1 = 6
R2 = 7
R3 = 8
R4 = 9
C1 = 10
C2 = 11
C3 = 12
GPIO.setup(Pir, GPIO.IN)
GPIO.setup(Buzzer, GPIO.OUT)
GPIO.setup(R1, GPIO.OUT)
GPIO.setup(R2, GPIO.OUT)
GPIO.setup(R3, GPIO.OUT)
GPIO.setup(R4, GPIO.OUT)
print("*",end='')
if(GPIO.input(C3) == 1):
Pass=Pass+characters[2]
print("*",end='')
GPIO.output(line, GPIO.LOW)
if len(Pass)==6:
if Pass==Password:
print("PassWord Matched")
Pass=""
GPIO.output(Buzzer,GPIO.LOW)
else:
print("Enter Currect PassWord")
Pass=""
try:
while True:
if(GPIO.input(Pir)==True):
GPIO.output(Buzzer,GPIO.HIGH)
readLine(R1, ["1","2","3"])
readLine(R2, ["4","5","6"])
readLine(R3, ["7","8","9"])
readLine(R4, ["*","0","#"])
time.sleep(0.2)
except KeyboardInterrupt:
GPIO.cleanup()
print("\nApplication stopped!")
Result:
EXPERIMENT-4(d)
Automated LED light control based on input from PIR
and LDR: Write Raspberry-Pi based Python program to
implement Automated LED light control system which can detect
presence of person and switch on light based on ambient light Use
PIR sensor for person detection and LDR for Ambient light
measurement.
Experiment-
List of components
Connection of the peripherals: 1. From RPI GPIO Board "j67" to IOT Kit PIR(G).
2. From RPI GPIO Board “j58” To IoT kit Relay(B).
#**************************************************************************************************
#* AcenAAr Mini IoT Trainer Kit 2021 ********
#* Program Name : Write Raspberry-Pi based Python program to
implement Automated LED light control system
which can detect presence of person and switch
on light based on ambient light Use light measurement. ****
#* Experiment : Exp_04(d) ********
#* Connector : 10-pins JST cable ********
#* Connections : 1. From RPI GPIO Board "j67" to IOT Kit PIR(G) ********
From RPI GPIO Board “j58” To IoT kit Relay(B) *******
#*************************************************************************************************
import spidev
import time
import os
import RPi.GPIO as IO
spi = spidev.SpiDev()
spi.open(0,0)
spi.max_speed_hz=1000000
IO.setwarnings(False)
IO.setmode(IO.BCM)
Pir = 8
Led1 =23
Led2 =22
IO.setup(Pir, IO.IN)
IO.setup(Led1, IO.OUT)
IO.setup(Led2, IO.OUT)
def ReadChannel(channel):
adc = spi.xfer2([1,(8+channel)<<4,0])
data = ((adc[1]&3) << 8) + adc[2]
return data
def ConvertVolts(data,places):
volts = (data * 3.3) / float(1023)
volts = round(volts,places)
return volts
light_channel = 0
while True:
if(IO.input(Pir)==True): #object is far away
print("Motion Detected")
Result-
EXPERIMENT-5
Upload humidity and temperature data to ThingSpeak,
periodically logging ambient level to ThingSpeak: Write C++
program for ESP32 Microcontroller to Upload humidity and
temperature data to ThingSpeak, periodically logging ambient level to
ThingSpeak.
Experiment
List of components
1. ESP-32 ESP-32
Sample code-
/***************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32 Microcontroller
to Upload humidity and temperature data
to Thingspeak, periodically logging ambient
level to ThingSpeak *****************
* Experiment : Exp_05 *****************
* Connecting Wires : One 4 pin JST Connecting Wire *****************
* Connections : From ESP32 IoT Module “GPIO” to
IoT Kit DHT 11 (I). *****************
***************************************************************************************************/
#include <WiFi.h>
#include "ThingSpeak.h"
#include "DHT.h"
WiFiClient client;
// Timer variables
unsigned long lastTime = 0;
unsigned long timerDelay = 30000;
float humidity;
//uncomment if you want to get temperature in Fahrenheit
//float temperatureF;
void readdht(){
if (isnan(humidity) || isnan(temperatureC) ) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
}
void setup() {
Serial.begin(115200); //Initialize serial
readdht();
dht.begin();
WiFi.mode(WIFI_STA);
void loop() {
if ((millis() - lastTime) > timerDelay) {
if(x == 200){
Serial.println("Channel update successful.");
}
else{
Serial.println("Problem updating channel. HTTP error code " + String(x));
}
lastTime = millis();
}
}
Result-
field-1-Temperature field-2-Humidity
EXPERIMENT-6(a)
Controlling LEDs using Blynk App:
Step-1: Configure Blynk App to send data from mobile phone to cloud
to control LEDs.
Step-2: Write C++ program for ESP32 Microcontroller to read cloud
data and control LEDs accordingly.
Features
• Similar API & UI for all supported hardware & devices
• Connection to the cloud using:
o WIFI
o Bluetooth and BLE
o Ethernet
o USB (Serial)
o GSM
o …
• Set of easy-to-use Widgets
• Direct pin manipulation with no code writing
• Easy to integrate and add new functionality using virtual pins
• History data monitoring via Super Chart widget
• Device-to-Device communication using Bridge Widget
• Sending emails, tweets, push notifications, etc.
• … new features are constantly added!
You can find example sketches covering basic Blynk Features. They are included in the library.
All the sketches are designed to be easily combined with each other.
Experiment-
List of components
Sample Code-
/***************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32
Microcontroller to read cloud data
* and control LEDs accordingly *****************
* Experiment : Exp_06(a) *****************
* Connecting Wires : One 4 pin JST Connecting Wire *****************
* Connections : From ESP32 IoT Module “LEDS” to
IoT Kit Logic(J). *****************
*************************************************************************************************/
#define BLYNK_TEMPLATE_ID "TMPLXgHEtqWL"
#define BLYNK_DEVICE_NAME "HomeAutomation"
#define BLYNK_AUTH_TOKEN "P7XtvyvnyjUxir5StLv-MvZKvwCr1wBj"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
BLYNK_CONNECTED()
{
Blynk.syncVirtual(V1);
}
BLYNK_WRITE(V1)
{
case 4:
digitalWrite(Leds[0], LOW);
digitalWrite(Leds[1], LOW);
digitalWrite(Leds[2], LOW);
digitalWrite(Leds[3], LOW);
digitalWrite(Leds[4], HIGH);
digitalWrite(Leds[5], HIGH);
digitalWrite(Leds[6], HIGH);
digitalWrite(Leds[7], HIGH);
break;
case 5:
digitalWrite(Leds[0], LOW);
digitalWrite(Leds[1], LOW);
digitalWrite(Leds[2], LOW);
digitalWrite(Leds[3], LOW);
digitalWrite(Leds[4], LOW);
digitalWrite(Leds[5], HIGH);
digitalWrite(Leds[6], HIGH);
digitalWrite(Leds[7], HIGH);
break;
case 6:
digitalWrite(Leds[0], LOW);
digitalWrite(Leds[1], LOW);
digitalWrite(Leds[2], LOW);
digitalWrite(Leds[3], LOW);
digitalWrite(Leds[4], LOW);
digitalWrite(Leds[5], LOW);
digitalWrite(Leds[6], HIGH);
digitalWrite(Leds[7], HIGH);
break;
case 7:
digitalWrite(Leds[0], LOW);
digitalWrite(Leds[1], LOW);
digitalWrite(Leds[2], LOW);
digitalWrite(Leds[3], LOW);
digitalWrite(Leds[4], LOW);
digitalWrite(Leds[5], LOW);
digitalWrite(Leds[6], LOW);
digitalWrite(Leds[7], HIGH);
break;
case 8:
digitalWrite(Leds[0], LOW);
digitalWrite(Leds[1], LOW);
digitalWrite(Leds[2], LOW);
digitalWrite(Leds[3], LOW);
digitalWrite(Leds[4], LOW);
digitalWrite(Leds[5], LOW);
digitalWrite(Leds[6], LOW);
digitalWrite(Leds[7], LOW);
}
void setup()
{
for(int ii = 0; ii < 8; ii++)
pinMode(Leds[ii], OUTPUT);
Serial.begin(9600);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
int wifi_ctr = 0;
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("WiFi connected");
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop()
{
Blynk.run();
}
Result-
EXPERIMENT-6(b)
Controlling Relay using Blynk App:
Step-1: Configure Blynk App to send data to Switch relay (ON/OFF)
from mobile phone to cloud.
Step-2: Write C++ program for ESP32 Microcontroller to read cloud
data and control Relay state accordingly
Experiment-
Sample Code-
/***************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32
Microcontroller to read cloud data
* and control Relay state accordingly *****************
* Experiment : Exp_06(b) *****************
* Connecting Wires : One 4 pin JST Connecting Wire *****************
* Connections : From ESP32 IoT Module “GPIO” to
IoT Kit Relay(B). *****************
***************************************************************************************************/
#define BLYNK_TEMPLATE_ID "TMPLXgHEtqWL"
#define BLYNK_DEVICE_NAME "HomeAutomation"
#define BLYNK_AUTH_TOKEN "P7XtvyvnyjUxir5StLv-MvZKvwCr1wBj"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
int Relay=19;
BLYNK_CONNECTED()
{
Blynk.syncVirtual(V0);
}
BLYNK_WRITE(V0)
{
void setup()
{
pinMode(Relay,OUTPUT);
Serial.begin(9600);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
int wifi_ctr = 0;
delay(500);
Serial.print(".");
Serial.println("WiFi connected");
void loop()
{
Blynk.run();
}
Result:
EXPERIMENT-6(c)
Controlling buzzer using Blynk App:
Step-1: Configure Blynk App to send data to Buzzer (ON/OFF) from
mobile phone to cloud.
Step-2: Write C++ program for ESP32 Microcontroller to read cloud
data and control Buzzer accordingly
Experiment-
List of components
Sample Code-
/***************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32
Microcontroller to read cloud data
* and control Buzzer accordingly *****************
* Experiment : Exp_06(c) *****************
* Connecting Wires : One 4 pin JST Connecting Wire *****************
* Connections : From ESP32 IoT Module “GPIO” to
IoT Kit Buzzer(C). *****************
***************************************************************************************************/
#define BLYNK_TEMPLATE_ID "TMPLXgHEtqWL"
#define BLYNK_DEVICE_NAME "HomeAutomation"
#define BLYNK_AUTH_TOKEN "P7XtvyvnyjUxir5StLv-MvZKvwCr1wBj"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
int Buzzer=19;
BLYNK_CONNECTED()
{
Blynk.syncVirtual(V0);
}
BLYNK_WRITE(V0)
{
void setup()
{
pinMode(Buzzer,OUTPUT);
Serial.begin(9600);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
int wifi_ctr = 0;
delay(500);
Serial.print(".");
Serial.println("WiFi connected");
void loop()
{
Blynk.run();
}
Result:
EXPERIMENT-7 (a)
Introduction to HTTP, hosting a basic server from the ESP32
to control various digital based actuator LED from a simple
web-page:
Write C++ program for ESP32 Microcontroller to configure it as
basic server to control LEDs, reading data from web page.
HTTP:
HTTP is abbreviated as Hypertext Transfer Protocol, an application layer protocol used primarily
with the WWW (World Wide Web) in the client-server model where a web browser is a client
communicating with the webserver which is hosting the website.
Architecture of HTTP
The basic block diagram of web application architecture which makes use of HTTP in it.
Web Client: The client of this client-server architecture asks for a request to a specific server
through the HTTP (TCP/IP connection) as a request method in the form of a URL. It also
contains a MIME-like message that contains request modifier and client information.
Web Server: This accepts the request and process with a response by a status line, together
with the version of the message's protocol as well as the success or error code, followed by a
MIME-like message having server information, some metadata, and possible the entity-body
content holding the requested information.
Features of HTTP
• HTTP is connectionless: An HTTP request is initiated by the browser (HTTP client) as per
the user's request for information. The server will process the request and launch back
with a response which the client waits for.
• HTTP is simple: HTTP/2 does the encapsulation of HTTP messages into frames; i.e., HTTP
is typically designed to be plain and human-readable.
Various HTTP methods (GET, POST, PUT, HEAD, DELETE, TRACE, OPTIONS, and CONNECT.) Are
explained below.
GET Method
The GET method is one of the most commonly used methods of HTTP. It is usually implemented
to request a particular resource data from the Web server by specifying the parameters as
a query string (name and value pairs) in the URL part of the request.
POST Method
The POST method is a commonly used HTTP method that sends data to the Web server in the
request body of HTTP. The various characteristics of the POST method are:
• The POST requests cannot be bookmarked as they do not appear in the URL.
PUT Method
The HTTP PUT request method is used to update existing resources with uploaded content or
to create a new resource if the target resource is not found. The difference between POST and
PUT is that PUT requests are static, which means calling the same PUT method multiple times
will not yield a different result because it will update the same content each time while POST
Request Will create new content each time.
HEAD Method
The HTTP HEAD method is almost identical to the GET method, but the only difference is that it
will not return any response body. For example, if GET/users return a record of users, then
HEAD/users make the same request, but it will not return any of the users' records.
DELETE Method
TRACE Method
The HTTP TRACE method is used for performing a message loop-back, which tests the path for
the target resource. It is useful for debugging purposes.
OPTIONS Method
HTTP OPTIONS method is used for describing the communication preferences for any target
resource.
CONNECT Method
HTTP CONNECT method is used for establishing a tunnel to the server recognized by a given
URI.
Experiment-
List of components
Sample Code-
/**************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32 Microcontroller
to configure it as basic server to control
LEDs, reading data from web page. ***************
* Experiment : Exp_07(a) *****************
* Connecting Wires : One 4 pin JST Connecting Wire *****************
* Connections : From ESP32 IoT Module “LEDS” to
IoT Kit Logic(J). *****************
***************************************************************************************************/
#include <WiFi.h>
WiFiServer server(80);
void setup() {
Serial.begin(115200);
// Set the pinmode of the pins to which the LEDs are connected and turn them low to
prevent flunctuations
for(int ii = 0; ii < 8; ii++)
pinMode(LedPin[ii], OUTPUT);
for(int ii = 0; ii < 8; ii++)
digitalWrite(LedPin[ii], LOW);
WiFi.begin(ssid, password);
Serial.print("Connecting to ");
Serial.println(ssid);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Print local IP address and start web server
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());// this will display the Ip address of the Pi which should be
entered into your browser
server.begin();
}
void loop(){
WiFiClient client = server.available(); // Listen for incoming clients
client.println("</body></html>");
Result:
EXPERIMENT-7 (b)
Introduction to HTTP, hosting a basic server from the ESP32
to control various digital based actuator Buzzer from a simple
web-page:
Write C++ program for ESP32 Microcontroller to configure it as
basic server to control Buzzer, reading data from web page.
Experiment-
List of components
• Connect the micro-USB cable to the ESP-32 IOT module. and UPLOAD the written C++
code using Arduino IDE.
• Connection of the peripherals: Connect the Buzzer(C) to the ESP-32 Module “GPIO”.
• For result search for to the particular IP address acquired form the result in serial monitor.
Sample Code-
/**************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32 Microcontroller
to configure it as basic server to control
Buzzer, reading data from web page. *****************
* Experiment : Exp_07(b) *****************
* Connecting Wires : One 4 pin JST Connecting Wire *****************
* Connections : From ESP32 IoT Module “GPIO” to
IoT Kit Buzzer(C). *****************
***************************************************************************************************/
#include <WiFi.h>
WiFiServer server(80);
void setup() {
Serial.begin(115200);
// Set the pinmode of the pins to which the LEDs are connected and turn them low to
prevent flunctuations
pinMode(BuzzerPin, OUTPUT);
digitalWrite(BuzzerPin, LOW);
WiFi.begin(ssid, password);
Serial.print("Connecting to ");
Serial.println(ssid);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Print local IP address and start web server
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());// this will display the Ip address of the Pi which should be
entered into your browser
server.begin();
}
void loop(){
WiFiClient client = server.available(); // Listen for incoming clients
client.println("</body></html>");
EXPERIMENT-7 (c)
Introduction to HTTP, hosting a basic server from the ESP32
to control various digital based actuator Relay from a simple
web-page:
Write C++ program for ESP32 Microcontroller to configure it as
basic server to control Relay stare, reading data from web page.
Experiment-
Here we control the Relay switch present IOT KIT by using the BLYNK app.
Sample Code-
/***************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32 Microcontroller
to configure it as basic server to control Relay
stare, reading data from web page *****************
* Experiment : Exp_07(c) *****************
* Connecting Wires : One 4 pin JST Connecting Wire *****************
* Connections : From ESP32 IoT Module “GPIO” to
IoT Kit Relay(B). *****************
***************************************************************************************************/
#include <WiFi.h>
WiFiServer server(80);
void setup() {
Serial.begin(115200);
// Set the pinmode of the pins to which the LEDs are connected and turn them low to
prevent flunctuations
pinMode(RelayPin, OUTPUT);
digitalWrite(RelayPin, LOW);
WiFi.begin(ssid, password);
Serial.print("Connecting to ");
Serial.println(ssid);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Print local IP address and start web server
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());// this will display the Ip address of the Pi which should be
entered into your browser
server.begin();
}
void loop(){
WiFiClient client = server.available(); // Listen for incoming clients
Serial.println("Relay OFF");
RelayState = "OFF";
digitalWrite(RelayPin, LOW);
}
client.println("</body></html>");
break;
} else { // if you got a newline, then clear currentLine
currentLine = "";
}
} else if (c != '\r') { // if you got anything else but a carriage return character,
currentLine += c; // add it to the end of the currentLine
}
}
}
// Clear the header variable
header = "";
// Close the connection
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
}
Result:
EXPERIMENT-8
Displaying various sensor readings on a simple web page hosted
on the ESP32:
Write C++ program for ESP32 Microcontroller to read sensor values
and display on web page
Experiment
List of components
Sample Code-
/***************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32 Microcontroller
to read sensor values and display on web page ********
* Experiment : Exp_08 *****************
* Connecting Wires : One 4 pin JST Connecting Wire *****************
* Connections : From ESP32 IoT Module “GPIO” to
IoT Kit DHT-11(I). *****************
**************************************************************************************************/
#include <WiFi.h>
#include <Wire.h>
#include "DHT.h"
// Uncomment one of the lines below for whatever DHT sensor type you're using!
//#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
#define DHTTYPE DHT11 // DHT 22 (AM2302), AM2321
//DHT Sensor;
#define DHTPin 19
DHT dht(DHTPin, DHTTYPE);
float Temperature;
float Humidity;
WiFiServer server(80);
String header;
void setup() {
Serial.begin(115200);
pinMode(DHTPin, INPUT);
dht.begin();
void loop()
{
Temperature = dht.readTemperature();
Humidity = dht.readHumidity();
WiFiClient client = server.available();
if (client)
{
Serial.println("Web Client connected ");
String request = client.readStringUntil('\r');
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
client.println("<!DOCTYPE html><html>");
client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-
scale=1\">");
Result:
EXPERIMENT-9(a)
Controlling actuators LEDs/Motors using android App:
Step-1: Develop MIT Android App to send digital data through
Bluetooth.
Step-2: Write C++ program for ESP32 Microcontroller to read digital
data from Bluetooth module and control LEDs accordingly.
About MIT APP
MIT App Inventor is an intuitive (Natural), visual programming environment that
allows everyone even children to build fully functional apps for smartphones and
tablets. Those new to MIT App Inventor can have a simple first app up and running
in less than 30 minutes. And what's more, our b locks-based tool facilitates the
creation of complex, high-impact apps in significantly less time than traditional
programming environments. The MIT App Inventor project seeks to democratize
software development by empowering all people, especially young p eople, to move
from technology consumption to technology creation .
App Inventor lets you develop applications for Android phones using a web browser and either
a connected phone or emulator. The App Inventor servers store your work and help you keep
track of your projects.
• The App Inventor Designer, where you select the components for your app.
• The App Inventor Blocks Editor, where you assemble program blocks that specify how the
components should behave. You assemble programs visually, fitting pieces together like
pieces of a puzzle.
Your app appears on the phone step-by-step as you add pieces to it, so you can test your work
as you build. When you're done, you can package your app and produce a stand-alone application
to install.
If you don't have an Android phone, you can build your apps using the Android emulator,
software that runs on your computer and behaves just like the phone.
The App Inventor development environment is supported for Mac OS X, GNU/Linux, and
Windows operating systems, and several popular Android phone models. Applications created
with App Inventor can be installed on any Android phone.
Experiment:
List of components
Step 1: Import the MIT app to the mobile which have been provide to you in the
document folder.
Sample Code-
/**************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32 Microcontroller
to read digital data from Bluetooth module
and control LEDs accordingly *****************
* Experiment : Exp_09(a) *****************
* Connecting Wires : One 4 pin JST Connecting Wire *****************
* Connections : From ESP32 IoT Module “LEDS” to
IoT Kit Logic(J). *****************
**************************************************************************************************/
#include <WiFi.h> // Para el ESP32
WiFiClient WIFI_CLIENT;
#include <PubSubClient.h>
PubSubClient MQTT_CLIENT;
void setup() {
for(int ii = 0; ii < 8; ii++)
pinMode(LedPin[ii], OUTPUT);
Serial.begin(115200);
delay(10);
Serial.println();
Serial.print("Connecting with ");
Serial.println(ssid);
WiFi.begin(ssid, password);
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("WiFi conected. IP: ");
Serial.println(WiFi.localIP());
// Setting Callback.
MQTT_CLIENT.setCallback(callback);
}
void loop() {
if (!MQTT_CLIENT.connected()) {
reconnect();
}
MQTT_CLIENT.loop(); // Check Subscription.
}
MQTT_CLIENT.setClient(WIFI_CLIENT);
Serial.println("Conected MQTT.");
}
Result:
EXPERIMENT-9(b)
Controlling AC appliances from an Android APP with the help
of relay:
Step-1: Develop MIT Android App to send digital data through
Bluetooth.
Step-2: Write C++ program for ESP32 Microcontroller to read digital
data from Bluetooth module and control Bulb using relay.
Experiment-
Step1: Import the MIT app to the mobile which have been provide to you in the document
folder.
Sample Code-
/***************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Write C++ program for ESP32 Microcontroller
to read digital data from Bluetooth module
and control Bulb using relay. *****************
* Experiment : Exp_09(b) *****************
* Connecting Wires : One 4 pin JST Connecting Wire *****************
* Connections : From ESP32 IoT Module “GPIO” to
IoT Kit Relay(B). *****************
***************************************************************************************************/
#include <WiFi.h> // Para el ESP32
WiFiClient WIFI_CLIENT;
#include <PubSubClient.h>
PubSubClient MQTT_CLIENT;
void setup() {
pinMode(LED2, OUTPUT);
Serial.begin(115200);
delay(10);
Serial.println();
Serial.print("Connecting with ");
Serial.println(ssid);
WiFi.begin(ssid, password);
Serial.println("");
Serial.print("WiFi conected. IP: ");
Serial.println(WiFi.localIP());
// Setting Callback.
MQTT_CLIENT.setCallback(callback);
}
void loop() {
if (!MQTT_CLIENT.connected()) {
reconnect();
}
MQTT_CLIENT.loop(); // Check Subscription.
}
MQTT_CLIENT.setClient(WIFI_CLIENT);
Serial.println("Conected MQTT.");
}
Result:
EXPERIMENT-10
Displaying humidity and temperature data on a web-based
application:
Experiment-
• Connect the micro-USB cable to the ESP-32 IOT module. and UPLOAD the written C++
code using Arduino IDE.
• Connection of the peripherals: Connect the DHT 11 (I) to the ESP-32 Module “GPIO”.
• For the result search for the broker.hivemq.com in the web page.
• Connect to the server as typing the port number and then type the subscribe topic and
click on subscribe.
Sample Code-
/***************************************************************************************************
* Acenaar IoT Trainer Kit *****************
* Program Name : Displaying humidity and temperature data
on a web-based application: *****************
* Experiment : Exp_10 *****************
* Connecting Wires : One 4 pin JST Connecting Wire *****************
* Connections : From ESP32 IoT Module “GPIO” to
IoT Kit DTH 11 (I). *****************
***************************************************************************************************/
#include <WiFi.h>
#include <PubSubClient.h>
#include <SPIFFS.h>
#include "DHT.h"
#define DHTPIN 19
WiFiClient espClient;
PubSubClient client(espClient);
int temperature;
int humidity;
void readdht(){
if (isnan(humidity) || isnan(temperature) ) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
}
void setup_wifi() {
delay(10);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
randomSeed(micros());
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Create a random client ID
String clientId = "ESP8266Client-";
clientId += String(random(0xffff), HEX);
// Attempt to connect
if (client.connect(clientId.c_str())) {
Serial.println("connected");
// Once connected, publish an announcement...
client.publish("AcenAAr/outTopic", msg);
// ... and resubscribe
client.subscribe("inTopic");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}
void setup() {
Serial.begin(115200);
setup_wifi();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
}
void loop() {
if (!client.connected()) {
reconnect();
}
client.loop();
/* Serial.print(F("Temperature: "));
Serial.print(Temp);
Serial.println(F("°C"));
Serial.print(F("Humidity: "));
Serial.print(Humi);
Serial.println(F("%"));
*/
client.publish("AcenAAr/outTopic",msg);
}
delay(1000);
}
Result:
Appendix A:
ESP 32 Specifications
The ESP32 development boards come with so many versions, pinouts, shapes, etc. In this article,
we are going to see the pinout diagram of ESP32 30-pin Devkit development board. It has a 48
pin QFN (Quad Flat No Leads) package microcontroller IC. As this is a No leads IC, so it is very
difficult to solder manually on a board. So the developer made a module using this
microcontroller is called ESP-WROOM-32. So the ESP 32 development board consists of ESP-
WROOM-32 as the baseboard. This ESP-WROOM-32 IC contains 4 MB SPI Flash memory IC and a
40MHz Crystal Oscillator, PCB Antenna, etc.
As the ESP32 board consists of a 4 MB flash memory to store its primary program, some GPIO
pins are directly connected to this flash memory. So these pins are can be used only for the
programming of the board, these pins are cannot be used for other functions.
Here, you can see the pinout diagram of ESP32 Devkit Development Board.
You can see each of the pins of this board has multiple functions. Each function is clearly noted
with different colors. Now we will discuss about these functions with respective pins to
understand how to and which pins should be used.
GPIO means General Input and Output. In the 30 pin ESP32 board, 25 GPIO pins are available to
connect with external circuits. It also has some other GPIO pins that are connected internally with
some ports and ICs. The GPIO pins are also used for other functions such as ADC, DAC, RTC, etc.
But, only one function work at a time. So, we can configure the GPIO pin as an ADC or a UART in
the program. You can see in the above diagram, the pin no 2 to 13 and pin no 18 to 30 have GPIO
functions.
ADC means Analog to Digital Converter. The ADC pins help to connect external analog devices
and components with this board. So, it can measure analog voltage, current. These ADC pins are
also be used in the sleep mode for low power consumption. The pin no 2 to 13 and 18 to 20 have
ADC functions.
DAC means Digital to Analog. Digital to Analog or DAC helps to convert the digital signal into an
analog signal. These are used for analog output purposes. These pins are comes in the use for
voltage control, PWM control, etc. The GPIO 25 and 26 or pin no 8 and 9 have DAC functions.
PWM means Pulse Width Modulated. There is a difference signal normal digital signal and pulse
width modulated or PWM signal although they look like same. The digital signal has a constant
or fixed time period and frequency whereas PWM signal has variable time period and frequency.
The PWM function comes for very useful applications such as motor control or variable load
controls. In the ESP32 board, almost all the pins are PWM enabled except pin no 1, 14, 15, 16,
17.
The 30 pin ESP32 board has 9 numbers touch sensor pins. The pin no 6, 7, 11, 12, 13, 18, 19, 20
the touch sensor pins. These pins are can be used to implement a capacitive touch sensor or
touchpad without any external hardware.
Appendix B:
Get fully with acquainted Raspberry pi and Thonny IDE.
To start the IoT programming with IoT trainer kit you need to follow step by step procedure which
is given below.
STEP-1: power on the Raspberry pi by connecting the c-type power adopter to c-type power
connector and wait for 1 min for boot loading.
Step -2.1 : Go to Wifi settings and click the change adaptor options
Step -2.3:Enter onto the WIFI PROPERTIES and go to the SHARING tab and mark the allow other
network to connect through computer’s internet connection
Step –2.4:
• Connect the your windows host system ethernet connector to the acenaar raspberry pi
Powered by AcenAAr Technology Pvt. Ltd. Kurnool
127
Step – 2.5: Download or copy the VNC viewer from software folder into the given CD and
launch VNC Viewer.
Step – 2.6: Select New connection from the File menu.
Step – 2.7: Enter Raspberry PI IP address 192.168.137.225 in the "VNC Server" field and click
ok button.
Step – 2.9: Enter the Pi's username and password when prompted. The defaults are
username: pi and password: acenaar@123. Click Ok.
Your Raspberry Pi desktop will then appear in a window on your main computer's desktop.
You'll be able to control everything from there.
STEP-3: click on the MENU bar > open PROGRAMING > open Thonny IDE.
STEP-4: Write your Python programming in Thonny IDE (all programs will be available in the
JNTUA_ATP folder).
Appendix C:
Get fully acquainted with Blynk APP Installation.
To start the IoT programming with IoT trainer kit you need to follow step by step procedure which
is given below. (Skip Step-1 to step-6 if already done in level-1)
STEP-7: IoT program on Basic IoT trainer kit-2022: Go to your favourite browser and paste the
following URL https://blynk.cloud/dashboard/register and complete the following procedure given
below.
Step-8: In Your Mobile, search for Blynk IoT App in Google App store and install it and follow the
steps given below figures.
Click here