diff --git a/gpio_240_30_ohm_sensor.h b/gpio_240_30_ohm_sensor.h new file mode 100644 index 0000000..0d8b25b --- /dev/null +++ b/gpio_240_30_ohm_sensor.h @@ -0,0 +1,24 @@ +#ifndef gpio_240_30_ohm_sensor_h +#define gpio_240_30_ohm_sensor_h + +#include "ResistanceSensor.h" +#include "NmeaXDR.h" + +#define Resistance_Sensor_GPIO_PIN G8 + +ResistanceSensor resistanceSens; + +void gpio_240_30_ohm_sensor_report() { + ResistanceSensor_read(&resistanceSens); + gen_nmea0183_xdr("$BBXDR,G,%.1f,O,Ohms_esp32", resistanceSens.measured_resistance); +} + +void gpio_240_30_ohm_try_init() { + // for 240-30 Ohm sensors (USA standard). Good for 0-180 Ohm too (EU Standard). + ResistanceSensor_init(&resistanceSens, Resistance_Sensor_GPIO_PIN, DOWNSTREAM, 3.3, 100.0); + app.onRepeat(5000, []() { + gpio_240_30_ohm_sensor_report(); + }); +} + +#endif diff --git a/mcu_sensors.h b/mcu_sensors.h index 4cfe71a..e0a0c64 100644 --- a/mcu_sensors.h +++ b/mcu_sensors.h @@ -15,6 +15,7 @@ #include "gpio_pir_as312.h" #include "gpio_tds_cqrsentds01.h" #include "gpio_limit_switch.h" +#include "gpio_240_30_ohm_sensor.h" void mcu_sensors_scan() { i2c_ina219_try_init(&Wire1); @@ -31,6 +32,7 @@ void mcu_sensors_scan() { gpio_pir_as312_try_init(); gpio_tds_cqrsentds01_try_init(); gpio_limit_switch_try_init(); + gpio_240_30_ohm_try_init(); } void mcu_sensors_update() {