Air Gradient Direct Integration with HE
This integration will allow you to run a virtual driver in HE that can be upgraded by the Air Gradient DIY Air quality Sensor.
What will you need to complete this:
- A computer with a usb cable and the Adruino IDE to flash updates to the Air Gradient Kit
- The Air Gradient virtual Driver driver from the provided link
- A instance of Maker API that can share the device.
To start with install the virtual driver, Create a virtual device with that driver, and then share it through your instance of Maker API.
Collect your Maker API instance API Token from the Maker API configuration page. Retrieve your Device ID number by browsing into the device and documenting it's number that is displayed in your browsers address bar. Also copy the "Send Device Command" Url provided in the lower part of the screen
For my purposes I am using the Air Gradient DIY Pro Kit Presoldered version. This integration may need to be slightly modified depending on weather you get the basic kit or the Pro kit. You may also need to tweak this if you add sensors to your setup.
The brains of the Air Quality Monitor is a Wemos D1 Min. This device can be tweaked from the Adriuno IDE. At this point you should reference the appropriate documentation from Air Gradient to download and install the Adruino IDE and be prepared to flash your DIY Kit. The directions from Air Gradient can be found here. You will want to go through the setup of the IDE and get prepped to flash your Wemos d1 Mini through the USB port. When you are prepared you will want to make the following adjustments to you adruino sketch.
Near the top of the sketch provided by Air Gradient there is a configuration section. Update the endpoint configuration to point to your Maker API instance that your sensor will work from. The easiest way to do this would be to past in the URL you copied out earlier for the "Send Device Command", then delete everything following /device/. The last slash needs to be there. Now add right below that the vlaues for the API Token and the Device id.
It should look something like this:
Now scroll down towards the bottom until you find the section for "sendToServer"
void sendToServer() {
if (currentMillis - previoussendToServer >= sendToServerInterval) {
previoussendToServer += sendToServerInterval;
String values = String(Co2)
+ "," + String(pm25)
+ "," + String(TVOC)
+ "," + String(temp)
+ "," + String(hum);
if(WiFi.status()== WL_CONNECTED){
// Serial.println(payload);
String POSTURL = APIROOT + DEVID + "/update/" + values + "?access_token=" + APITOKEN;
Serial.println(POSTURL);
WiFiClient client;
HTTPClient http;
http.begin(client,POSTURL);
// http.addHeader("content-type", "application/json");
int httpCode = http.GET();
String response = http.getString();
Serial.println(httpCode);
Serial.println(response);
http.end();
}
else {
Serial.println("WiFi Disconnected");
}
}
}
Once this is done save the sketch and then upload it to the device.
Once it comes back up you will want to go through the setup on the Air Gradient and associate the sensor to the same network your Hub is on. If you have more then one Sensor all you need to do is adjust the device id the next time you flash