Nothing Special   »   [go: up one dir, main page]

Iot Lab Manual 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 81

Experiment number:

Date:
1. Controlling actuators through Serial Monitor. Creating different led patterns and controlling them

Using push button switches.

AIM: Controlling actuators through Serial Monitor. Creating different led patterns and controlling them

Using push button switches.

Description:

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.
list of components:
Sno Component Description Port Names Board

1. Arduino nano Arduino Control unit


Development
board

2. LDR Sensor Light Dependent LDR


(L) Resistor

3. connecting wires one - 4 port


JST connecting wire

procedure:

a. Connect the micro-USB cable to the Arduino Nano in the Acenaar kit, and UPLOAD the
written C++ code using Arduino IDE.
b. Connection of the peripherals: Connect the LDR module (L) to Control unit (4) using the 4
pinJST connector .
c. Check the Analog Sensor LDR values in Serial Monitor of Arduino IDE.

Sample Code:

int sensorPin=A0; // select theinput pinfor LDR


int sensorValue=0; // variabletostorethevaluecomingfromthesensor

1
Experiment number:

Date:

voidsetup() {
Serial.begin(9600);
}
voidloop() {
sensorValue=analogRead(sensorPin);
Serial.print(sensorValue); //printsthevaluescomingfromthesensor onthescreen

if(sensorValue<200) //settinga thresholdvalue

Serial.println(" LowLight Intensity");

else
Serial.println(" High Light Intensity");

delay(1000);
}

2
Experiment number:

Date:

OUTPUT:

Off state- high intensity

Result:

3
Experiment number:

Date:
2. Calculate the distance to an object with the help of an ultrasonic sensor and display it on an LCD

Aim: Calculate the distance to an object with the help of an ultrasonic sensor and display it on an LCD

Description: The IR Sensor Module or infrared (IR) sensor is a basic and most popular sensor in
electronics. It is used in wireless technology like remote controlling functions and detection of
surrounding objects/ obstacles. IR sensors mainly consist of an Infrared(IR) LED and a Photodiode, this
pair is generally called IR pair. An IR LED is a special purpose LED, it emits infrared rays ranging from
700 nm to 1 mm wavelength. These types of rays are invisible to our eyes. In contrast, a photodiode or
IR Receiver LED detects the infrared rays. Example is shown below.

list of components

Sno Component Description Port Names Board

1. Arduino nano Arduino Nano Control unit


Development
board

2. IR Sensor IR sensor with LM 393 IR


(F) module

3. connecting wires one - 4 port


JST
4
Experiment number:

Date:

procedure:

 Connect the micro-USB cable to the Arduino Nano. And UPLOAD the C++ code using
Arduino IDE.
 Connection of the peripherals.: Connect the IR sensor module(F) to the control unit (6) using the4
pin JST connecting wires.
 Check the Digital Sensor of IR sensor values in Serial Monitor of Arduino IDE

Sample Code

int IRPin=10;
int hasObstacle=LOW; //LOWMEANSNOOBSTACLE

voidsetup() {
pinMode(IRPin,INPUT);
Serial.begin(9600);
}

voidloop() {
hasObstacle=digitalRead(IRPin);

if(hasObstacle==HIGH)
Serial.println("Object Not Detected");

else{
Serial.println("Object Detected");
}
delay(200);
}

5
Experiment number:

Date:

OUTPUT:

Result:

6
Experiment number:

Date:

.
03 Controlling relay state based on ambient light levels using LDR sensor.

AIM : Controlling relay state based on ambient light levels using LDR sensor.

An audio signalling device like a beeper or buzzer may be electromechanical or piezoelectric type. The main
function of this is to convert the electrical signal to sound. Generally, it is powered through DC voltage and
used in timers, alarm devices, printers, computers, etc.

The pin configuration of the buzzer is shown above. 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.

List of components:

Sno Component Description Port Names Board

1. Arduino Nano Arduino Nano Control unit


Development
board

2 Buzzer Sound Buzzer Buzzer


7
Experiment number:

Date:

3. Bluetooth Module HC-05 HC-05 module (E)


Bluetooth Module

4. Connecting wires Two - 4 port


JST connecting
wires

Procedure:

Connect the micro-USB cable to the Arduino Nano in the kit, and UPLOAD the written C++ code using Arduino
IDE. (Note: ENSURE Connector – 11 is removed on Control unit while uploadingthe code. Instal HC-05
module libraries.)

• Connection of the peripherals: Connect the Buzzer module (C) to control unit (7).
• Connect the HC-05 module(E) to control unit (06).
#include<SoftwareSerial.h>
int bluetoothTx =10; // bluetoothtx to10 pin
int bluetoothRx =11; // bluetoothrx to11 pin
int Buzzer=8;
int value=0;
SoftwareSerialbluetooth(bluetoothTx,bluetoothRx);

voidsetup()
{
Serial.begin(9600); // set thebaudrateto9600, sameshouldbeof your Serial Monitor
bluetooth.begin(9600);
pinMode(Buzzer,OUTPUT);
delay(100);
}

voidloop()
{

if(bluetooth.available()>0 ) // receivenumber frombluetooth


{
value=bluetooth.read(); // savethereceivednumber tostate
value=value-48;
Serial.println(value);
}

8
Experiment number:

Date:
if (value==0) // LOWvaluecommunicatedby bluetoothmodule
{
digitalWrite(Buzzer, LOW); //BuzzerisswitchedOFF
Serial.print(" Buzzer OFFstate");
}elseif (value==1) //HIGHvaluecommunicatedby bluetoothmodule
{
digitalWrite(Buzzer,HIGH); // Buzzer isturned ON
Serial.print(" Buzzer ONstate");
}
delay(100);
}

OUTPUT:

Buzzer Off State

Input: When we enter the ‘0’ value in bluetooth terminal app then we get the result as

9
Experiment number:

Date:

OUTPUT:

Result:

10
Experiment number:

Date:
B . Basic Burglar alarm security system with the help of PIR sensor and buzzer.

Based on the width of the pulse, the position of the servo motor varies. There are several ways in which
we can generate the PWM Signal to control a Servo Motor. The traditional way is to use fully analog
circuits like the 555 Timer IC and using a potentiometer to control the width of the pulse. But with the
help of microcontrollers like Arduino (ATmega328 to be precise), you can generate PWM
Signals without any external components.

The main concept of the Bluetooth Controlled Servo Motor using Arduino project is very simple. Control
the Servo Motor using PWM Signals generated by Arduino. The inputs to the Arduino are given from an
Android Smart Phone over Bluetooth Communication in terms of angles for servo motor.

List of components:

Sno Component Description Port Names Board

1. Arduino Nano Arduino Nano Control unit


Development
board

2. Servo Motor Servo SG-90 Three pins to


digital lines

3. Bluetooth Module HC-05 HC-05 module (E)


Bluetooth Module

4. connecting wires Two - 4 port


JST connecting
wires

11
Experiment number:

Date:

procedure:
connect the micro-USB cable to the Arduino Nano in the kit, UPLOAD the written C++ code using
Arduino IDE. (Note: ENSURE to Remove connection on Connector – 11 in Control unitwhile
uploading the code.), also make sure you already installed the respected libraries.
• Connection of the peripherals: Connect the Servo motor pin to pins as following format.

S.No Colour Pins

1 Brown colour GND

2 RED colour 5Vots

3 Yellow colour PWM

• Connect the HC-05 module(E) to control unit (6) and servo motor –(A) to control unit (10).
Sample code:

#include <SoftwareSerial.h>
include <Servo.h>
Servo myservo;
SoftwareSerial Bluetooth(10, 11);
void setup()
{
myservo.attach(3);
Bluetooth.begin(9600);
Serial.begin(9600);
Serial.print(" Welcome To\n");
Serial.print("AcenAArTechnology\n");
delay(5000);
}

void loop() {
if(Bluetooth.available())
{
char Angle = Bluetooth.read();
Serial.println(Angle);
Angle=Angle-48;
if(Angle==1)
{
myservo.write(0);
Serial.print(" 0 degree ");

12
Experiment number:

Date:
}
else if(Angle==2)
{
myservo.write(45);
Serial.print(" 45 degree ");
}
else if(Angle==3)
{
myservo.write(90);
Serial.print(" 90 degree ");
}
else if(Angle==4)
{
myservo.write(135);
Serial.print(" 135 degree ");
}
else if(Angle==5)
{
myservo.write(180);
Serial.print(" 180 degree ");
}
}
}

13
Experiment number:

Date:

OUTPUT:

Result:

14
Experiment number:

Date:
c. Displaying humidity and temperature values on LCD

List of components:

Sno Component Description Port Names Board

1. Arduino nano Arduino Nano Control unit


Development
board

2. Wi-Fi Module ESP 8266 ESP-01 module (D)


Wi-Fi Module

3. Ultra-Sonic Sonic Sensor ULTRA


SONIC Sensor HC SRO4 SENSOR(H)

4. connecting wires one - 4 port & one 10 port JST


connecting wires

Procedure:
• Connect the micro-USB cable to the Arduino Nano in the kit, and UPLOAD the written C++
codeusing Arduino IDE. (Note: ENSURE Connector – 11 is Remove on Connector – 11
while uploading the code.)
• Connection of the peripherals: Connect the ultrasonic module (H) to control unit (8).
• Connect the Wi-Fi module(D) to control unit (11).

15
Experiment number:

Date:

Sample code:

include<WiFiEsp.h>
include<WiFiEspUdp.h>
include<NewPing.h>

char ssid[] ="AcenAAr"; // your network SSID(name)


char pass[] ="123456789"; // your network passwordint
status=WL_IDLE_STATUS; // the Wifi radio'sstatus

unsignedint localPort =9001; // local port tolistenon


char serverAddress[] ="192.168.43.141"; // buffer toholdincomingpacket
char ReplyBuffer[] ="ACK"; // a stringtosendback
const int NTP_PACKET_SIZE=255; // NTPtimestampisinthefirst 48bytesof themessage const
int UDP_TIMEOUT=2000;
charpacketBuffer[NTP_PACKET_SIZE];
WiFiEspUDPUdp;

defineTRIGGER_PIN 7 // Arduinopintiedtotrigger pinontheultrasonic sensor.


defineECHO_PIN 6 // Arduinopintiedtoechopinontheultrasonic sensor.
defineMAX_DISTANCE300 // Maximumdistancewewant topingfor (incentimeters).
Maximumsensor distanceisratedat 400-500cm.
NewPingsonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
voidsetup() {
Serial.begin(19200); // If not connectedchangebaudrate115200
WiFi.init(&Serial);
//if (WiFi.status() ==WL_NO_SHIELD){
//Serial.println("WiFi shieldnot present");
// don't continue:
// while(true);
//}
while(status!=WL_CONNECTED){
Serial.print("Attempting toconnect toWPASSID: ");
Serial.println(ssid);
// Connect toWPA/WPA2network
status=WiFi.begin(ssid, pass);
}
Serial.println("Connectedtowifi");
//printWifiStatus();
Serial.println("\nStartingconnectiontoserver...");
Udp.begin(localPort);
Serial.print("Listeningonport "); Serial.println(localPort);
}
voidloop() { sendToServer(serverAddress);
16
Experiment number:

Date:
unsignedlongstartMs=millis();
while(!Udp.available() &&(millis() -startMs) <UDP_TIMEOUT)
{} int packetSize=Udp.parsePacket();
Serial.println(packetSize); if
(packetSize) {
Serial.print("Receivedpacket of size");
Serial.println(packetSize);
Serial.print("From");
IPAddressremoteIp=Udp.remoteIP();
Serial.print(remoteIp);
Serial.print(", port ");
Serial.println(Udp.remotePort());
int len=Udp.read(packetBuffer, 255); if
(len>0) {
packetBuffer[len] =0;
}
Serial.println("Contents:");
Serial.println(packetBuffer);
Udp.beginPacket(Udp.remoteIP(),Udp.remotePort());
Udp.write(ReplyBuffer);
Udp.endPacket();
}
//Udp.write("HellofromAcenAArBoard");delay(500);
}
voidsendToServer(char*ntpSrv){memset(packetBuffer,
0, NTP_PACKET_SIZE);
sprintf(packetBuffer, "Distanceincm:%d", sonar.ping_cm());
//strcpy(packetBuffer,"HellofromAcenAArUDPClient");
Udp.beginPacket(ntpSrv, 9001);
Udp.write(packetBuffer,strlen(packetBuffer)+1);
Udp.endPacket();
}

17
Experiment number:

Date:

output:

Result:

4. Controlling relay state based on input from IR sensors


18
Experiment number:

Date:
Aim: Controlling relay state based on input from IR sensors

• ThingSpeak is IoT Cloud platform where you can send sensor data to the cloud. You can also
analyze and visualize your data with MATLAB or other software, including making your own
applications.
• The ThingSpeak service is operated by MathWorks. In order to sign up for ThingSpeak, you must
create a new MathWorks Account or log in to your existing MathWorks Account.
• ThingSpeak is free for small non-commercial projects.
• ThingSpeak includes a Web Service (REST API) that lets you collect and store sensor data in the
cloud and develop Internet of Things applications. It works with Arduino, Raspberry Pi and
MATLAB (premade libraries and APIs exists) But it should work with all kind of Programming
Languages, since it uses a REST API and HTTP.

ThingSpeak Basics and account setup

Step 1: visit the site Thinkspeak

URL : https://thingspeak.com/

Thinkspeak environment is shown in below image

If you do not have a ThingSpeak account create one. Once you have a ThingSpeak account
login to your account.

19
Experiment number:

Date:
Step 2 : Create a new Account if you don’t have any, by clicking on the button “create one” as shown in below

image.

Create MathWorks Account by entering the below details and select the time zone.

20
Experiment number:

Date:
Step 3: Link your Matlab account to your thinkspeak if don’t have create one.

After entering your Email ID account, login in your EMAIL and click on “submit”.

Create a password for your thinkspeak Account.

Step 4: Create a new channel by clicking on the button as shown in below image - A channel is the
space for your data. Where you can store and retrieve data. A channel can have maximum 8 fields. It
means you can store 8 different data to a channel.

21
Experiment number:

Date:

Step 5: Enter basic details of the channel, here we are creating channel to store data from one sensor
so we need only one field.

22
Experiment number:

Date:
And click on the “save channel” as shown in the below image.

Channel Id is the identity of your channel. Note down this ID, this ID used in the code for data
communication.

23
Experiment number:

Date:
Step 6: API Keys API ( Application Programming Interface ) keys are the keys to access to your
channel. In simple language you can understand that these are password to access your channel.
You can access your channel in two ways

1. To update channel / data logging: API Write Key will be used to access in this mode.

2. To retrieve data: API Read Key will be used to access in this mode. Click on the API tab to know your
keys.

b. Interfacing stepper motor with R-Pi


List of components
Sno Component Description Port Names Board

1. Arduino nano Arduino Nano Control unit


Development
board

2. LDR Sensor Light Dependent LDR


(L) Resistor

24
Experiment number:

Date:

3. Wi-Fi Module ESP 8266 ESP-01 module (D)


Wi-Fi Module

4. connecting wires one - 4 port & one 10 port JST


connecting wire

procedure:

Here we measure the light intensity values using LDR sensor that is available on the Acenaar
IOT trainer kit and push this values into the cloud (think speak cloud).
We display the light intensity values using the fields of Thinkspeak cloud, light intensity values are
represented in a graph format and we will use the lamp widget to show status.

• Connect the micro-USB cable to the Arduino Nano in the Acenaar kit, and UPLOAD the
written C++ code using Arduino IDE. (Note: ENSURE Connector – 11 is removed on
Control unit whileuploading the code.)
• Connection of the peripherals: Connect the LDR module (L) to the control unit (4) using the 4
pin JST connecting wires.
• Connect the ESP module(D) to the control unit (8) using the 4 pin jst connecting wires in the
Acenaar IOT kit.

Sample Code:

include"WiFiEsp.h"
include"secrets.h"
include "ThingSpeak.h" // alwaysincludethingspeak header file
after other header filesand custommacros

char ssid[] =SECRET_SSID; // your network SSID(name)


char pass[] =SECRET_PASS; // your network password
int keyIndex =0; // your network key Index number(neededonly for WEP)
WiFiEspClient client;

// EmulateSerial1 onpins6/7if not presentifndef


HAVE_HWSERIAL1
include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX,
TX defineESP_BAUDRATE19200
else
25
Experiment number:

Date:
defineESP_BAUDRATE115200
endif

unsignedlongmyChannelNumber=SECRET_CH_ID;const
char *myWriteAPIKey =SECRET_WRITE_APIKEY;

int number =0;


const char ldrPin=A0;

voidsetup() {
Serial.begin(115200); //Initializeserial
while(!Serial){
; // wait for serial port toconnect. Neededfor LeonardonativeUSBport only
}

// initializeserial for ESPmodule


setEspBaudRate(ESP_BAUDRATE);

while(!Serial) {
; // wait for serial port toconnect. Neededfor LeonardonativeUSBport only
}

Serial.print("Searchingfor ESP8266...");
// initializeESPmodule
WiFi.init(&Serial1);

// check for thepresenceof theshield if


(WiFi.status() ==WL_NO_SHIELD) {
Serial.println("WiFi shieldnot present");
// don't continue
while(true);
}
Serial.println("foundit!");

ThingSpeak.begin(client); // InitializeThingSpeak
}

voidloop() {

// Connect or reconnect toWiFi


if(WiFi.status()!=WL_CONNECTED){
Serial.print("Attempting toconnect toSSID: ");
Serial.println(SECRET_SSID);
while(WiFi.status()!=WL_CONNECTED){
WiFi.begin(ssid, pass); // Connect toWPA/WPA2network.
Changethislineif usingopenor WEPnetwork
Serial.print(".");
delay(5000);
}
26
Experiment number:

Date:
Serial.println("\nConnected.");
}

int ldrValue=analogRead(ldrPin);

// WritetoThingSpeak. Thereareupto8fieldsina channel, allowingyoutostoreupto8different


// piecesof informationina channel. Here, wewritetofield 1.
int x=ThingSpeak.writeField(myChannelNumber, 1, ldrValue, myWriteAPIKey);if(x
==200){
Serial.println("Channel updatesuccessful.");
}
else{
Serial.println("Problemupdatingchannel. HTTPerror code" +String(x));
}

delay(20000); // Wait 20secondstoupdatethechannel again


}

// Thisfunctionattemptstoset the ESP8266 baudrate. Boardswithadditional hardwareserial ports


// canuse115200, otherwisesoftwareserial islimitedto19200. voidsetEspBaudRate(unsignedlongbaudrate){
longrates[6] ={115200,74880,57600,38400,19200,9600};

Serial.print("SettingESP8266 baudrateto");
Serial.print(baudrate);
Serial.println("...");

for(int i =0; i <6; i++){


Serial1.begin(rates[i]);
delay(100);
Serial1.print("AT+UART_DEF=
");Serial1.print(baudrate);
Serial1.print(",8,1,0,0\r\n");
delay(100);
}

Serial1.begin(baudrate);
}

Secrets-

// Usethisfiletostoreall of theprivatecredentials
// andconnectiondetails

defineSECRET_SSID"ACENAARTECHNOLOGY" // replaceMySSIDwithyour WiFi network name


defineSECRET_PASS"123456789" // replaceMyPasswordwithyour WiFi password

defineSECRET_CH_ID1581760 // replace0000000 withyour channel numberdefin

27
Experiment number:

Date:

OUTPUT:

To create lamp widget-

28
Experiment number:

Date:
off state lamp for 501 value.

On state lamp for 76 value (less than 100).

Result:

29
Experiment number:

Date:

C. Advanced burglar alarm security system with the help of PIR sensor
The ESP 01 ESP8266 Serial WIFI Wireless Transceiver Module is a self-contained SOC with
integrated TCP/IP protocol stack that can give any microcontroller access to your Wi-Fi network. Each
ESP8266 module comes pre- programmed with an AT command set firmware. This module has a
powerful enough on-board processing and storage capability that allows it to be integrated with the
sensors and other application-specific devices through its GPIOs with minimal development up-front
and minimal loading during runtime.

List of components:
Sno Component Description Port Names Board

1. Arduino Nano Arduino Nano Control unit


Development
board

2 Buzzer Sound Buzzer Buzzer

3. Wi-Fi Module ESP 8266 ESP-01 module (D)


Wi-Fi Module

4. Connecting wires Two - 4 port


JST connecting
wires

Procedure:

• We are controlling the buzzer through cloud


• The process for controlling actuator is given in step-2.
• We push (WRITE) values using browser with API key of ThingSpeak cloud, and these values are READ
by the Arduino Board to active the buzzer.

30
Experiment number:

Date:

Step 1:

 Connect the micro-USB cable to the Arduino Nano in the kit, and UPLOAD the written C++
codeusing Arduino IDE. (Note: ENSURE Connector – 11 is REMOVED on Control unit
while uploading the code.)
 also make sure you already installed the ESP-01 libraries.
 Connection of the peripherals: Connect the buzzer (C) to the control unit (7)
 Connect the ESP-01 module(D) to control unit (8) in the Acenaar IOT kit.

Step 2:

 Ensure first, both Arduino nano board and Personal Computer should be
connected to same local network.
 Create account in ThingSpeak and create new channel ( ignore if done in
previous experiment, use same account and create new channel for controlling)
 Note API READ and WRITE keys , which has to be place/change in code.
 Copy write channel feed URL link as shown in below figure
 For controlling actuator OPEN any Browser and enter your URL link
 For example :
https://api.thingspeak.com/update?api_key=MXY9OS6AQ9ILM5I0&field1=
0
 For controlling ON and OFF we need to change last character to ”0” and “1”

31
Experiment number:

Date:

Step 3: code

include"WiFiEsp.h"

include"secrets.h"

include"ThingSpeak.h" // alwaysincludethingspeak header fileafter other headerfilesand

//custommacros

char ssid[] =SECRET_SSID; // your networkSSID(name)char


pass[] =SECRET_PASS; // yournetworkpassword

int keyIndex=0; // your networkkey Indexnumber(neededonly for WEP)

WiFiEspClientclient;

// EmulateSerial1 onpins6/7 if not presentifndef


HAVE_HWSERIAL1include"SoftwareSerial.h"

SoftwareSerial Serial1(6, 7); // RX, TX


defineESP_BAUDRATE19200

else

defineESP_BAUDRATE115200

endif

// Weatherstationchannel details

unsignedlongmyChannelNumber=SECRET_CH_ID;

const char *myReadAPIKey=SECRET_READ_APIKEY; //readAPI


unsignedint FieldNumber =1;

intBuzzer_status;const int
buzzerPin=8;

voidsetup()

Serial.begin(115200); Serial1.begin(19200);
Serial.print(F("SearchingforESP8266..."));
WiFi.init(&Serial1);

32
Experiment number:

Date:
// checkfor thepresenceof theshield if
(WiFi.status()==WL_NO_SHIELD){

Serial.println(F("ESP8266not present"));

//don'tcontinuewhile(true);

Serial.println("foundit!");

ThingSpeak.begin(client); // InitializeThingSpeak
pinMode(buzzerPin,OUTPUT);

voidloop()

// Connect or reconnect toWiFi

if (WiFi.status() !=WL_CONNECTED)

Serial.print(F("AttemptingtoconnecttoSSID:"));
Serial.println(ssid);

while(WiFi.status()!=WL_CONNECTED)

WiFi.begin(ssid,pass);
Serial.print(".");
delay(5000);

Serial.println(F("\nConnected"));

//readfromchannel

Buzzer_status=ThingSpeak.readLongField(myChannelNumber, FieldNumber, myReadAPIKey);

// Checkthestatusof thereadoperationtoseeif it wassuccessful int statusCode=0;

statusCode=ThingSpeak.getLastReadStatus();
Serial.println(statusCode);

33
Experiment number:

Date:

if (statusCode==200)

Serial.println("Read: " +String(Buzzer_status));

else

Serial.println(F("Problemreadingchannel"));

if(Buzzer_status==1)

{Serial.print("Buzzeron");
digitalWrite(buzzerPin,HIGH);

elseif(Buzzer_status==0)

{Serial.print("Buzzeroff");digitalWrite(buzzerPin,LOW);

delay(15000); // Noneedtoreadthecountertoooften.

Secrets-

// Usethisfiletostoreall of theprivatecredentials
// andconnectiondetails

defineSECRET_SSID"ACENAARTECHNOLOGY" // replaceMySSIDwithyour WiFi networkname


defineSECRET_PASS"123456789" // replaceMyPasswordwithyour WiFi password

defineSECRET_CH_ID 1821569 //Test channel for counting


defineSECRET_READ_APIKEY"UHPXHAHWI5W5DS1Q" //API Key for Test channel

34
Experiment number:

Date:
OUTPUT:

Result:

35
Experiment number:

Date:
05. Upload humidity &amp; temperature data to Thing Speak, periodically logging ambient light level to

Thing Speak

Aim: Upload humidity &amp; temperature data to Thing Speak, periodically logging ambient light level to

Thing Speak

List of components:

Sno Component Description Port Names Board

1. Arduino nano Arduino Nano Control unit


Development
board

2. DHT-11 module DHT 11 Sensor DHT 11(I)

3. Wi-Fi Module ESP 8266 ESP-01 module (D)


Wi-Fi Module

4. connecting wires Two - 4 port


JST connecting

procedure:

Here we measure the Temperature and the Humidity using DHT-11sensor. We PUSH values to
the cloud (ThingSpeak cloud) and represent the values using the FIELDS in the Thinkspeak, in
graphical format, here we use two fields one for Temperature and one for Humidity.
• Connect the micro-USB cable to the Arduino Nano . and UPLOAD the written C++ code using
Arduino IDE.

36
Experiment number:

Date:
• Connection of the peripherals: Connect the DHT-11 module (I) to the control unit (5) using the4
pin JST connector.
• Connect the ESP module(D) to the control unit (8) using the 4 pin JST connector.

Sample code-

include"WiFiEsp.h"
include"secrets.h"
include"ThingSpeak.h" // alwaysincludethingspeak headerfileafter otherheaderfilesandcustommacros
include<DHT.h>
defineDHTPIN12 // DHTdatapinconnectedtoArduinopin5
defineDHTTYPEDHT11 // DHT11
(DHTSensorType)
DHTdht(DHTPIN, DHTTYPE); // InitializetheDHTsensor

charssid[] =SECRET_SSID; // yournetworkSSID(name)


charpass[] =SECRET_PASS; // yournetworkpassword
int keyIndex=0; // yournetworkkey Indexnumber (neededonly forWEP)
WiFiEspClient client;
// EmulateSerial1 onpins6/7if not presentifndef
HAVE_HWSERIAL1
include"SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
defineESP_BAUDRATE19200
else
defineESP_BAUDRATE115200
endif

unsignedlongmyChannelNumber=SECRET_CH_ID;const
char*myWriteAPIKey =SECRET_WRITE_APIKEY;

// Initializeourvaluesfloat t;
float h;

voidsetup() {
//Initializeserial andwait forport toopen
Serial.begin(115200); // Initializeserial while(!Serial){
; // wait forserial port toconnect. NeededforLeonardonativeUSBport only
}

// initializeserial forESPmodule
setEspBaudRate(ESP_BAUDRATE);

while(!Serial) {
; // wait forserial port toconnect. NeededforLeonardonativeUSBport only
}

37
Experiment number:

Date:
Serial.print("SearchingforESP8266...");
// initializeESPmodule
WiFi.init(&Serial1);

// checkforthepresenceof theshield if
(WiFi.status() ==WL_NO_SHIELD) {
Serial.println("WiFi shieldnot present");
// don't continue
//while(true);
}
Serial.println("foundit!");

ThingSpeak.begin(client); // InitializeThingSpeak

dht.begin();
}
voidloop() {

// Connect orreconnect toWiFi


if(WiFi.status()!=WL_CONNECTE
D){
Serial.print("Attemptingtoconnect toSSID: ");
Serial.println(SECRET_SSID);
while(WiFi.status()!=WL_CONNECTED){
WiFi.begin(ssid, pass); // Connect toWPA/WPA2network. Changethislineif usingopenorWEPnetworkSerial.print(".");
delay(5000);
}
Serial.println("\nConnected.");
}

// Checkif any readsfailedandexit early (totry again).if


(isnan(h) || isnan(t) ){
Serial.println(F("FailedtoreadfromDHTsensor!"));
return;
}
//Wait afewsecondsbetweenmeasurements.delay(2000);

// Readingtemperatureorhumidity takesabout 250milliseconds!


// Sensor readingsmay alsobeupto2seconds'old' (itsavery slowsensor)float
h=dht.readHumidity();
// ReadtemperatureasCelsius(thedefault) float t
=dht.readTemperature();
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("%Temperature: "));
Serial.print(t);
38
Experiment number:

Date:
Serial.print(F("°C"));
// set thefieldswiththevalues
ThingSpeak.setField(1,h);
ThingSpeak.setField(2, t);
// set thestatus
// ThingSpeak.setStatus(myStatus);
// writetotheThingSpeak channel
intx=ThingSpeak.writeFields(myChannelNumber,myWriteAPIKey);
if(x==200){
Serial.println("Channel updatesuccessful.");
}
else{
Serial.println("Problemupdatingchannel. HTTPerrorcode" +String(x));
}

delay(20000); // Wait 20secondstoupdatethechannel again


}

// Thisfunctionattemptstoset theESP8266baudrate. Boardswithadditional hardwareserial ports


// canuse115200, otherwisesoftwareserial islimitedto19200. voidsetEspBaudRate(unsignedlongbaudrate){
longrates[6] ={115200,74880,57600,38400,19200,9600};

Serial.print("SettingESP8266baudrateto");
Serial.print(baudrate);
Serial.println("...");
for(int i =0; i <6; i++){
Serial1.begin(rates[i]);
delay(100);
Serial1.print("AT+UART_DEF=
");Serial1.print(baudrate);
Serial1.print(",8,1,0,0\r\n");
delay(100);
}

Serial1.begin(baudrate);
}

Secrets-

// Usethisfiletostoreall of theprivatecredentials
// andconnectiondetails

defineSECRET_SSID"ACENAARTECHNOLOGY" // replaceMySSIDwithyourWiFi networkname


defineSECRET_PASS"123456789" // replaceMyPasswordwithyour WiFi password

39
Experiment number:

Date:

defineSECRET_CH_ID1746185 // replace0000000withyourchannel number


defineSECRET_WRITE_APIKEY"DCV1M348ZMBF0YCT" // replaceXYZwithyourchannel writeAPI
Key

OUTPUT:

40
Experiment number:

Date:

RESULT:

41
Experiment number:

Date:

6. Controlling LEDs, relay &amp; buzzer using Blynk app

Aim: Controlling LEDs, relay &amp; buzzer using Blynk 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 who are new to MIT App Inventor can develop a simple first app and run in less
than 30 minutes. Blocks-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 people, 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.

List Of Components:

Sno Component Description Port Names Board

1. Arduino Nano Arduino Nano Control unit


Development
board

2. Servo Motor Servo SG-90 Three pins to


digital lines

3. Bluetooth Module HC-05 HC-05 module (E)

4. Connecting wires Two - 4 port


JST connecting

42
Experiment number:

Date:

Procedure:

Step 1: creation of MIT App

 Search URL https://appinventor.mit.edu/ in any browser

43
Experiment number:

Date:

44
Experiment number:

Date:

45
Experiment number:

Date:

Click on Load App into App Inventor

46
Experiment number:

Date:

The App Inventor 2 Design & Blocks

Design Block

Install app in your mobile phone after downloading apk file

• Connect the micro-USB cable to the Arduino Nano in the kit, UPLOAD the written C++ code
using Arduino IDE. (Note: ENSURE to REMOVE connection on Connector – 11 in
Control unit while uploading the code.), also make sure you already installed the respected

47
Experiment number:

Date:
libraries.
• Connection of the peripherals: Connect the Servo motor pin to pins as followingformat.
S.No Colour Pins

1 Brown colour GND

2 RED colour 5Vots

3 Yellow colour PWM

• Connect the HC-05 module(E) to control unit (6) and servo motor –(A) to controlunit (10).

Sample Code

Step3:ArduinoCode

include<SoftwareSerial.h> // TXRXsoftwarelibrary for bluetooth


include<Servo.h> // servolibrary
Servomyservo; // servoname
int bluetoothTx =10; // bluetooth txto10 pin
int bluetoothRx =11; // bluetoothrx to11 pin

SoftwareSerialbluetooth(bluetoothTx,bluetoothRx);voidsetup()
{

myservo.attach(3); // attachservosignal wiretopin9


//Setupusbserial connectiontocomputer
Serial.begin(9600);

//SetupBluetoothserial connectiontoandroid
bluetooth.begin(9600);
}

voidloop()
{
//Readfrombluetoothandwritetousbserial
if(bluetooth.available()>0 ) // receivenumber frombluetooth
{
int servopos=bluetooth.read(); // savethereceivednumber toservopos

48
Experiment number:

Date:
Serial.println(servopos); // serial print servoposcurrent number receivedfrombluetooth
myservo.write(servopos); // roatetheservotheanglereceivedfromtheandroidapp
Serial.print("ServoPosition");
}
}

49
Experiment number:

Date:
OUTPUT:

Result:

50
Experiment number:

Date:
Exp No:7. Introduction to HTTP, hosting basics from various actuators

Aim : Introduction to HTTP, hosting basics from various actuators

The MQ-135 Gas sensor can detect gases like Ammonia (NH3), sulfur (S), Benzene (C6H6), CO2, and
other harmful gases and smoke. Similar to other MQ series gas sensor, this sensor also has a digital and
analog output pin. When the level of these gases go beyond a threshold limit in the air the digital pin goes
high. This threshold value can be set by using the on-board potentiometer. The analog output pin, outputs
an analog voltage which can be used to approximate the level of these gases in the atmosphere.
The MQ135 air quality sensor module operates at 5V and consumes around 150mA. It requires some
pre-heating before it could actually give accurate results.

Note : That all MQ sensors have to be powered up for a pre-heat duration for the sensor to
warm up before it can start working. This pre-heat time is normally between 30 seconds to a
couple of minutes. When you power up the module the power LED will turn on, leave the module in
this statetill the pre-heat duration is completed.

Detect Harmful Gases using Digital Pin:

The digital output pin of the sensor can be used to detect harmful gases in the environment. The
sensitivity of the digital pin can be controlled by using the 10k potentiometer. If the gas is detected the
indicator LED D0 will turn on and the digital pin will go from logic high to logic low (0V). The
LM393 Op-Amp Comparator IC is used to compare the actual gas value with the value set using the
potentiometer. If the actual gas value increases than the set value then the digital output pin gets low.
Because of the onboard LM393 comparator IC the MQ135 Gas sensor module can also be used without
the need of an external microcontroller. Simply power up the module and set the sensitivity of the
digital pin using the potentiometer, then when the module detects the gas the digital pin will golow.
This digital pin can directly be used to drive a buzzer or LED with the help of simple transistors.

51
Experiment number:

Date:
Measure PPM Value using Analog Pin:

The Analog output pin of the sensor can be used to measure the PPM value of the required gas. To do
this we need to use an external microcontroller like Arduino. The microcontroller will measure the value
of analog voltage and perform some calculations to find the value of Rs/Ro where Rs is the sensor
resistance when gas is present and Ro is sensor resistance at clean air. Once we find this ratio of Rs/Ro
we can use it to calculate the PPM value of required gas using the graph below which is taken from the
datasheet of MQ135 Sensor.
Technical Specifications of MQ135 Gas Sensor

• Operating Voltage: 2.5V to 5.0V


• Power consumption: 150mA
• Detect/Measure: NH3, NOx, CO2, Alcohol, Benzene, Smoke
• Typical operating Voltage: 5V
• Digital Output: 0V to 5V (TTL Logic) @ 5V Vcc
• Analog Output: 0-5V @ 5V Vcc

PPM VALUE ANALYSIS

The concentration of pollutants in the air is measured in parts per million (ppm). The Analog Output pin
of the sensor is connected to the analog channel of the MCU. The analog output from the MQ135 can
be assumed directly proportional to the concentration (in ppm) of gas in the industrial area. The
digitized value (Vout) is related to the load resistance to find the resistance output value from the sensor
(Rs).

52
Experiment number:

Date:

RL is load resistance and Rs is the sensor resistance (between 30Kohm and 200Kohm),Vc=5.
It is possible to obtain values of CO2, CO and NH4 levels in the air of the monitored environment
usingthe following equations

where R0 is the resistance of the gas sensor at defined concentration.


PPM value of CO2 Gas

The ppm of CO2 gas in the environment varies from 4.6x100 ppm to 5.7x100 ppm which is shown in
below figure. The safe upper limit for CO2 is no more than 450 ppm. The increasing CO2
concentration would lead to traps heat on the environment that can have a very significant effect on
health. In order to stabilize CO2 concentrations less than 450 ppm, the microcontroller will turn on the
exhaust fan.
About PPM and PM:

Measuring Units

The three basic measurements units used in


reporting air pollution data are micrograms
per cubic meter, parts per million (PPM),
and the micron (JL). Micro grams per cubic
meter and parts per million are measures of
concentration. Both microgram per meter
cube and ppm are used to indicate the
concentration of a gaseous pollutant. There
is an advantage to the unit ppm that
frequently makes it the unit of choice is a
volume-to-volume ratio.

53
Experiment number:

Date:

Note:- 1. PPM in Air, is a volume-to-volume ratio.

2.PPM in water and wastewater, is a mass-to-mass ratio.

Changes in temperature and pressure do not change the ratio of the volume of pollutant gas to the
volume of air that contains it

What is PPM

Parts per million (PPM) is a unit of measurement used for expressing a very dilute concentration level of
pollutants in the air, water and other fluids or one item in a million of anything of the same size.
Converting air pollutant concentration
1. Converting Micro grams per cubic meter to PPM

ppmv = mg/m^3 x (0.08205 x T) / M

2. Converting PPM to Micro grams per cubic meter


mg/m^3 = ppmv x M /(0.08205 x T)

• mg/m^3 = Microgram of pollutant per cubic meter of air


• ppmv = Air pollutant concentration, in parts per million by volume
• T = Ambient temperature in kelvin
• 0.08205 = Universal gas constant
• M = Molecular weight of air pollutant

What is PM level

Particulate matter (PM) in the atmospheric air or in any other gas cannot be expressed in terms of
ppmv, volume percent or mole percent. PM is most expressed as mg/m^3 of air or other gas at a
specified temperature and pressure.

Note:- One volume percent = 10, 000 ppmv (parts per million by volume) with a million being
defined as 10^6.

Care must be taken with the concentrations expressed as parts per billion by volume (ppbv) to
differentiate between the British billion which is 10^12 and the USA billion which is 10^9.

Particulate matter is the sum of all solid and liquid particles suspended in air many of which are

54
Experiment number:

Date:
hazardous. This complex mixture includes both organic and inorganic particles.

Based on size, particulate matter is often divided into two groups

1. Coarse particles (PM 10-2.5) such as those found near roadways and dusty industries range in
diameter from 2.5 to 10 micrometers (or microns). The existing coarse particle standard (known as PM
10) includes all particles less than 10 microns in size.
2. "Fine particles" (or PM 2.5) are those found in smoke and haze have diameters less than 2.5 microns.
PM 2.5 is referred to as "primary" if it is directly emitted into the air as solid or liquid particles, and is
called "secondary" if it is formed by chemical reactions of gases in the atmosphere.

Air Quality Index (AQI)

An air quality index (AQI) is a number which is used by the government authorities to communicate the
public about the current level of air pollution on a daily basis. It is a measure of air quality impacts their
health. An increase in the AQI value tells that an increase in level of air pollution and the greater the
severe adverse health effects. The concept of AQI is widely used in many countries in different point
scales to report air quality
The AQI provides an indication of the quality of the air and its health effects. The index value for
pollutant can be calculated as

where,

Cp is the truncated concentration of pollutant (p)


BPHi is the breakpoint that is greater than or equal to Cp
BPLo is the breakpoint that is less than or equal to Cp
IHi is the AQI value corresponding to
BPHi ILo is the AQI value corresponding
to BPLo

55
Experiment number:

Date:

OUTPUT:

Air quality-

Air Quality (AQ) Values Levels of Health Concern

When the AQ is in this range: ..air quality conditions are:


1023 Good
50 to 300 Hazardous

Result:

56
Experiment number:

Date:
Exp No:8. Displaying various sensor readings on a simple web page

Aim: Displaying various sensor readings on a simple web page

List of components:

Sno Component Description Port Names Board

1. Arduino Nano Arduino Nano Control unit


Development
board

2. AIR Quality Sensor MQ135 V - (1.0) Three pins to


Analog lines

3. Wi-Fi Module ESP 8266 ESP-01 module (D)


Wi-Fi Module

4. Connecting wires Two - 4 port


JST connecting
wires

Procedure:
57
Experiment number:

Date:
• Connect the micro-USB cable to the Arduino Nano in the kit, and UPLOAD the written C++ code using
Arduino IDE. (Note: ENSURE Connector – 11 is removed on Connector unit while uploading the
code.)
• Connection of the peripherals: Connect the MQ135 Sensor connector at bottom side “Air” to Control Unit
(4) and Connect ESP module(D) to the control Unit (11).

Sample Code:

include"WiFiEsp.h"
include"secrets.h"
include "ThingSpeak.h" // alwaysincludethingspeak header fileafter other header filesandcustommacros

char ssid[] =SECRET_SSID; // your network SSID(name)char


pass[] =SECRET_PASS; // your networkpassword
int keyIndex =0; // your network key Index number (neededonly for WEP)
WiFiEspClient client;

// EmulateSerial1 onpins6/7 if not presentifndef


HAVE_HWSERIAL1
include"SoftwareSerial.h" SoftwareSerial
Serial1(6,7); // RX, TX
defineESP_BAUDRATE19200
else
defineESP_BAUDRATE115200
endif

unsignedlongmyChannelNumber=SECRET_CH_ID;const
char *myWriteAPIKey =SECRET_WRITE_APIKEY;

voidsetup() {
Serial.begin(115200); //Initializeserial
while(!Serial){
; // wait for serial port toconnect. Neededfor LeonardonativeUSBport only
}

// initializeserial for ESPmodule


setEspBaudRate(ESP_BAUDRATE);

while(!Serial) {
; // wait for serial port toconnect. Neededfor LeonardonativeUSBport only
}
Serial.print("Searchingfor ESP8266...");
// initializeESPmodule
WiFi.init(&Serial1);

58
Experiment number:

Date:

// check for thepresenceof theshield if


(WiFi.status() ==WL_NO_SHIELD) {
Serial.println("WiFi shieldnot present");
// don't continue
while(true);
}
Serial.println("foundit!");
ThingSpeak.begin(client); // InitializeThingSpeak
}
voidloop() {

// Connect or reconnect toWiFi


if(WiFi.status()!=WL_CONNECTED){
Serial.print("Attempting toconnect toSSID: ");
Serial.println(SECRET_SSID);
while(WiFi.status()!=WL_CONNECTED){
WiFi.begin(ssid, pass); // Connect toWPA/WPA2network. Changethislineif usingopenor WEPnetwork Serial.print(".");
delay(5000);
}
Serial.println("\nConnected.");
}
/*AirQualityvaluesMQ135gasSensor
=MQ135(A0);air_quality
=gasSensor.getPPM();Serial.print("
AIRQUALITYPPM:");
Serial.println(air_quality);
delay(1); // delay inbetweenreadsfor stability*/

int air_quality =analogRead(A0);


// print out thevalueyouread:Serial.println(air_quality);

if(air_quality>1000){
Serial.print(" FreshAir");

elseif( air_quality<1000)
{
Serial.print(" Poor Air");
}

// WritetoThingSpeak. Thereareupto8fieldsina channel, allowingyoutostoreupto8different


// piecesof informationina channel. Here, wewritetofield 1.
int x=ThingSpeak.writeField(myChannelNumber, 1,air_quality, myWriteAPIKey);
if(x ==200){
Serial.println("Channel updatesuccessful.");
}
59
Experiment number:

Date:
else{
Serial.println("Problemupdatingchannel. HTTPerror code" +String(x));
}

delay(20000); // Wait 20secondstoupdatethechannel again


}
// Thisfunctionattemptstoset the ESP8266 baudrate. Boardswithadditional hardwareserial ports
// canuse115200, otherwisesoftwareserial islimitedto19200. voidsetEspBaudRate(unsignedlongbaudrate){
longrates[6] ={115200,74880,57600,38400,19200,9600};
Serial.print("SettingESP8266 baudrateto");
Serial.print(baudrate);
Serial.println("...");

for(int i =0; i <6; i++){


Serial1.begin(rates[i]);
delay(100);
Serial1.print("AT+UART_DEF=
");Serial1.print(baudrate);
Serial1.print(",8,1,0,0\r\n");
delay(100);
}
Serial1.begin(baudrate);
}

Secrets-

// Usethisfiletostoreall of theprivatecredentials
// andconnectiondetails

defineSECRET_SSID"ACENAARTECHNOLOGY" // replaceMySSIDwithyour WiFi networkname


defineSECRET_PASS"123456789" // replaceMyPasswordwithyour WiFi password

defineSECRET_CH_ID1746185 // replace0000000 withyour channel number


defineSECRET_WRITE_APIKEY"DCV1M348ZMBF0YCT" // replaceXYZwithyour channel writeAPI
Key

OUTPUT:
60
Experiment number:

Date:

Result:

61
Experiment number:

Date:

9. Controlling LEDs/Motors from an Android/WebappControllingAC


Aim: Controlling LEDs/Motors from an Android/Web app, ControllingAC

1. TDS (Total Dissolved Solids) indicates that how many milligrams of soluble solids dissolved in
oneliter of water. In general, the higher the TDS value, the more soluble solids dissolved in water,
andthe less clean the water is. Therefore, the TDS value can be used as one of the references for
reflecting the cleanliness of water.
2. As the number of dissolved solids in the water increases, the conductivity of the water increases,
and that allow us to calculate the total dissolved solids in ppm (mg/L).
3. note that it does not measure contaminants in the water.
4. A TDS meter can be useful to monitor water quality in many applications like pools, aquariums,
fish tanks, hydroponics, water purifiers, etc.
5. This product supports 3.3 ~ 5.5V wide voltage input, and 0 ~ 2.3V analog voltage output, which
makes it compatible with 5V or 3.3V control systems or boards. The excitation source is AC
signal,which can effectively prevent the probe from polarization and prolong the life of the probe,
meanwhile can help increase the stability of the output signal. The TDS probe is waterproof, it can
be immersed in water for long time measurement.
Working of TDS meter
A TDS meter is basically an electrical charge (EC) meter where by two electrodes equally
spaced apart are inserted into water and used to measure charge. The result is interpreted by the TDS
meter and converted into a ppm figure.

If the water contains no soluble materials and is pure, it will not


conduct a charge and will, therefore, have a 0 ppm figure. Conversely, if the water is full of dissolved
materials, it will conduct a charge, with the resulting ppm figure being proportional to the number of
dissolved solids. This is because all dissolved solids have an electrical charge,which allows conduction
of electrical charge between the electrodes.

62
Experiment number:

Date:

According to EPA, the limit for (TDS) Total Dissolved Solids for Drinking Water in the US is 200
ppm (Parts Per Million) but normal acceptable Levels range between 50-300 ppm. TDS Listed by
EPA as Secondary Contaminants, that may affect how water tastes, and in some cases, cause
disease.

List of components:

Sno Component Description Port Names Board

1. Arduino nano Arduino Nano Control unit

2. TDS Sensor TDS Meter V - (1.0) Three pins to


Analog lines

3. Wi-Fi Module ESP 8266 ESP-01 module (D)


Wi-Fi Module

4. connecting wires Two - 4 port

63
Experiment number:

Date:
JST connecting
wires

procedure:

• Connect the micro-USB cable to the Arduino Nano in the kit, to dump the written C++code using
Arduino IDE. (Note: ENSURE Connector-11 is removed on Connector unit while
uploading the code.) also make sure you installed the TDS respected libraries.
• Connection of the peripherals: Connect the TDS sensor JST connector to control unit
(4) , and Connect the ESP module(D) to control unit (11) .

Sample Code

include"WiFiEsp.h"
include"secrets.h"
include "ThingSpeak.h" // alwaysincludethingspeak header fileafter other header filesandcustommacrosinclude
<EEPROM.h>
include "GravityTDS.h"

defineTdsSensorPinA1 // tdsmeter pin

GravityTDSgravityTds;

char ssid[] =SECRET_SSID; // your network SSID(name)char


pass[] =SECRET_PASS; // your networkpassword
int keyIndex =0; // your network key Index number (neededonly for WEP)
WiFiEspClient client;

// EmulateSerial1 onpins6/7 if not presentifndef


HAVE_HWSERIAL1
include"SoftwareSerial.h" SoftwareSerial
Serial1(6, 7); // RX, TX
defineESP_BAUDRATE19200
else
defineESP_BAUDRATE115200
endif

unsignedlongmyChannelNumber=SECRET_CH_ID;const
char *myWriteAPIKey =SECRET_WRITE_APIKEY;

64
Experiment number:

Date:
float temperature=25;// set temperaturevalue int

tdsValue=0;

voidsetup() {
Serial.begin(115200); //Initializeserial
while(!Serial){
; // wait for serial port toconnect. Neededfor LeonardonativeUSBport only
}

// initializeserial for ESPmodule


setEspBaudRate(ESP_BAUDRATE);

while(!Serial) {
; // wait for serial port toconnect. Neededfor LeonardonativeUSBport only
}

Serial.print("Searchingfor ESP8266...");
// initializeESPmodule
WiFi.init(&Serial1);

// check for thepresenceof theshield if


(WiFi.status() ==WL_NO_SHIELD) {
Serial.println("WiFi shieldnot present");
// don't continue
while(true);
}
Serial.println("foundit!");

gravityTds.setPin(TdsSensorPin);
gravityTds.setAref(5.0); //refewebpage+="Danger! MovetoFreshAir";
}rencevoltageonADC, default 5.0VonArduinoUNO gravityTds.setAdcRange(1024);
//1024for 10bit ADC;4096 for 12bit ADCgravityTds.begin();
//initialization

ThingSpeak.begin(client); // InitializeThingSpeak
}

voidloop() {

// Connect or reconnect toWiFi


if(WiFi.status()!=WL_CONNECTED){
Serial.print("Attempting toconnect toSSID: ");
Serial.println(SECRET_SSID);
while(WiFi.status()!=WL_CONNECTED){
WiFi.begin(ssid, pass); // Connect toWPA/WPA2network. Changethislineif usingopenor WEPnetwork Serial.print(".");
65
Experiment number:

Date:
delay(5000);
}
Serial.println("\nConnected.");
}

//temperature=readTemperature(); //add your temperaturesensor andreadit

gravityTds.setTemperature(temperature); // set thetemperatureandexecutetemperaturecompensation gravityTds.update();


//sampleandcalculate
/*HowgravityTdsvaluecalculatedinprogram
*gravityTds:-
analogValue=analogRead(pin);
voltage=analogValue/adcRange*aref;
ecValue=(133.42*voltage*voltage*voltage-255.86*voltage*voltage+857.39*voltage)*kValue;ecValue25
=ecValue/ (1.0+0.02*(temperature-25.0)); //temperaturecompensation
tdsValue=ecValue25*TdsFactor;
if(cmdSerialDataAvailable() >0)
{
ecCalibration(cmdParse()); // if receivedserial cmdfromtheserial monitor, enter intothecalibrationmode
}
*/
tdsValue=gravityTds.getTdsValue();
// thenget thevalueint
tds=tdsValue;
Serial.print("TDSPPM:");
Serial.println(tds);
// WritetoThingSpeak. Thereareupto8fieldsina channel, allowingyoutostoreupto8different
// piecesof informationina channel. Here, wewritetofield 1.
int x=ThingSpeak.writeField(myChannelNumber, 1,tdsValue, myWriteAPIKey);if(x
==200){
Serial.println("Channel updatesuccessful.");
}
else{
Serial.println("Problemupdatingchannel. HTTPerror code" +String(x));
}

delay(20000); // Wait 20secondstoupdatethechannel again


}

// Thisfunctionattemptstoset the ESP8266 baudrate. Boardswithadditional hardwareserial ports


// canuse115200, otherwisesoftwareserial islimitedto19200. voidsetEspBaudRate(unsignedlongbaudrate){
longrates[6] ={115200,74880,57600,38400,19200,9600};
Serial.print("SettingESP8266 baudrateto");
Serial.print(baudrate);
Serial.println("...");
for(int i =0; i <6; i++){
66
Experiment number:

Date:
Serial1.begin(rates[i]);
delay(100);
Serial1.print("AT+UART_DEF=
");Serial1.print(baudrate);
Serial1.print(",8,1,0,0\r\n");
delay(100);
}
Serial1.begin(baudrate);
}

Secrets-

// Usethisfiletostoreall of theprivatecredentials
// andconnectiondetails

defineSECRET_SSID"ACENAARTECHNOLOGY" // replaceMySSIDwithyour WiFi network name


defineSECRET_PASS"123456789" // replaceMyPasswordwithyour WiFi password

defineSECRET_CH_ID1746185 // replace0000000 withyour channel number


defineSECRET_WRITE_APIKEY"DCV1M348ZMBF0YCT" // replaceXYZwithyour channel writeAPI
Key

67
Experiment number:

Date:
OUTPUT:

ThingSpeak site

Salt water values

68
Experiment number:

Date:

Tabular column:

S.no TDS Level in parts per million(ppm) Palatability Quotient


1 Between 50-150 Excellent for drinking
2 150-250 Good
3 250-300 Fair
4 300-500 Poor

Conduct Experiment with your own water and fill the table

S.no TDS Level in parts per million(ppm) TDS Value


1 Raw water with out RO
2 RO water
3 RO water with table salt
4 RO water with sugar

Result:

69
Experiment number:

Date:
10. Displaying humidity and temperature data on a web-based application
Aim: Displaying humidity and temperature data on a web-based application

List of components:

Sno Component Description Port Names Board

1. Arduino nano Arduino Nano Control unit


Development
board

2. LDR Sensor Light Dependent LDR


(L) Resistor

3. 8 LEDs 8 LEDs connected Logic


(J) through resistors

4. connecting wires one - 4 port


JST connecting
wire one- 10
port JST
connecting
wire

70
Experiment number:

Date:
procedure:
Here, we designed an Ambient light intensity based power saving system for Street lights.
 Connect the micro-USB cable to the Arduino Nano in the Acenaar kit, and UPLOAD the
written C++ code using Arduino IDE.
 Connection of the peripherals: Connect the LDR module (L) to the control unit (4) using the 4
pin JST connecting wires in AcenAAr IOT trainer kit.

Sample Code
int sensorPin=A0;
const int LEDPins[8] ={10,11,12,13,A2,A3,A4,A5};
int i =0;
voidsetup()
{
Serial.begin(9600);
pinMode(sensorPin,INPUT);for
(i=0;i<9;i++){
pinMode(LEDPins[i],
OUTPUT);
}
}
voidloop()
{
int x=analogRead(sensorPin);
Serial.println(x);
if( x<=100 ) // Changethevalueasper your requirement
{
for(i =0; i <9; i++)
digitalWrite(LEDPins[i],LOW);
}
else
{for(i =0; i <9; i++)
digitalWrite(LEDPins[i],HIGH);
}

if(x>101,x<200)
{
for(i =0; i <8; i++)
digitalWrite(LEDPins[i],LOW);
}
else{
for(i =0; i <8; i++)
digitalWrite(LEDPins[i],HIGH);
}

if(x>201,x<300)
{

71
Experiment number:

Date:
for (i=0;i<7;i++)
digitalWrite(LEDPins[i],LOW);
}
else{
for(i =0; i <7; i++)
digitalWrite(LEDPins[i],HIGH);
}

if(x>301,x<400)
{
for (i=0;i<6;i++)
digitalWrite(LEDPins[i],LOW);
}
else{
for(i =0; i <6; i++)
digitalWrite(LEDPins[i],HIGH);
}

if(x>401,x<500)
{
for (i=0;i<5;i++)
digitalWrite(LEDPins[i],LOW);
}
else{
for(i =0; i <5; i++)
digitalWrite(LEDPins[i],HIGH);
}

if(x>501,x<600)
{
for (i=0;i<4;i++)
digitalWrite(LEDPins[i],LOW);
}
else{
for(i =0; i <4; i++)
digitalWrite(LEDPins[i],HIGH);}
if(x>601,x<700)
{
for (i=0;i<3;i++)
digitalWrite(LEDPins[i],LOW);
}
else{
for(i =0; i <3; i++)
digitalWrite(LEDPins[i],HIGH);
}

72
Experiment number:

Date:

if(x>701,x<800){
for(i =0; i <2; i++)
digitalWrite(LEDPins[i],LOW);

}
else
{
for (i=0;i<2;i++)
digitalWrite(LEDPins[i],HIGH);

}
delay(200);
}

73
Experiment number:

Date:
OUTPUT:

Result:

74
Experiment number:

Date:
11. Demonstration of UAV elements, Flight Controller Mission Planner flight planning
design

Aim: Demonstration of UAV elements, Flight Controller Mission Planner flight planning design
Before digging into the best examples of Business Model Canvas around the world, let’s find out how the

Business Model Canvas was designed.

Generally speaking, the Business Model Canvas is a summary that tells how the key drivers of a
business fit together. It means showing the strategic details necessary to help a business get success
within the market.

help a business get success within the market.

One important thing is that this summary's length is within one sheet of paper. Imagine when you
include all this down in a document, and it turns into many pages to capture all information. This will
make you hard to remember as well as waste time opening pages over pages

While the categories or buckets included in a canvas can be adjusted according to


Customer segments: Who do you target as customers?

Value proposition: What are your strengths to make customers buy from your business?

Channels: Which channels do you use to deliver your products or services to the market?

Customer relationships: What are your strategies to get, keep, and build up the relationships with your
customers?

75
Experiment number:

Date:
Revenue streams: How will you make money?

Key resources: What are the special strategic resources that you own as well as a need?
Key activities: What will your business do to deliver your value proposition?

Key Partnerships: What are the non-key activities that you do to help your company focus more on
your key activities?
Cost structures: What are the biggest costs that your business earns?

Example of the business canvas for Digital display:

Appendix A: Arduino nano specifications

The Arduino Nano is a small Arduino board based on ATmega328P or ATmega628 Microcontroller.
Theconnectivity is the same as the Arduino Uno Board.
The Nano board is defined as a sustainable, small, consistent, and flexible Microcontroller board. It is small
in size compared to the UNO board. The Arduino Nano is organized using the Arduino (IDE), which can run
on various platforms. Here, IDE stands for Integrated Development Environment.
The devices required to start our projects using the Arduino Nano board are Arduino IDE and mini-USB. The
Arduino IDE software must be installed on our respected laptop or desktop. The mini-USB transfers the code
from the computer to the Arduino Nano board.

76
Experiment number:

Date:

MICROCONTROLLER ATmega328
ARCHITECTURE AVR
OPERATING VOLTAGE 5V
FLASH MEMORY 32 KB of which 2 KB used by bootloader
SRAM 2 KB
CLOCK SPEED 16 MHz
ANALOG IN PINS 8
EEPROM 1 KB
DC CURRENT PER I/O PINS 40 mA (I/O Pins)
INPUT VOLTAGE 7-12V
DIGITAL I/O PINS 22 (6 of which are PWM)
PWM OUTPUT 6
POWER CONSUMPTION 19 mA
PCB SIZE 18 x 45 mm
WEIGHT 7g
PRODUCT CODE A000005

77
Experiment number:

Date:
Power

The Arduino Nano can be powered via the Mini-B USB connection, 6-20V unregulated external power
supply (pin 30), or 5V regulated external power supply (pin 27). The power source is automatically
selected to the highest voltage source.

Memory

The ATmega328 has 32 KB, (also with 2 KB used for the bootloader. The ATmega328 has 2 KB of
SRAM and 1 KB of EEPROM.

Input and Output

Each of the 14 digital pins on the Nano can be used as an input or output, using pinMode(),
digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive a
maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms. In
addition, some pins have specialized functions:

 Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins
are connected to the corresponding pins of the FTDI USB-to-TTL Serial chip.
 External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low
value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details.
 PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.
 SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which,
although provided by the underlying hardware, is not currently included in the Arduino
language.
 LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the
LED is on, when the pin is LOW, it's off.

The Nano has 8 analog inputs, each of which provide 10 bits of resolution (i.e. 1024 different values).
By default they measure from ground to 5 volts, though is it possible to change the upper end of their
range using the analogReference() function. Analog pins 6 and 7 cannot be used as digital pins.
Additionally, some pins have specialized functionality:

 I2C: A4 (SDA) and A5 (SCL). Support I2C (TWI) communication using the Wire library
(documentation on the Wiring website).

There are a couple of other pins on the board:

78
Experiment number:

Date:

 AREF. Reference voltage for the analog inputs. Used with analogReference().
 Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to
shields which block the one on the board.

Communication
The Arduino Nano has a number of facilities for communicating with a computer, another Arduino, or
other microcontrollers. The ATmega328 provide UART TTL (5V) serial communication, which is
available on digital pins 0 (RX) and 1 (TX). An FTDI FT232RL on the board channels this serial
communication over USB and the FTDI drivers (included with the Arduino software) provide a virtual
com port to software on the computer. The Arduino software includes a serial monitor which allows
simple textual data to be sent to and from the Arduino board. The RX and TX LEDs on the board will
flash when data is being transmitted via the FTDI chip and USB connection to the computer (but not for
serial communication on pins 0 and 1). A SoftwareSerial library allows for serial communication on
any of the Nano's digital pins. The ATmega328 also support I2C (TWI) and SPI communication. The
Arduino software includes a Wire library to simplify use of the I2C bus. To use the SPI communication,
please see ATmega328 datasheet.

Programming

The Arduino Nano can be programmed with the Arduino software (download). Select "Arduino
Duemilanove or Nano w/ ATmega328" from the Tools > Board menu (according to the microcontroller
on your board). The ATmega328 on the Arduino Nano comes preburned with a bootloader that allows
you to upload new code to it without the use of an external hardware programmer. It communicates
using the original STK500 protocol. You can also bypass the bootloader and program the
microcontroller through the ICSP (In-Circuit Serial Programming) header using Arduino ISP or similar.

Automatic (Software) Reset

Rather then requiring a physical press of the reset button before an upload, the Arduino Nano is
designed in a way that allows it to be reset by software running on a connected computer. One of the
hardware flow control lines (DTR) of the FT232RL is connected to the reset line of the ATmega328 via
a 100 nanofarad capacitor. When this line is asserted (taken low), the reset line drops long enough to
reset the chip. The Arduino software uses this capability to allow you to upload code by simply
pressing the upload button in the Arduino environment. This means that the bootloader can have a
shorter timeout, as the lowering of DTR can be well-coordinated with the start of the upload. This
setup has other implications. When the Nano is connected to either a computer running Mac OS X or
Linux, it resets each time a connection is made to it from software (via USB). For the following half-
second or so, the bootloader is running on the Nano. While it is programmed to ignore malformed data
(i.e. anything besides an upload of new code), it will intercept the first few bytes of data sent to the
board after a connection is opened. If a sketch running on the board receives one-time configuration or

79
Experiment number:

Date:

Result:

80
IOT LAB

You might also like