This library allows you to read data from Aranet4 devices using Bluetooth.
To save memory, this library is using NimBLE bluetooth stack. Install it from library manager or get it here: h2zero/NimBLE-Arduino
class MyAranet4Callbacks: public Aranet4Callbacks {
uint32_t onPinRequested() {
Serial.println("PIN Requested. Enter PIN in serial console.");
while(Serial.available() == 0)
vTaskDelay(500 / portTICK_PERIOD_MS);
return Serial.readString().toInt();
}
};
setup()
function:
Aranet4::init();
String addr = "00:01:02:03:04:05";
Aranet4 ar4(new MyAranet4Callbacks());
...
bool secure = true;
if (ar4.connect(addr, secure) == AR4_OK) { AranetData data = ar4.getCurrentReadings(); Serial.printf("CO2: %i ppm\n", data.co2); Serial.printf("Temperature: %.2f C\n", data.temperature / 20.0); Serial.printf("Pressure: %.1f C\n", data.pressure / 10.0); Serial.printf("Humidity: %i %%\n", data.humidity); Serial.printf("Battery: %i %%\n", data.battery); Serial.printf("Interval: %i s\n", data.interval); Serial.printf("Ago: %i s\n", data.ago); } else { Serial.println("read failed"); } ar4.disconnect();
You can set `bool secure=false;`, if Aranet4 is running v1.2.0 or later, with Smart Home Integrations enabled. This will skip pairing process. However, you will be only available to use `getCurrentReadings()` function. Geting history still requires device pairing/secure mode.
Measurement data is stored in original binary format. This means temperature must be divided by 20 and pressure must be divided by 10 to get correct values.