Message Boards Message Boards

1
|
11398 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

Photocell GPIO Raspberry Pi DeviceRead

Posted 11 years ago
I am attempting to read the output of a photocell hooked up via pin 23 on the GPIO raspberry pi board. I was successful in following the python instructions available here,
but now wish to use mathmatica to accomplish something similar. 

My first step is to read through GPIO documentation and try to apply the DeviceConfigure to my photocell on pin 23.
In[1]:= DeviceConfigure["GPIO", {23 ->"output"}]
In[2]:= DeviceRead["GPIO", 23]

My understanding of the photocell is that I need to "read" it at baud 9600 but have been unable to see how this fits in with the GPIO documentation as of yet. The Photocell is wired up essentially like this, only on pin 23 instead of what looks like 18 on the GPIO breakout board. 
POSTED BY: miles perry
So what you want to do here is read the photocell voltage as a digital value.  The circuit is really just an RC circuit that allows you to "measure" the resistance of the photocell as a digital value. 

Since you are measuring you'll want to configure pin 23 as "Input".

Then you just want to do a series of readings. In the WolframLanguage, we have a function that helps you do just that.

DeviceReadTimeSeries["GPIO",{1,0.1}, 23]

will read pin 23 for 1 second at an interval of 0.1 seconds.

Check it out!

http://reference.wolfram.com/language/ref/DeviceReadTimeSeries.html

Using this, you should be able to analyze the time series and figure out the resistance.

Or if you want to try to write code similar to the python example, you can use DeviceRead instead.  This will give you a single reading.  You can put this in your own loop then.
POSTED BY: Lambert Chao
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract