My name is Tim and I've just purchased a Beaglebone Black (BBB) revision C1 which runs Debian Linux. This little computer will make a nice little controller for a few projects I have in mind. I choose the BBB for it's size, it fits in an Altoids tin, though I'll be using at least two capes so the projects will not be housed in a tin.
I spent an evening learning and experimenting with a breadboard, some jumper wires and some simple components such as LEDs, switches, resistors, and a thermistor.
I managed to program the BBB to flash a LED, turn on the LED with a switch, read the voltage from the thermistor and then combined two programs to monitor the thermistor and turn on the LED when the voltage rose above a certain level and off again when it dropped below. This code will be the start of my Brew Chamber Controller.
Here is the thermistor.py code:
#############################################################################
#!/usr/bin/python
import Adafruit_BBIO.ADC as ADC
import Adafruit_BBIO.GPIO as GPIO
import time
import math
ADC.setup()
GPIO.setup("P8_12", GPIO.OUT)
#setup the values used for calculations dependent on the thermistor we are using
r_bias = 10000 #voltage divider resistance used 10k ohms
r_alpha = .09919
Bvalue = 3650 #from the thermistor data sheet (B value)
c2kelvin = 273.15 #this is a constant
print "\n\nPress CTRL-C to exit program.\n\n"
while True: #loop through this code forever or until CTRL-C is pressed
adcValue = ADC.read("P9_36") #read the thermistor voltage divider reading
#do some calculations
r_therm = ((1/adcValue)-1)*r_bias
t_c = 10*((Bvalue/math.log((r_therm/r_alpha)))-c2kelvin)/10 #calculate Celsius
t_f = (t_c * 9/5) +32 #calculate Fahrenheit
print "ADC:", adcValue," | Resistance:", r_therm," | Celsius:", t_c," | Fahrenheit:", t_f
if adcValue > 0.35:
#turn on the LED
GPIO.output("P8_12", GPIO.HIGH)
else:
#turn off LED
GPIO.output("P8_12", GPIO.LOW)
time.sleep(2) #sleep for 2 seconds then repeat
############################################################################
Pretty simple stuff really.
Some things I've done to my BBB and laptop so far in order to accomplish this:
- Installed Putty on my laptop (SSH to BBB)
- Updated installed applications (apt-get update & apt-get upgrade)
- Ensure Python was installed on the BBB
- Installed the Adafruit BBB-IO Python library
- Installed VNC Viewer on the laptop (to see BBB desktop)
- Brew Chamber Controller
- Home Environment Control
- Autonomous Quad Copter Control
Cheers!
No comments:
Post a Comment