summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/datalogger/main.cc20
-rw-r--r--src/driver/sen5x.cc29
2 files changed, 49 insertions, 0 deletions
diff --git a/src/app/datalogger/main.cc b/src/app/datalogger/main.cc
index fd016e7..251d1fa 100644
--- a/src/app/datalogger/main.cc
+++ b/src/app/datalogger/main.cc
@@ -235,6 +235,26 @@ void loop(void)
} else {
kout << "SEN5x error" << endl;
}
+ if (sen5x.readStatus()) {
+ if (sen5x.fan_speed_warning) {
+ kout << "SEN5x warning: fan speed out of range" << endl;
+ }
+ if (sen5x.fan_cleaning_active) {
+ kout << "SEN5x info: fan cleaning active" << endl;
+ }
+ if (sen5x.gas_sensor_error) {
+ kout << "SEN5x error: gas sensor" << endl;
+ }
+ if (sen5x.rht_sensor_error) {
+ kout << "SEN5x error: RHT sensor" << endl;
+ }
+ if (sen5x.laser_failure) {
+ kout << "SEN5x error: laser current out of range" << endl;
+ }
+ if (sen5x.fan_failure) {
+ kout << "SEN5x error: fan failure" << endl;
+ }
+ }
#endif
#ifdef CONFIG_driver_veml6075
diff --git a/src/driver/sen5x.cc b/src/driver/sen5x.cc
index 2a5d6b8..9edbcd0 100644
--- a/src/driver/sen5x.cc
+++ b/src/driver/sen5x.cc
@@ -11,6 +11,13 @@
#include "driver/soft_i2c.h"
#endif
+void SEN5x::cleanFan()
+{
+ txbuf[0] = 0x56;
+ txbuf[1] = 0x07;
+ i2c.xmit(address, 2, txbuf, 0, rxbuf);
+}
+
void SEN5x::start()
{
txbuf[0] = 0x00;
@@ -48,4 +55,26 @@ bool SEN5x::read()
return true;
}
+bool SEN5x::readStatus()
+{
+ txbuf[0] = 0xd2;
+ txbuf[1] = 0x06;
+ if (i2c.xmit(address, 2, txbuf, 0, rxbuf)) {
+ return false;
+ }
+ arch.delay_ms(20);
+ if (i2c.xmit(address, 0, txbuf, 6, rxbuf)) {
+ return false;
+ }
+
+ fan_speed_warning = rxbuf[1] & 0x20;
+ fan_cleaning_active = rxbuf[1] & 0x08;
+ gas_sensor_error = rxbuf[4] & 0x80;
+ rht_sensor_error = rxbuf[4] & 0x40;
+ laser_failure = rxbuf[4] & 0x20;
+ fan_failure = rxbuf[4] & 0x10;
+
+ return true;
+}
+
SEN5x sen5x;