sjwaight/airsensorgateway

By sjwaight

Updated over 2 years ago

Simple .NET 6 Web API that acts as an Azure IoT Hub gateway for a Purple Air PA-II sensor.

Image
0

42

Edge Gateway for PurpleAir PA-II to Azure IoT Hub

This repository contains a simple HTTP-MQTT gateway that can be used with any PurpleAir PA-II air quality sensor to filter and send data on to an Azure IoT Hub instance.

While the PurpleAir devices have pre-configured (if undocumented) support for Azure IoT Hub, I was unable to get this functioning, so decided to go ahead an build this solution.

The source code for this solution can be found on GitHub.

Runtime Configuration

When you run the application it expects the following four configuration items.

  • IOTHUB_DEVICE_CONNECTION_STRING: full connection string for the Azure IoT Hub instance / device you wish to publish events to.
  • API_ACCESS_KEY: a HTTP header key you will set on your PA-II device so that you can ensure only an authorised device can use your gateway.
  • ALLOWED_SENSOR_ID: the hostname of the Sensor that will be using the gateway. This will be in the format of a MAC address.
  • SKIP_EVENT_COUNT: if you want to limit the number of events sent to Azure, you can tell the gateway to skip every X message. Set to 0 if you want to send all events.

You may choose to limit events sent even though a PA-II device will send total events that fit within the free tier of Azure IoT Hub in any given month. There may be other upstream services you want to use that have lower limits (for example, Anomaly Detector).

Docker Pull Command

docker pull sjwaight/airsensorgateway