summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-05-15 19:45:57 +0200
committerDaniel Friesel <derf@finalrewind.org>2022-05-15 19:45:57 +0200
commit71e891f2284e5afb47ab6d24383058dd97230355 (patch)
tree047c5649e25abc0eb1956e7081af35fdfdd9656a /include
parent14e405f5152c99e3e2db9948a8cee780e1af04a3 (diff)
add driver stub for Sensirion SEN5x PM sensor
Diffstat (limited to 'include')
-rw-r--r--include/driver/sen5x.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/include/driver/sen5x.h b/include/driver/sen5x.h
new file mode 100644
index 0000000..64e116b
--- /dev/null
+++ b/include/driver/sen5x.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2021 Daniel Friesel
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+#ifndef SEN5x_H
+#define SEN5x_H
+
+class SEN5x {
+ private:
+ SEN5x(const SEN5x &copy);
+ unsigned char const address = 0x69;
+ unsigned char txbuf[2];
+ unsigned char rxbuf[24];
+
+ public:
+ SEN5x() {}
+
+ unsigned short const PM_INVALID = 0xffff;
+ signed short const TEMPERATURE_INVALID = 0x7fff;
+ signed short const HUMIDITY_INVALID = 0x7fff;
+ signed short const VOC_INVALID = 0x7fff;
+ signed short const NOX_INVALID = 0x7fff;
+
+ /*
+ * PM1.0 value, scaled by 10.
+ * PM1.0 [µg/m³] = pm10 / 10
+ */
+ unsigned short pm1;
+
+ /*
+ * PM2.5 value, scaled by 10.
+ * PM2.5 [µg/m3] = pm2_5 / 10
+ */
+ unsigned short pm2_5;
+
+ /*
+ * PM4.0 value, scaled by 10.
+ * PM4.0 [µg/m3] = pm4 / 10
+ */
+ unsigned short pm4;
+
+ /*
+ * PM10 value, scaled by 10.
+ * PM10 [µg/m3] = pm10 / 10
+ */
+ unsigned short pm10;
+
+ /*
+ * Temperature, scaled by 200.
+ * Temperature [°c] = temperature / 200
+ */
+ signed short temperature;
+
+ /*
+ * Relative Humidity, scaled by 100.
+ * Relative Humidity [%] = humidity / 100
+ */
+ signed short humidity;
+
+ /*
+ * VOC Index, scaled by 10.
+ * VOC index = voc / 10
+ */
+ signed short voc;
+
+ /*
+ * NOx Index, scaled by 10.
+ * NOx index = nox / 10
+ */
+ signed short nox;
+
+ void start();
+ void stop();
+
+ bool read();
+};
+
+extern SEN5x sen5x;
+
+#endif