Monday, June 23, 2014

Measuring Light with a Beaglebone Black

I spent Friday evening at the Milwaukee Makerspace experimenting with a photoresistor on my Beaglebone Black.  I am still trying to learn more about how the BBB works and am going through some learning tutorials on the Adafruit website.  They have one titled Measuring Light with a BeagleBone Black that I was using.

Before I could do anything, I had to enable ADC in the slots file.  The slots file is in the /sys/devices/bone.capemgr.9 folder.  I did not have the correct rights to modify the file.  This was fixed by typing 
sudo chmod 666 slots
to give all users rights to modify the file.

Next, I enabled ADC on the BBB by typing 
echo BB-ADC > slots
while in the folder where the slots file is stored.  I did not have to reboot the BBB.  The change took affect immediately.

I spent a couple of hours playing around with the circuit.  It is extremely simply since it only has a resistor and the photoresistor.  The circuit is a voltage divider.  Basically, the BBB puts a constant 1.8 volts into the circuit.  The resistor keeps some of the voltage from going to ground.  The pin that accepts the incoming voltage on the BBB measures different voltages depending on how much light is coming in to the photoresistor.  The more light that comes in, the more voltage goes to the BBB in pin and not to ground.

I'm not really sure why it works that way but it does.

So, my first experiment with analog readings on the BBB worked.  Next, I would like to figure out how to measure DC volts on the BBB.  That will be a bit tricky because the analog input pins will not take more than 1.8 volts.