AltSense Trainers' Shield


AltSense Trainers' Shield




           



 Contents

  •  Overview
  •  Power Usage
  •  Controlling LEDs
  •  Interfacing Relays
  •  Interfacing Light Sensor/LDR
  •  Interfacing Temperature Sensor/LM35
  •  Interfacing Bluetooth/HC05
  •  Interfacing WiFi Module/ESP8266

Overview

         This trainer shield’s purpose is to get self trained on Internet of Things(IOT) and also to learn  to control LEDs, Home Appliances with Wi-Fi and Bluetooth.
3 LEDs are connected to digital pins 9,10 &11 of Arduino.

ESP8266’s Tx and Rx pins are connected to digital Pins 4 and 5  of Arduino respectively.

HC-05’s Tx and Rx are connected to digital pins 6 and 7 of Arduino respectively.

Relays are connected to digital pins 2 and 3 of Arduino.


Power Usage

Normally when attached with Arduino we get 5V supplied to LDR, LM35, Bluetooth and 3.3V to Wi-Fi module. Since we have used 12V relays, a 12V adapter is needed to trigger the relays.

Controlling LEDs


                                          
There are 3 LEDs connected to pins 9, 10 and 11 of Arduino. By using digital OUTPUTS we can control them.

Code - Blink 3 LEDs with one second delay

void setup() {
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(2, OUTPUT);
}
void loop()
{
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
delay(1000);

}

Interfacing Relays



Relays are electromachanical switches used to control AC devices.
Two Relays are connected to pins 2 and 3 of Arduino. The external adapter of 12V minimum 0.5A should be connected to external jack as shown in the figure below.




Code - Triggering Relays

void setup() {
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
}


void loop()
{
digitalWrite(3, HIGH);
digitalWrite(3, HIGH);
delay(1000);
digitalWrite(2, LOW);
digitalWrite(3,LOW);
delay(1000);
}


Interfacing Temperature Sensor/LM35


LM35 is a temperature sensor which converts the room temperature into electrical signals. The LM35 is connected to pin A0 of Arduino.

Code - Read the room temperature

void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(1);
}


Interfacing Light Sensor/LDR



LDR or Light Dependent Resistor is used to measure amount of light present. Light is inversely proportional to resistivity. The LDR is connected to analog pin A1 of Arduino.

Code - Get the know the amount of Light

void setup() {
Serial.begin(9600);
}


void loop() {
int sensorValue = analogRead(A1);
Serial.println(sensorValue);
delay(1);
}


Interfacing HC05 Bluetooth Module



HC-05 is a wireless module which works on bluetooth protocol.

Hardware Features

  • Typical -80dBm sensitivity
  • Up to +4dBm RF transmit power
  • Low Power 1.8V Operation ,1.8 to 3.6V I/O
  • GPIO control
  • UART interface with programmable baud rate
  • With integrated antenna
  • With edge connector

Steps to work with HC05 Bluetooth Module

  1.  Fix the HC-05 module as shown in this figure above.
  2.  Download BLUETERM application from google play in your mobile.
  3.  Open Bluetooth settings and check for available devices.
  4.  Click the HC-05 and pair it with password 1234
  5.  Open blueterm. Go to option menu.
  6.  Connect device and click on the paired HC-05 device.
  7.  Now execute the following code and check whether data is sent from laptop to mobile and vice versa.

Code - Let your mobile and laptop talk

#include<SoftwareSerial.h>
SoftwareSerial blue(2,3);
 #define bike 10
 void setup()
{
 Serial.begin(9600);
blue.begin(9600);
 pinMode(bike, OUTPUT);
 }
 void loop()
 {
 if (blue.available() > 0)
 {
 String x = blue.readString();
Serial.print(x);
 }
if (Serial.available() > 0)
{
 String x = Serial.readString();
 blue.print(x);
 }
 }


Interfacing ESP8266 WiFi Module



ESP8266 is a low cost Wifi module which works on 3.3V. The voltage issue are all sorted out with potential divider circuit.

To Learn more about ESP8266 module click here

Download WiFiEsp library.

codes

To control LEDs or home appliances within LAN, from the library

Open WebServerLed.

To ping a server continuously

Open WebClientRepeating.

Comments

Popular posts from this blog

A Day at AltSense

Arduino Day