Infrared if there is an object comes across

Infrared Sensor:

Infrared Sensor is a sensor that measures the light radiating from an object in front of it and detecting if the light reflected back or not. An infrared sensor consists of IR transmitter, which sends an invisible light to human being using a light emitting diode (LED) and the distance can be adjusted by an adjustable potentiometer. An infrared sensor is also consists of IR receiver which is a special photodiode that only detects infrared light. When the IR transmitter sends a light if there is an object comes across the light some of the radiation reflects back as shown in the figure below.

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

Infrared Sensor Layout:

#

Description

1

VCC

2

GND

3

OUT

4

Distance Adjustable

5

IR Receiver

6

IR Transmitter

7

Obstacle LED

8

Power LED

 

Infrared Sensor Specifications:

Operating Voltage

3.0V to 5.0V

Current

3.3V : approximately 23 mA
5.0V: approximately  43 mA

Detection Range

2cm to 30cm (Adjusted using potentiometer)

Detection Angle

35o

Active output level

Outputs Low logic level when obstacle is detected

LED

On board Obstacle Detection LED indicator
On board Power LED indicator

Dimensions

3.1cm * 1.5cm

 

Testing Infrared Sensor:

Testing Infrared Sensor Arduino code:

int inputPin = A0;void setup() {  Serial.begin(9600);  pinMode(inputPin, INPUT);} void loop() {  int inputStatus = digitalRead(inputPin);  Serial.println(inputStatus);  delay(1);} 

Schematic Diagram for Testing Infrared Sensor:

Tuning an Infrared Sensor:

1.      Put a paper on front of infrared sensor.

2.      Adjust the distance by adjusting the potentiometer until the obstacle LED turned on or from the Arduino IDE open the Serial Monitor.

 

 

 

 

LCD Display:

The display that is used in the project is 1602 or 16×2 where 2 is the number of rows and 16 is the number of characters per row. Therefore, the display can display up to 32 characters.

The problem with connecting LCD directly to an Arduino that it requires many pins. Consequently, I2C (Inter-Integrated Circuit) module is used which reduce the number of pins used to only two pins. I2C module use serial communication that sends data packages one after another through SDA (Serial Data Communication line) and SCL (Serial Clock Line). The two wires are all connected to a master which is an Arduino and multiple slaves which is all LCD.

I2C Working Principle:

When the master wants to talk to a slave. A start condition which is the switching of SDA line from high level voltage to low level voltage followed by a switching of SCL line from high level voltage to low level voltage.

After that, the data begin transformed form the master to the slave in 8 bits sequence where the SCL switch from high to low. In addition, the SDA line must remain stable when SCL is high during data transformed. An ACK (acknowledgement) at the end of the data transformed of 8 bits must be sent.

Then, other data byte of another slave start receiving data. If an ACK bits of all slave devices, sends back to the master high then the stop sequence started. The stop sequence is the switching from low to high of SCL followed by the switching from low to high of SDA.

LCD Display Layout:

#

Description

1

GND

2

VCC

3

SDA

4

SCL

5

Contrast Adjustment

6

Backlight Jumper

7

I2C Solder Addressing Selector

 

 

LCD Display Addressing:

The master which is the Arduino, starts by sending the address to one of the slave that the master wants to send data or communicate with that slave. After that, the slave comperes the address with it is own address. A low voltage of ACK bit sends back from slave to the master if the address are the same. Otherwise, the SDA line remains high and the master tries another slave.

 

The address of an LCD can be changed by soldering the solder jumpers A0,A1 and A2.

The following table shows the LCD addresses:

LCD Address

A0

A1

A2

0x27

0

0

0

0x26

0

0

1

0x25

0

1

0

0x24

0

1

1

0x23

1

0

0

0x22

1

0

1

0x21

1

1

0

0x20

1

1

1

 

Note: Zero means the solder jumpers are not bridges together. One means the solder jumpers are bridges together.

 

 

 

 

 

 

Gating Started With Cayenne:

First of All, you need to create an account with myDevices. You can use a computer or Mobil Application.

User Creation Using Computer:

1.      Go To https://mydevices.com Website and press “SIGN UP FREE”.

2.      Type your first name, last name, email address and password. Check the checkbox of “I agree to the myDevices Cayenne terms.”  and Press “GET STARTED FREE”.

 

 

3.      Cayenne is going to ask to choose a device, select Arduino.

 

4.      An Arduino IDE is needed to connect to Cayenne. To download Arduino IDE go to https://www.arduino.cc/en/Main/Software and choose your computer operating system. After that, install the program and run it.

5.      Adding Cayenne library to an Arduino IDE is needed. To add the library go to “Sketch” then “Include Library” then “Manage Libraries…”.

 

6.      Type Cayenne in the search bar then the library “Cayenne by myDevices” is going to show up. Choose the latest version then press “Install” and wait for the library to download.

7.      Verify that Cayenne library installed properly by going to “Sketch” then going to “Include Library”. Make sure that the Cayenne library included at the bottom in the “Contributed libraries” section.

8.      Change the following selections by going to “Tools”:

Board

Arduino/Genuino Mega or Mega 2560

Processor

ATmega2560 (Mega 2560).

Port

Choose the port that is connected to Arduino

9.      Go back to Cayenne website and press “Next”.

 

 

 

 

 

 

 

 

10.  Select the “Arduino Mega” then “W5500”.

 

Configuring Ethernet Shield:

1.      Ethernet Shield library is necessary in order to use the Ethernet Shield, which can be download by going to https://github.com/adafruit/Ethernet2 and press “Clone or download”. After that, press “Download ZIP”.

 

 

 

2.      Add the library by going to “Include Library” then “Add .ZIP Library…” and select the file that you download.

3.      Make sure that the library was added correctly by going to “Sketch” then “Include Library” then “Ethernet2” must be included in the libraries.

 

 

Arduino Mega Code:

 

//#define CAYENNE_DEBUG         // Uncomment to show debug messages

#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space

#include

 

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.

char token = “”;

 

void setup()

{

  Serial.begin(9600);

  Cayenne.begin(token);

}

 

void loop()

{

  Cayenne.run();

}

 

Adding a new Stuff:

1.      Go to Cayenne dashboard. After that, select “Add new…” and then go to “Device/Widget”.

2.      Select “Sensors and then “Generic”.

3.      Select “Digital Input” then Change the following:

Widget Name

Stuff Name

Select Device

Select The Arduino Mega

Connectivity

Select Digital

Pin

Select the digital pin that is connected to stuff box.

Choose Widget

Select 0/1 state

Invert Logic

Make sure that the checkbox is checked

After that, press “Step 2: Add Sensor”.

4.      The stuff is going to be added in the dashboard, which can be moved and dragged around by holding left click.

 

Edit Current Stuff Widget:

1.      Go to Cayenne dashboard. After that, press the settings icon of the stuff that needs some changes. Then, select “Settings”.

2.Edit the following settings:

Widget Name

Stuff Name

Choose Widget

0/1 2 state

Choose Display

Value

Select GPIO

Integrated GPIO ( Digital Input)

Select Channel

Select the digital pin that is connected to stuff box.

Invert Logic

Make sure that the checkbox is checked

After that, save the settings by pressing “Save”.

 

Removing a Stuff Completely:

1.      Go to Cayenne dashboard. After that, press the settings icon of the stuff that needs to be removed. Then, select “Settings”.

2.      Press “Remove”

 

 

 

 

 

Configuring Email and Mobile Number Trigger for a Stuff:

1.      Go to Cayenne dashboard. After that, press the settings icon of the stuff that needs some changes. Then, select “Trigger”.

2.      Type the stuff into the “Name your trigger” field. Then, drag the device and drop it in the if the section.

3.      Press the “- Select Trigger – “then choose the stuff.

4.      In the then section press “setup notification”.

 

5.      Press “Add custom reception”

6.      Press “Add more recipient”. After that, type email address and mobile phone number respectively.

7.      Save the settings by pressing the “Save” button. After that, the trigger is going to be added and Cayenne is going to move you to “My Triggers” section.

 

 

 

 

 

 

Editing A Trigger for a Stuff:

1.      Go to Cayenne dashboard. After that, select “Add new…” and then go to “Trigger”.

2.      Go to my triggers by pressing “My Triggers”.

3.      Edit the email and mobile number by first locating the stuff name.After that press the edit icon.

4.      Edit the information which need some changes and press the save button.

Delating a Trigger for a Stuff:

1.      Go to Cayenne dashboard. After that, select “Add new…” and then go to “Trigger”.

2.      Go to my triggers by pressing “My Triggers”.

3.      Locate the stuff name .After that press the edit icon.

4.      Press the delate button at the bottom. After that, a confirmation message is going to show up. Then, press “Confirm” button and the trigger is going to be removed.

 

 

 

Disabling and Enabling a Trigger for a Stuff:

1.      Go to Cayenne dashboard. After that, select “Add new…” and then go to “Trigger”.

2.      Go to my triggers by pressing “My Triggers”.

3.      Locate the stuff name .After that, enable or disable the trigger by switching the switch.

Note: Trigger is on if the switch is green. Otherwise, the trigger is off if the switch is gray.

 

 

 

 

 

 

 

 

https://github.com/myDevicesIoT/cayenne-docs/blob/master/docs/GETTINGSTARTED.md

https://wiki.eprolabs.com/index.php?title=IR_Obstacle_Sensor

Basics of the I2C Communication Protocol