Hey together, does anyone knows the “sensebox”?
www.sensebox.de
I’am looking for a possibility to add it into pimatic?!
Thank you!
-
Sensebox
-
@HarrySteff never heard of it. Is it some kind of weather station?
There is somewhat of an API, but i cant really see what the benefits are. As always, if there is an API, it can be integrated somehow.
So, first question, what the hell is it
-
@HarrySteff said in Sensebox:
Hey together, does anyone knows the “sensebox”?
Yes, it is a startup founded by a few individuals at Uni Münster. As far as I know they started with Sensebox.Edu which is a tinkering toolbox to support education at schools. Sensebox.Home is multi-sensor toolbox to build your own sensor device. For example, it can be used to collect environmental data and to optionally, feed it into the open, cloud-based service SenseMap. Sensebox.Home kit basically contains an Arduino UNO with a sensor shield and light, pressure, temperature, and humidity sensors. The company is dedicated to Open Science and Open Source. So, most information like software, documentation, and hardware specs are publicly available.
Did you purchase Sensebox.Home kit? I think it is a nice toolbox for self education. As the kit is open source there are various options for integrating it with Pimatic. Amongst these it should be possible to use Firmata on the Arduino along with pimatic-johnny-five.
"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law
-
Hey mwittig,
thank you for your explanation. Yes i ordered a sensebox:home… Iam waiting for it. It is connected to the “opensensemap” opensensemap.org
I’am looking for a kind of “middleware” to collect the data from “a couple” of Senseboxes and send them (via HTTP-POST) somwhere else. I do not know, if pimatic is the right thing for this, but lets give a try.
maybe thethingsnetwork.org is an alternative to manage more than 1 Sensebox… -
Hello, my box is here and a think this little thing is absolutely cool
Now i have a question, i’d like to send data from my sensebox (opensensemap.org) via json into variables of Pimatic:https://api.opensensemap.org/boxes/596e0dd38ecc8900101c2936
this for examle gives me all measurements of my box in a json format.
How can i get this into variables?
Can anybody help me with this?
Here is the documentation:
https://docs.opensensemap.org/Thank you very much!
-
@HarrySteff create a bash to get the json through curl en then use the app “jq” to filter what you want.
sudo apt-get install jq
You could also use sed etc but i think jq is more elegant.
Example:
curl -s -u http://x.x.x.x/api/variables/alarm | jq -r ".variable.value"
.variable is the table i want the value from and .value is ofc the value.
Will give me my alarm variable.
-
@Gleno0h
Many thanks for your suggestion! I will have a try… Hope that i will get this working… i did Not fully understand this, but Maybe i will get it by try and error -
@HarrySteff if no one replies i will give u a example for your case later. Currently at work.
-
Allright here goes;
First lets try to get the file, put this in your raspberry command line(doh)
sudo curl https://api.opensensemap.org/boxes/596e0dd38ecc8900101c2936
Output;
{"_id":"596e0dd38ecc8900101c2936","createdAt":"2017-07-18T13:32:03.732Z","updatedAt":"2017-08-01T14:23:23.668Z","name":"Test2","boxType":"fixed","grouptag":"Bad_Hersfeld","exposure":"outdoor","model":"homeWifiFeinstaub","sensors":[{"title":"Temperatur","unit":"°C","sensorType":"HDC1008","icon":"osem-thermometer","_id":"596e0dd38ecc8900101c2937","lastMeasurement":{"value":"27.67","createdAt":"2017-08-01T14:23:23.664Z"}},{"title":"rel. Luftfeuchte","unit":"%","sensorType":"HDC1008","icon":"osem-humidity","_id":"596e0dd38ecc8900101c2938","lastMeasurement":{"value":"53.16","createdAt":"2017-08-01T14:23:23.664Z"}},{"title":"Luftdruck","unit":"hPa","sensorType":"BMP280","icon":"osem-barometer","_id":"596e0dd38ecc8900101c2939","lastMeasurement":{"value":"987.86","createdAt":"2017-08-01T14:23:23.664Z"}},{"title":"Beleuchtungsstärke","unit":"lx","sensorType":"TSL45315","icon":"osem-brightness","_id":"596e0dd38ecc8900101c293a","lastMeasurement":{"value":"740.00","createdAt":"2017-08-01T14:23:23.664Z"}},{"title":"UV-Intensität","unit":"μW/cm²","sensorType":"VEML6070","icon":"osem-brightness","_id":"596e0dd38ecc8900101c293b","lastMeasurement":{"value":"11.25","createdAt":"2017-08-01T14:23:23.664Z"}},{"title":"PM10","unit":"µg/m³","sensorType":"SDS 011","icon":"osem-cloud","_id":"596e0dd38ecc8900101c293c","lastMeasurement":{"value":"6.00","createdAt":"2017-08-01T14:23:23.664Z"}},{"title":"PM2.5","unit":"µg/m³","sensorType":"SDS 011","icon":"osem-cloud","_id":"596e0dd38ecc8900101c293d","lastMeasurement":{"value":"3.10","createdAt":"2017-08-01T14:23:23.664Z"}},{"_id":"597083342e9396000fd09586","icon":"osem-volume-up","sensorType":"mic","unit":"db","title":"Umgebungslautstärke"}],"loc":[{"geometry":{"coordinates":[9.675063,50.870084],"type":"Point"},"type":"feature"}],"description":"TestSenseBOX"}
Oh snap, thats not exactly parsable, is it?
Lets change that. Note the JQ command;sudo curl https://api.opensensemap.org/boxes/596e0dd38ecc8900101c2936 | jq '.'
Output;
{ "_id": "596e0dd38ecc8900101c2936", "createdAt": "2017-07-18T13:32:03.732Z", "updatedAt": "2017-08-01T14:23:23.668Z", "name": "Test2", "boxType": "fixed", "grouptag": "Bad_Hersfeld", "exposure": "outdoor", "model": "homeWifiFeinstaub", "sensors": [ /// THIS IS OUR SUBCATEGORY { "title": "Temperatur", "unit": "°C", "sensorType": "HDC1008", "icon": "osem-thermometer", "_id": "596e0dd38ecc8900101c2937", "lastMeasurement": { "value": "27.67", "createdAt": "2017-08-01T14:23:23.664Z" } }, { "title": "rel. Luftfeuchte", "unit": "%", "sensorType": "HDC1008", "icon": "osem-humidity", "_id": "596e0dd38ecc8900101c2938", "lastMeasurement": { "value": "53.16", "createdAt": "2017-08-01T14:23:23.664Z" } }, { "title": "Luftdruck", "unit": "hPa", "sensorType": "BMP280", "icon": "osem-barometer", "_id": "596e0dd38ecc8900101c2939", "lastMeasurement": { "value": "987.86", "createdAt": "2017-08-01T14:23:23.664Z" } }, { "title": "Beleuchtungsstärke", "unit": "lx", "sensorType": "TSL45315", "icon": "osem-brightness", "_id": "596e0dd38ecc8900101c293a", "lastMeasurement": { "value": "740.00", "createdAt": "2017-08-01T14:23:23.664Z" } }, { "title": "UV-Intensität", "unit": "μW/cm²", "sensorType": "VEML6070", "icon": "osem-brightness", "_id": "596e0dd38ecc8900101c293b", "lastMeasurement": { "value": "11.25", "createdAt": "2017-08-01T14:23:23.664Z" } }, { "title": "PM10", "unit": "µg/m³", "sensorType": "SDS 011", "icon": "osem-cloud", "_id": "596e0dd38ecc8900101c293c", "lastMeasurement": { "value": "6.00", "createdAt": "2017-08-01T14:23:23.664Z" } }, { "title": "PM2.5", "unit": "µg/m³", "sensorType": "SDS 011", "icon": "osem-cloud", "_id": "596e0dd38ecc8900101c293d", "lastMeasurement": { "value": "3.10", "createdAt": "2017-08-01T14:23:23.664Z" } }, { "_id": "597083342e9396000fd09586", "icon": "osem-volume-up", "sensorType": "mic", "unit": "db", "title": "Umgebungslautstärke" } ], "loc": [ { "geometry": { "coordinates": [ 9.675063, 50.870084 ], "type": "Point" }, "type": "feature" } ], "description": "TestSenseBOX" }
Ah, thats betters. As you can see, sensors has subcategories, ill just asume you want those. Now, instead of using jq ‘.’, we select the sensors like so:
sudo curl https://api.opensensemap.org/boxes/596e0dd38ecc8900101c2936 | jq '.sensors'
Output;
[ //<<-- start of array { "title": "Temperatur", "unit": "°C", "sensorType": "HDC1008", "icon": "osem-thermometer", "_id": "596e0dd38ecc8900101c2937", "lastMeasurement": { "value": "27.67", "createdAt": "2017-08-01T14:23:23.664Z" } }, { "title": "rel. Luftfeuchte", "unit": "%", "sensorType": "HDC1008", "icon": "osem-humidity", "_id": "596e0dd38ecc8900101c2938", "lastMeasurement": { "value": "53.16", "createdAt": "2017-08-01T14:23:23.664Z" } }, { "title": "Luftdruck", "unit": "hPa", "sensorType": "BMP280", "icon": "osem-barometer", "_id": "596e0dd38ecc8900101c2939", "lastMeasurement": { "value": "987.86", "createdAt": "2017-08-01T14:23:23.664Z" } }, { "title": "Beleuchtungsstärke", "unit": "lx", "sensorType": "TSL45315", "icon": "osem-brightness", "_id": "596e0dd38ecc8900101c293a", "lastMeasurement": { "value": "740.00", "createdAt": "2017-08-01T14:23:23.664Z" } }, { "title": "UV-Intensität", "unit": "μW/cm²", "sensorType": "VEML6070", "icon": "osem-brightness", "_id": "596e0dd38ecc8900101c293b", "lastMeasurement": { "value": "11.25", "createdAt": "2017-08-01T14:23:23.664Z" } }, { "title": "PM10", "unit": "µg/m³", "sensorType": "SDS 011", "icon": "osem-cloud", "_id": "596e0dd38ecc8900101c293c", "lastMeasurement": { "value": "6.00", "createdAt": "2017-08-01T14:23:23.664Z" } }, { "title": "PM2.5", "unit": "µg/m³", "sensorType": "SDS 011", "icon": "osem-cloud", "_id": "596e0dd38ecc8900101c293d", "lastMeasurement": { "value": "3.10", "createdAt": "2017-08-01T14:23:23.664Z" } }, { "_id": "597083342e9396000fd09586", "icon": "osem-volume-up", "sensorType": "mic", "unit": "db", "title": "Umgebungslautstärke" } ] //<<-- end of array
Ok, but now, There are no more main categories so how the hell do we select temperature or humidty?
We divide it. The first one, temperature is always 0, so execute this;
sudo curl https://api.opensensemap.org/boxes/596e0dd38ecc8900101c2936 | jq '.sensors[0]'
Output;
{ "title": "Temperatur", "unit": "°C", "sensorType": "HDC1008", "icon": "osem-thermometer", "_id": "596e0dd38ecc8900101c2937", "lastMeasurement": { "value": "27.67", "createdAt": "2017-08-01T14:23:23.664Z" } }
Okay, so now we have entered the temperature section of the json file, now we simply select our data:
sudo curl -s https://api.opensensemap.org/boxes/596e0dd38ecc8900101c2936 | jq -r '.sensors[0].lastMeasurement.value'
Output;
27.67
Please note i have added the -r to remove the “” from the output. I also added the -s tag to the curl command to only output jq
Now, if you want the second category value just change the 0 to 1, 2 etc
sudo curl -s https://api.opensensemap.org/boxes/596e0dd38ecc8900101c2936 | jq -r '.sensors[1].lastMeasurement.value'
Output(humidity):
53.16
I hope i was clear on how to use the lovely json parser JQ!!
Easy part; create a shellsensor device called Temperature and as command do;
sudo curl -s https://api.opensensemap.org/boxes/596e0dd38ecc8900101c2936 | jq -r '.sensors[0].lastMeasurement.value'
Voila!
-
@Gleno0h
WOW… Thank you so much… i will try this today… very great explanation!
Big thanks again!
I will tell you if everything works… -
@Gleno0h Thank you again… it Works like a charm… jq is a very cool tool!!! I have one more question: Could you please tell me how i can get the values under “geometry.coordinates” in two separated strings? Lat and Long? Thank you so much again…
-
@HarrySteff yeah sure.
First value:
sudo curl -s https://api.opensensemap.org/boxes/596e0dd38ecc8900101c2936 | jq -r '.loc[0].geometry.coordinates[0]'
Output:
9.675063
Second value:
sudo curl -s https://api.opensensemap.org/boxes/596e0dd38ecc8900101c2936 | jq -r '.loc[0].geometry.coordinates[1]'
Output:
50.870084
No problem
-
Oh man… Thank you!
I Tried and tried but i did Not get this with those brackets [] 🙈 Thanks again -
@HarrySteff it is easier then you think
sudo curl -s https://api.opensensemap.org/boxes/596e0dd38ecc8900101c2936 | jq -r '.loc[0].geometry.coordinates' [ 9.675063, 50.870084 ]
As you can see, there are 2 brackets in the .coordinates table so it has to be .coordinates[0] for first entry, [1] for the second value.
Glad i could help
-
This post is deleted!