Developers |
Yahi Overview Relationship between Yahi and PSI Mapping Pilot Assembly Instructions Installation Instructions Developers Data FAQ |
Shamefully incomplete information for developers:
Sensor firmware source
Sensor firmware source on GitHub.
Access to map data (subject to change)
The live map script fetches a JSONP file every 30s. There is also a JSON file containing the same data.
Note that this currently contains just enough information to display the map (locations and colours, no device identification, no PM2.5 estimate). This will change in future, please make sure you’re on yahi-announce if you connect anything to this.
My hope is to provide an API in the same general shape as the one provided by Spark Labs (long-lived HTTPS connections with events pushed as they happen). There are …unsolved economic problems with doing it this way.
Access to live event stream
- Register a Spark Labs account
- Click on the Settings cog at the bottom left
- Copy the Access Token
- Use the following command
.
$ curl -sS --no-buffer 'https://api.spark.io/v1/events/yahi?access_token={accessToken}' | grep --line-buffered {deviceId}
data: {"data":"{ lpo: 181590, r: 0.605300, c: 314.227692 }","ttl":"60","published_at":"2014-07-30T02:26:16.236Z","coreid":"53ff72065075535122521387"}
data: {"data":"{ lpo: 39560, r: 0.131867, c: 69.127106 }","ttl":"60","published_at":"2014-07-30T02:26:50.753Z","coreid":"53ff72065075535122521387"}
data: {"data":"{ lpo: 0, r: 0.000000, c: 0.620000 }","ttl":"60","published_at":"2014-07-30T02:27:25.876Z","coreid":"53ff72065075535122521387"}
Drop the grep to get the events from all sensors in the Yahi network. Note that access tokens expire after 90 days, making embedded script use problematic.
To convert a series of concentration measurements (the “c:” in the data items) into an estimated PM2.5 I’m currently using the following approximation:
estimatedPm25 = 0.0889 * averageConcentration - 1.69
I don’t yet have good data about how accurate this is. Any use of this approximation should be clearly marked as an approximation.
The colour is then per the NEA’s categories:
(estimatedPm25 <= 12.0) ? "green" // Good
: (estimatedPm25 <= 55.0) ? "blue" // Moderate
: (estimatedPm25 <= 150.0) ? "yellow" // Unhealthy
: (estimatedPm25 <= 250.0) ? "orange" // Very Unhealthy
: "red" // Hazardous
Access to historical event stream
- Meng is accumulating historical data in a public S3 bucket. Thank you! (I will deal with publishing location data at some point. For those who are interested: the complication with location data is that all sensors move at least once (from their calibration period at HackerspaceSG to where their owner installs them) and sometimes more than once.)