Message Boards Message Boards

Read GPIO devices?

GROUPS:

I was wondering if it was possible to use DeviceRead to read a temperature sensor. So far Mathematica will only produce 1's and 0's from device read. Is importing the device data from an external file the only way to get my temperature data and other exact numerical data into Mathematica? Why doesn't device read read the output voltage?

Thanks for your time.

POSTED BY: Owen Riemer
Answer
3 months ago

Hi Owen,

What kind of temperature sensor are you interested in reading from? We also support interfacing with I2C devices : http://reference.wolfram.com/language/ref/device/I2C.html

Thanks,

Ian

POSTED BY: Ian Johnson
Answer
3 months ago

We read temperature from a USB connected serial device on a laptop. What platform and temperature device are you using?

POSTED BY: Neil Singer
Answer
2 months ago

I have a TMP36 analog temperature sensor. My goal is to take some measurements and successfully plot them in Mathematica. So far I havn't been able to access my readings measured by the temperature sensor. I prefer to program directly through Mathematica so I'm going to look into the I2C devices for the future. Currently, I'm having trouble with connecting the devices on the pins to Mathematica.

POSTED BY: Owen Riemer
Answer
2 months ago

Hello again,

As Neil was saying, the temperature sensor you have is analog, and so there is no way to connect it directly to the pins on the Pi and read the analog voltage of the sensor. However you can use a simple ADC chip to convert the analog voltage into a digital stream usable by the Pi. For example, this is an ADC chip that can send the digital data back to the Pi + Wolfram Engine over I2C : https://www.adafruit.com/product/1083

Another simple option would just be to connect the TMP36 to an Arduino on one of the analog pins (say A0 for example), and then connect the Arduino to the Raspberry Pi over USB. Then in Mathematica you could read from the TMP36 sensor like so:

DeviceOpen["Arduino","/dev/ttyAMA0"]
( DeviceRead["Arduino","A0"] - Quantity[0.5,"Volts"] ) / (Quantity[10,"Millivolts"] / Quantity[1,"DegreesCelsius"] )

Thanks,

Ian

POSTED BY: Ian Johnson
Answer
2 months ago

Owen,

What hardware is Mathematica running on? The sensor is analog only so you need an analog to digital converter or a different temperature device but everything depends on your hardware.

Regards

POSTED BY: Neil Singer
Answer
2 months ago

Group Abstract Group Abstract