July 22, 2018

IoT Project 6 : RaspberryPi 2 and REES52 Proximity Sensor(Avinash Aeron)

Let us try the Proximity Sensor (REES52) this time.

Required items:
– Raspberry PI 3 & SD Card with ubuntu-mate Operating System https://www.raspberrypi.org/products/ra … 3-model-b/
– Proximity Sensor (REES52) pack
– 3 x pitch jumpers
Preparing Raspberry PI 3 & SHDC:

Create the setup as follows:
1. Download below two as described https://ubuntu-mate.org/raspberry-pi/
– 7-Zip to extract the image.
– Win32 Disk Imager to write the image.
2. Extracted ‘ubuntu-mate from zip and flashed SHCD using Win32 Disk Imager
3. Put the SHCD into slot and power-up the Raspberry PI 2.
4. After ubuntu-mate is up, execute following on the terminal:

CODE: SELECT ALL
sudo apt-get update
sudo apt-get upgrade

5. If you have not installed git, install it now:

CODE: SELECT ALL
sudo apt-get install git

6. Type this script in a pluma Text Editor and set type from “Plain Test” to “Python” and save this as “ProximitySensor.py” in your Desktop :

CODE: SELECT ALL
"""
ePro Labs PIR Sensor REES52 Proximity Sensor. using Raspberry Pi.

"""
# Import all the libraries we need to run
import sys
import RPi.GPIO as GPIO
import os
from time import sleep
import datetime

TRUE = 1
FALSE = 0

DEBUG = 1

# Setup the pins we are connect to
SR501_pin = 16

#Setup our API and delay
#myAPI = "***Insert Your API CODE HERE***"
myDelay = 1 #how many seconds between posting data

GPIO.setmode(GPIO.BCM)
GPIO.setup(SR501_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

def getSensorData():
return (str(GPIO.input(SR501_pin)))

# main() function
def main():

print 'Detecting Proximity......'

while True:

try:
PIRDETECT = getSensorData()

LT = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S')

if GPIO.input(SR501_pin):
print LT + " : "  + " WARNING !! Too Close !! "
else:
print LT + " : " + " Safe ! Go ahead."

sleep(int(myDelay))
except:
print "REES52 :"
print 'exiting...... Thank You for Testing Proximity Sensor ! GOODBYE !!'

break

# call main
if __name__ == '__main__':
main()

7. Install the REES52 in the Raspberry Pi 2 using Jump wires by the following process :
VCC – Pin 4
GND – Pin 34
OUT – Pin 36

[b]NOTE :[b] Check if the Proximity Sensor is working by seeing if the red light is switching on bringing a wooden or steel object or a cardboard near it. You can test it by bringing it very close to your hand too.

ProximitySensor_Active.png
No Proximity detected
ProximitySensor_Idle.png
Proximity detected

8. Type this in the mate Terminal :

CODE: SELECT ALL
cd Desktop/
sudo python ProximitySensor.py

9. Bingo! The sensor starts working!

ATTACHMENTS
ProximitySensor.png
Sensor working at mate Terminal

Leave a Reply

Your email address will not be published. Required fields are marked *