Until now the sensors field in the Space API specification only specifies a few sensor types. As hackerspaces are using many more sensor types it’s time to define some more.

Also does the sensors field have a bad structure at the moment. Some hackerspaces use arrays while others use objects for multiple instances of a sensor type. Some encode the sensor location or name into the sensor key. This led to a big mess and it’s necessary to improve this.

There are two proposals to do so.

Making the sensors field an object with as many subelements as there are sensor types. Every subelement then contains an array of objects which are the actual sensor instances.

The second proposes to make the sensors field an array of objects which represent the sensor instances with the sensor type being an attribute.

Sensor types which can have only one instance don’t need to be a one-element array.

Con:

Client applications must iterate over the whole sensors array to get the sensor instances of a specific type.

If the array is big and if the sensor types are not one after the other but mixed (e.g. one instance of temperature then one of barometer and finally again a temperature) then it’s less obvious what sensor types are used.

Personally I tend to use the first variant. It doesn’t hurt really to use one-element arrays for sensor types that can have one instance at most.

What are your suggestions?

4 Comments

I would second the first option, it gives a clear structure and also seems more intuitive to me for integration into other apps even with growing numbers of different sensor classes, for example geiger counters, which I’m working on right now to feed uSv/h data of the Hackerspace’s location into the big soup with a Raspberry Pi and a cheap add-on board to connect the geiger tube.

rohieb

Posted June 4, 2013 at 2:38 PM

Yes, first variant, as you already said. One-element arrays are just a corner case.

slopjong

Posted July 6, 2013 at 3:31 PM

The new structure got implemented right after this discussion. Check the reference for details. If there are questions, ask.