A unified sensor abstraction layer used by all 107-system sensor libraries.
This library works for
- ArduinoCore-samd:
Arduino Zero
,MKR 1000
,MKR WiFi 1010
,Nano 33 IoT
,MKR GSM 1400
,MKR NB 1500
,MKR WAN 1300/1310
✔️ - ArduinoCore-mbed:
Portenta H7
,Nano 33 BLE
,Nano RP2040 Connect
,Edge Control
✔️ - arduino-pico:
Raspberry Pi Pico
,Adafruit Feather RP2040
, ... ✔️ - ArduinoCore-renesas:
Portenta C33
,Uno R4 WiFi
,Uno R4 Minima
, ... ✔️
#include <107-Arduino-Sensor.hpp>
/* ... */
class DummyPressureSensor : public drone::PressureSensorBase
{
public:
DummyPressureSensor()
: drone::PressureSensorBase("BMP388",
0.0 * drone::unit::pascal,
1000.0 * drone::unit::pascal,
25.0 * drone::unit::hertz,
[](drone::unit::Pressure const pressure)
{
Serial.print("[ASYNC] p = ");
Serial.print(pressure.value());
Serial.println(" Pascal");
})
{ }
virtual ~DummyPressureSensor() { }
virtual void get(drone::unit::Pressure & val) override { val = drone::unit::Pressure(1023.0 * drone::unit::pascal); }
void onExternalEvent() { onSensorValueUpdate(drone::unit::Pressure(65.8 * drone::unit::pascal)); }
};
/* ... */
DummyPressureSensor pressure_sensor;
/* ... */
void setup()
{
Serial.begin(9600);
while (!Serial) { }
Serial.println(pressure_sensor);
drone::unit::Pressure pressure_val = 0.0 * drone::unit::pascal;
Serial.print("[SYNC] p = ");
Serial.print(pressure_val.value());
Serial.println(" Pascal");
Serial.println();
pressure_sensor.onExternalEvent();
}
void loop()
{
}