View Sensor Data Locally over WiFi (JSON Data)

Documentation for JSON data obtained from a sensor is found in our Sensor JSON Documentation

Finding Your Sensor’s IP Address

You can get the same data from your PurpleAir device that it sends to the map. To do this, you will need to first connect your device to wifi so it can be assigned an IP address on your network. This IP address can then be used within the same network to access the sensor. Details on how to find the assigned IP address differ depending on the exact router or network setup you have.

Accessing JSON Data

Sending the HTTP Request

Once you have your sensor’s IP address, you can obtain data by sending it an HTTP request. For a quick test, you can use a URL in your web browser. Below, the curl utility is shown using an example sensor IP address of 192.168.1.43.

curl '192.168.1.43/json?live=true'

ip-address/json

If you send an HTTP web request to your sensor’s IP address with “/json” added to the end, you will see the data it’s most recently reported in JSON format. This data is the same that’s sent to the PurpleAir map.

Example: http://192.168.1.43/json

Note that this will show raw JSON data, not a user-friendly web page. The image below is what it might look like if you view the JSON in your web browser. Some information has been redacted.

ip-address/json?live=true

You can also use “/json?live=true” to see the latest air quality readings collected by the sensor. “/json” shows data averaged over two minutes, while air quality data viewed with “/json?live=true” is updated every second. This only applies to air quality data. Other information such as temperature, pressure, humidity, and vocs will still reflect two minute averaged values.

Example Address: http://192.168.1.43/json?live=true

Using “/json?live=true” will not change how often your device reports on the map. It will only show second-to-second data directly from your device. This data also does not update automatically in your web browser, and you’ll need to send another HTTP request (or refresh the web page) to see updated readings.

3 Likes