This week's assignment

Write an Application to make a secondary device perform some tasks. I have chosen to use the Raspberry Pi board and Python scripting to complete the assignment. This will also play a part in my hummingbird feeder project.

References

Getting Started with Raspberry Pi
Getting To Know The $35 ARM-Powered Linux Computer
By
Publisher: Maker Media, Inc
Released: December 2012

Hardware Setup

On my final project, these signals will come from my sensor board to the Pi board. Since the sensor board is not completed yet, I created a breadboard setup to simulate the incoming signals. Main points of circuit below:
Using 3.3V source from PI GPIO pins
Using ground from PI GPIO pins Using Broadcom naming convention for GPIO pins
Each of the 4 circuits consists of a push button and a 10K resistor
Buttons 1,2,3,and 4 are connected back to GPIO pins 23,24,25 and 22 respectively.
Issue: Original intent was to use Pi camera commands but camera module no longer appears to be working (I did 2 hours of debug and then had to move on without it).



Breadboard setup


Python Script


from datetime import datetime
from time import sleep
import RPi.GPIO as GPIO
from sys import exit

GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN)
GPIO.setup(24, GPIO.IN)
GPIO.setup(25, GPIO.IN)
GPIO.setup(22, GPIO.IN)
print ("step1")
log = open("./log.txt", "w")
print ("step2")
while True:
    now = str(datetime.now())
    try:
        if (GPIO.input(23) == True):
            print("Btn1")
            log.write(now + "Button 1")
            log.flush()
            sleep(.9)   
        if (GPIO.input(24) == True):
            print("Btn2")
            log.write(now + "Button 2")
            log.flush()
            sleep(.9)   
        if (GPIO.input(25) == True):
            print("Btn3")
            log.write(now + "Button 3")
            log.flush()
            sleep(.9)   
        if (GPIO.input(22) == True):
            print("Btn4")
            log.write(now + "Button 4")
            log.flush()
            sleep(.9)
    except KeyboardInterrupt:
        log.close()
        exit()   


Output

After some small debugging, the program worked and sent the data to the log file.

Log picture
View from Log File(data arranged for clarity)


Planned Improvements

At this time I know the basic methodology for getting data out from the Raspberry Pi. I will work on some improvements for Final Project:

Back to Index