Practicals
BLINKING OF LED USING
ARDUINO.
REQUIREMENTS:
• 1 Arduino UNO Board, Wire
Interfaces, LEDs
• THEORY:
In this we have perform a practical
of blinking of LED using Arduino
using the following steps-
• Step1: Connect the LED with 13
and ground off arduino.
• Step2: Connect the arduino with
the system.
• Step3: Open arduino software and
Blinking Code.
• Step4: Verify and upload the
program in the arduino and get the
output.
Checking the Voltage Variation of
Arduino UNO in IoT Platform
Ubidots
REQUIREMENTS:
• Arduino UNO Board, Ethernet
Shield, Interfacing Wires.
THEORY:
• In this we check the voltage
variation of arduino on IoT
Platform (ubidots.com)
Open ubidots.com
Login
Create new widget
Copy variable number and paste it in the
program
Copy token number and paste it in the program
Checking the Voltage
Variation of Arduino UNO in
IoT Platform(ThingSpeak)
REQUIREMENTS:
Arduino UNO Board, Ethernet Shield, Interfacing
Wires.
THEORY:
In this we check the voltage variation of
arduino on IoT Platform (thinkspeak.com)
Fig1: open arduino and include library
thinkspeak.
Fig 3: Open thinkspeak.com
Fig 4: Login
Fig 5: Create new channel
Fig 6: Copy Channel ID and API Key
and paste it in the program
Fig 7: Open Public View
Fig 8: Verify and Upload the program
Fig 9: Final Output
Code-
#include <ThingSpeak.h>
/*
WriteVoltage
Reads an analog voltage from pin 0, and writes it to a channel on
ThingSpeak every 20 seconds.
ThingSpeak ( https://www.thingspeak.com ) is a free IoT service for
prototyping
systems that collect, analyze, and react to their environments.
Copyright 2015, The MathWorks, Inc.
Documentation for the ThingSpeak Communication Library for Arduino is in
the extras/documentation folder where the library was installed.
See the accompaning licence file for licensing information.
*/
#ifdef SPARK
#include "ThingSpeak/ThingSpeak.h"
#else
#include "ThingSpeak.h"
#endif
///
*************************************************************************************************
**********
// This example selects the correct library to use based on the board selected under the
Tools menu in the IDE.
// Yun, Wired Ethernet shield, wi-fi shield, esp8266, and Spark are all supported.
// With Uno and Mega, the default is that you're using a wired ethernet shield
(http://www.arduino.cc/en/Main/ArduinoEthernetShield)
// If you're using a wi-fi shield (http://www.arduino.cc/en/Main/ArduinoWiFiShield),
uncomment the line below
//
*************************************************************************************************
**********
//#define USE_WIFI_SHIELD
#ifdef ARDUINO_ARCH_AVR
#ifdef ARDUINO_AVR_YUN
#include "YunClient.h"
YunClient client;
#else
#ifdef USE_WIFI_SHIELD
#include <SPI.h>
// ESP8266 USERS -- YOU MUST COMMENT OUT THE LINE BELOW. There's a
bug in the Arduino IDE that causes it to not respect #ifdef when it comes to #includes
// If you get "multiple definition of `WiFi'" -- comment out the line below.
#include <WiFi.h>
char ssid[] = "<YOURNETWORK>"; // your network SSID (name)
char pass[] = "<YOURPASSWORD>"; // your network password
int status = WL_IDLE_STATUS;
WiFiClient client;
#else
// Use wired ethernet shield
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
EthernetClient client;
#endif
#endif
// On Arduino: 0 - 1023 maps to 0 - 5 volts
#define VOLTAGE_MAX 5.0
#define VOLTAGE_MAXCOUNTS 1023.0
#endif
#ifdef ARDUINO_ARCH_ESP8266
#include <ESP8266WiFi.h>
char ssid[] = "<YOURNETWORK>"; // your network SSID (name)
char pass[] = "<YOURPASSWORD>"; // your network password
int status = WL_IDLE_STATUS;
WiFiClient client;
// On ESP8266: 0 - 1023 maps to 0 - 1 volts
#define VOLTAGE_MAX 1.0
#define VOLTAGE_MAXCOUNTS 1023.0
#endif
#ifdef SPARK
TCPClient client;
// On Particle: 0 - 4095 maps to 0 - 3.3 volts
#define VOLTAGE_MAX 3.3
#define VOLTAGE_MAXCOUNTS 4095.0
#endif
/*
*****************************************************************************************
**** Visit https://www.thingspeak.com to sign up for a free account and create
**** a channel. The video tutorial http://community.thingspeak.com/tutorials/thingspeak-
channels/
**** has more information. You need to change this to your channel, and your write API
key
**** IF YOU SHARE YOUR CODE WITH OTHERS, MAKE SURE YOU REMOVE YOUR
WRITE API KEY!!
*****************************************************************************************/
unsigned long myChannelNumber = 124278;
const char * myWriteAPIKey = "04377LL7I54LVCNZ";
void setup() {
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_ESP8266)
#ifdef ARDUINO_AVR_YUN
Bridge.begin();
#else
#if defined(USE_WIFI_SHIELD) || defined(ARDUINO_ARCH_ESP8266)
WiFi.begin(ssid, pass);
#else
Ethernet.begin(mac);
#endif
#endif
#endif
ThingSpeak.begin(client);
}
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading
// On Arduino: 0 - 1023 maps to 0 - 5 volts
// On ESP8266: 0 - 1023 maps to 0 - 1 volts
// On Particle: 0 - 4095 maps to 0 - 3.3 volts
float voltage = sensorValue * (VOLTAGE_MAX / VOLTAGE_MAXCOUNTS);
// Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8
different
// pieces of information in a channel. Here, we write to field 1.
ThingSpeak.writeField(myChannelNumber, 1, voltage, myWriteAPIKey);
delay(20000); // ThingSpeak will only accept updates every 15 seconds.
}
Glowing Of LED Using I/R
Sensor.
REQUIREMENTS:
Arduino UNO Board, Breadboard, LED, I/R Sensor,
Wire Interfaces.
THEORY:
Here we glow the LED using I/R sensor. In this when
our hand come closer towards the I/R sensor the
LED glows.
Step1: Connect the LED with arduino board and
breadboard.
Step2: Make the connection of wire between
arduino and breadboard.
Step3: Connect the LED with one pin of Arduino.
Step4: Connect the I/R sensor with arduino and
breadboard.
Step5: Connect the arduino with system.
Step6: Open the program in the arduino software.
Step7: Verify and upload the program and get the
output by placing your hand near the I/R Sensor.
Code-
int a=12;
int b=5;
void setup() {
// put your setup code here, to run once:
pinMode(a, INPUT);
pinMode(b, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int readsen=digitalRead(a);
if(readsen==HIGH)
{
digitalWrite(b, HIGH);
}
else
{
digitalWrite(b, !HIGH);
}
delay(1);
}
• Now its your turn do the same
practical with the use of any IOT
Platform.
Tasks to do-
• Make a system that sends mail to you
when the value of the sensor exceeds
the limit.(Hint-Explore Ubidots)
• Make a system that sends message
on your phone when the IR sensor
detects any presence.(Hint-Explore
Ubidots)
Thank You and Keep
Exploring

IoT Platform

  • 1.
  • 2.
    BLINKING OF LEDUSING ARDUINO. REQUIREMENTS: • 1 Arduino UNO Board, Wire Interfaces, LEDs • THEORY: In this we have perform a practical of blinking of LED using Arduino using the following steps-
  • 3.
    • Step1: Connectthe LED with 13 and ground off arduino. • Step2: Connect the arduino with the system. • Step3: Open arduino software and Blinking Code. • Step4: Verify and upload the program in the arduino and get the output.
  • 4.
    Checking the VoltageVariation of Arduino UNO in IoT Platform Ubidots REQUIREMENTS: • Arduino UNO Board, Ethernet Shield, Interfacing Wires. THEORY: • In this we check the voltage variation of arduino on IoT Platform (ubidots.com)
  • 6.
  • 7.
  • 8.
  • 9.
    Copy variable numberand paste it in the program
  • 10.
    Copy token numberand paste it in the program
  • 11.
    Checking the Voltage Variationof Arduino UNO in IoT Platform(ThingSpeak) REQUIREMENTS: Arduino UNO Board, Ethernet Shield, Interfacing Wires.
  • 12.
    THEORY: In this wecheck the voltage variation of arduino on IoT Platform (thinkspeak.com)
  • 13.
    Fig1: open arduinoand include library thinkspeak.
  • 14.
    Fig 3: Openthinkspeak.com
  • 15.
  • 16.
    Fig 5: Createnew channel
  • 17.
    Fig 6: CopyChannel ID and API Key and paste it in the program
  • 18.
    Fig 7: OpenPublic View
  • 19.
    Fig 8: Verifyand Upload the program
  • 20.
  • 21.
    Code- #include <ThingSpeak.h> /* WriteVoltage Reads ananalog voltage from pin 0, and writes it to a channel on ThingSpeak every 20 seconds. ThingSpeak ( https://www.thingspeak.com ) is a free IoT service for prototyping systems that collect, analyze, and react to their environments. Copyright 2015, The MathWorks, Inc. Documentation for the ThingSpeak Communication Library for Arduino is in the extras/documentation folder where the library was installed. See the accompaning licence file for licensing information. */
  • 22.
    #ifdef SPARK #include "ThingSpeak/ThingSpeak.h" #else #include"ThingSpeak.h" #endif /// ************************************************************************************************* ********** // This example selects the correct library to use based on the board selected under the Tools menu in the IDE. // Yun, Wired Ethernet shield, wi-fi shield, esp8266, and Spark are all supported. // With Uno and Mega, the default is that you're using a wired ethernet shield (http://www.arduino.cc/en/Main/ArduinoEthernetShield) // If you're using a wi-fi shield (http://www.arduino.cc/en/Main/ArduinoWiFiShield), uncomment the line below // ************************************************************************************************* ********** //#define USE_WIFI_SHIELD #ifdef ARDUINO_ARCH_AVR #ifdef ARDUINO_AVR_YUN #include "YunClient.h"
  • 23.
    YunClient client; #else #ifdef USE_WIFI_SHIELD #include<SPI.h> // ESP8266 USERS -- YOU MUST COMMENT OUT THE LINE BELOW. There's a bug in the Arduino IDE that causes it to not respect #ifdef when it comes to #includes // If you get "multiple definition of `WiFi'" -- comment out the line below. #include <WiFi.h> char ssid[] = "<YOURNETWORK>"; // your network SSID (name) char pass[] = "<YOURPASSWORD>"; // your network password int status = WL_IDLE_STATUS; WiFiClient client; #else // Use wired ethernet shield #include <SPI.h> #include <Ethernet.h> byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; EthernetClient client; #endif #endif // On Arduino: 0 - 1023 maps to 0 - 5 volts #define VOLTAGE_MAX 5.0
  • 24.
    #define VOLTAGE_MAXCOUNTS 1023.0 #endif #ifdefARDUINO_ARCH_ESP8266 #include <ESP8266WiFi.h> char ssid[] = "<YOURNETWORK>"; // your network SSID (name) char pass[] = "<YOURPASSWORD>"; // your network password int status = WL_IDLE_STATUS; WiFiClient client; // On ESP8266: 0 - 1023 maps to 0 - 1 volts #define VOLTAGE_MAX 1.0 #define VOLTAGE_MAXCOUNTS 1023.0 #endif #ifdef SPARK TCPClient client; // On Particle: 0 - 4095 maps to 0 - 3.3 volts #define VOLTAGE_MAX 3.3 #define VOLTAGE_MAXCOUNTS 4095.0 #endif /* *****************************************************************************************
  • 25.
    **** Visit https://www.thingspeak.comto sign up for a free account and create **** a channel. The video tutorial http://community.thingspeak.com/tutorials/thingspeak- channels/ **** has more information. You need to change this to your channel, and your write API key **** IF YOU SHARE YOUR CODE WITH OTHERS, MAKE SURE YOU REMOVE YOUR WRITE API KEY!! *****************************************************************************************/ unsigned long myChannelNumber = 124278; const char * myWriteAPIKey = "04377LL7I54LVCNZ"; void setup() { #if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_ESP8266) #ifdef ARDUINO_AVR_YUN Bridge.begin(); #else #if defined(USE_WIFI_SHIELD) || defined(ARDUINO_ARCH_ESP8266) WiFi.begin(ssid, pass); #else Ethernet.begin(mac); #endif
  • 26.
    #endif #endif ThingSpeak.begin(client); } void loop() { //read the input on analog pin 0: int sensorValue = analogRead(A0); // Convert the analog reading // On Arduino: 0 - 1023 maps to 0 - 5 volts // On ESP8266: 0 - 1023 maps to 0 - 1 volts // On Particle: 0 - 4095 maps to 0 - 3.3 volts float voltage = sensorValue * (VOLTAGE_MAX / VOLTAGE_MAXCOUNTS); // Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8 different // pieces of information in a channel. Here, we write to field 1. ThingSpeak.writeField(myChannelNumber, 1, voltage, myWriteAPIKey); delay(20000); // ThingSpeak will only accept updates every 15 seconds. }
  • 27.
    Glowing Of LEDUsing I/R Sensor. REQUIREMENTS: Arduino UNO Board, Breadboard, LED, I/R Sensor, Wire Interfaces. THEORY: Here we glow the LED using I/R sensor. In this when our hand come closer towards the I/R sensor the LED glows.
  • 28.
    Step1: Connect theLED with arduino board and breadboard. Step2: Make the connection of wire between arduino and breadboard. Step3: Connect the LED with one pin of Arduino. Step4: Connect the I/R sensor with arduino and breadboard. Step5: Connect the arduino with system. Step6: Open the program in the arduino software. Step7: Verify and upload the program and get the output by placing your hand near the I/R Sensor.
  • 29.
    Code- int a=12; int b=5; voidsetup() { // put your setup code here, to run once: pinMode(a, INPUT); pinMode(b, OUTPUT); } void loop() { // put your main code here, to run repeatedly: int readsen=digitalRead(a); if(readsen==HIGH) { digitalWrite(b, HIGH); } else { digitalWrite(b, !HIGH); } delay(1); }
  • 30.
    • Now itsyour turn do the same practical with the use of any IOT Platform.
  • 31.
    Tasks to do- •Make a system that sends mail to you when the value of the sensor exceeds the limit.(Hint-Explore Ubidots) • Make a system that sends message on your phone when the IR sensor detects any presence.(Hint-Explore Ubidots)
  • 32.
    Thank You andKeep Exploring