I’m just getting started with DataDrop. I’ve got a Particle Photon logging sensor data to a Databin, which was super easy and great. Now I’ve got some data to work with.
I’m using the Dev Platform notebook, I can see the data bin with Databins[], I can check there is data present with TimeSeries[Databin[“”]], which tells me that I’ve got 700 data points from 03 Oct to 04 Oct.
But when I use DateListPlot on that same databin, i get a plot that is scaled from 0.0 to 1.0 on the Y axis and 00:00:00 to 00:00:01 on the X axis. My data values are between 70 and 80. I can’t find any reference on how to set proper scaling on this function.
Then when I use Dataset on that bin my data looks like this:
Any ideas on how I can get this data set time stamp in the proper format? I don’t send any time info when the device sends the sensor data, I think that is handled automagically by Wolfram.
DateListPlot should just plot your data. If it shows your values being betwen 0 and 1 then it is probably because the data you are giving it is between 0 and 1.
Can you give a small snippet of your data? Or something to help us reproduce the problem?
One thing you can do is to run Normal on the dataset. This will turn it into a list, which is easier to copy.
When you make a Databin, it will assume everything is a string unless you specify some kind of type, like “Number”. Here is how work aroudn the current problem:
(* get the data as a simple list of values *)
data = Normal[TimeSeries[Databin["7j5P9Pz2"]]["temp1"]]
(* turn the temps from strings into numbers *)
data = data /. {date_, temp_} :> {date, ToExpression@temp}
(* alternatively you could turn the temps from strings into numbers this way *)
data = MapAt[ToExpression, data, {All, 2}]
DateListPlot will now work with the variable “data”.
But when I use DateListPlot on data, I still get a plot that is scaled from 0.0 to 1.0 on the Y axis and 00:00:00 to 00:00:01 on the X axis, as originally described by this question asker. Any ideas?
Mathematica does a lot of formatting to make code more readable, but it’s sometimes confusing at first. You can think of InputForm as a function that shows you what your code “actually” looks like.
Databin by default will make strings. You have to ask it to interpret it’s input as anything else.
To fix your code, let’s make a function that takes a pair of values and runs “ToExpression” on the last part. ToExpression in this case will take a string of a number and turn it into a number: