# Reading Temperature Sensors in the Wolfram Language on the RPi

Posted 5 years ago
30389 Views
|
10 Replies
|
30 Total Likes
|
10 Replies
Sort By:
Posted 5 years ago
 This pretty cool start, Allison, thanks for sharing! Do you mean "what to do next" with Temperature Sensors or in general with R-Pi? I can give an idea for the former. If some folks here are physicists (and who isn't honestly at least a little bit?) and they are not afraid to get their feet wet in literal and figurative senses, there is famous simple experiment:Calorimetry: Specific Heat Capacity of Copper*Copper* could be any given metal. One would need some basic lab equipment and will use R-Pi as a thermometer in that setup. One surely needs some waterproof coating for sensor - simple nail polish will do I think. The advantage of the R-Pi thermometer is that it shows record of temperature and makes it easier to judge when thermodynamic equilibrium is reached. Usually kids just have to eye-estimate when the temperature stopped changing on thermometer. But it is not clear if one can run RunScheduledTask fast enough for this experiment.
Posted 3 years ago
 I have been using the DS18B20 temperature sensor on a Raspberry Pi B for a while, but tried to do the same on a Raspberry Pi 2 and the 28-xxxx device file doesn't appear. I think I've tracked down the problem. It seems that there is a Device Tree described at https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README that allows you to enable the hardware to read the temp. sensor. I'm not certain what the setting would be. Any idea what it is?
Posted 3 years ago
 Hi, I am trying to upload temperature and humidity data from DHT 22 sensor connected to Raspberry pi into the Wolfram Datadrop. I read the GPIO documentation. I understand GPIO DeviceRead command gives the value one or zero.I used the followingDeviceRead["GPIO",4]I am getting 4-> -1 i want to read the temperature and humidity value from DHT22 sensor.I am not sure how to achieve it. Please guide me.
 The following will work with the DS18B20 but you will have to consult the DHT22 specifications in order to get your digital signal. This code saves the temperature along with the memory in use to a new Databin. You will need to enter your password and appropriate Wolfram ID. $HistoryLength=0$pollinginterval=60; initialmemory=MemoryInUse[]; CloudConnect[$WolframID, "yourpassword"]; bin=CreateDatabin[]; devicefolders[]:=FileNames["28-*", {"/sys/bus/w1/devices"}]; devicefolder[i_] := devicefolders[][[i]]; lengthdevicefolder:=Length[devicefolders[]]; devicefile[i_] := FileNameJoin[{devicefolder[i], "w1_slave"}]; read[i_] := ReadList[devicefile[i], String]; temperature[devicefile_String] := Flatten[StringCases[ReadList[devicefile, String], "t=" ~~ x___ :> ToExpression[x]/1000., 1]][[1]]; Run["sudo modprobe w1-gpio"]; Run["sudo modprobe w1-therm"]; Print[devicefolders[]]; task = CreateScheduledTask[DatabinAdd[bin,{ Sequence@@Join[{"Memory"->MemoryInUse[]-initialmemory}, Map[(StringJoin["Temperature",ToString@#]->temperature[devicefile[#]])&,Range[lengthdevicefolder] ] ] }],$pollinginterval]; StartScheduledTask[{task}]; While[Length[ScheduledTasks[]]>0,Pause[1]]; If you are using a single sensor then you could also explicitly define the data semantics of your Databin in the following way.  SetOptions[bin, "Interpretation" -> {"Memory" -> Restricted["StructuredQuantity", "Bytes"], "Temperature1" -> Restricted["StructuredQuantity", "DegreesCelsius"]}] You can then deploy a report. CloudDeploy[ FormFunction[{{"initialchoice", "Databin Key"} -> Keys@Databin["42ffdT3r"]}, Column[{StringTemplate[ "The choice for the Databin Key was choice"][<| "choice" -> #initialchoice|>], data = Databin["42ffdT3r"]; DateListPlot@TimeSeries@data["Values"][#initialchoice]}] &, "CloudCDF"] , Permissions -> "Public"]