Message Boards Message Boards

3
|
11727 Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Recording a time series of simple GPIO sensor data

Posted 11 years ago
For this experiment you will need a bread board, a resistor (I used 820 ohm) and two jumper wires.

First start the wolfram language and configure the GPIO device. In this we will use GPIO pin 17 and use it for input:
DeviceConfigure["GPIO", 17 -> "Input"]

Next, connect one wire (red in the picture) to the 3.3V output and the other (green in the picture) to GPIO pin 17.

Connect the wires and the resistor on the bread board as shown:



We can check if pin 17 is reading this configuration as "high":
DeviceRead["GPIO", 17]
This should return {17->1}. If you disconnect either the red or green cable the DeviceRead command will return {17->0}.

Now let's run the same command, but record all data for 10 seconds in 0.1 second intervals and return this data as a time series:
ts = DeviceReadTimeSeries["GPIO", {10, .1}, 17]
While this command is running plug and unplug a cable a few times to get both "high" and "low" sensor readings.

At the end you can examine the data by plotting the data points:
ts["ValueList"][[1, All, 1, 2]] // ListLinePlot

POSTED BY: Arnoud Buzing
4 Replies

There is an updated version of this post available here.

POSTED BY: Ian Johnson
Not sure if this is a problem on my end (quite possibly, as our university internet is a bit quirky) but the link hangs on a "long script" error in IE and hangs indefinitely in Chrome.  
POSTED BY: BoB LeSuer
Documentation is here:

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

The syntax allows for a total time and a sampling interval: { total_time, sampling_interval }

I don't know how it ensures a particular sampling rate (I'll check with the developer).
POSTED BY: Arnoud Buzing
Arnoud,

  I can't seem to get at the documentation atm.  How does DeviceReadTimeSeries handle sampling rate and ensuring that the desired sampling rate is maintained?  
POSTED BY: BoB LeSuer
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