Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geiger sensor #144

Merged
merged 43 commits into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
eee4b0c
Geiger first test version
roberbike Mar 16, 2022
b89b90c
serial mensage changued
roberbike Mar 16, 2022
831d879
minor changues
roberbike Mar 16, 2022
c527a4c
Geiger example
roberbike Apr 16, 2022
134b204
fixed esp8266
roberbike Apr 18, 2022
02e1887
esp8266 serial print values
roberbike Apr 18, 2022
e5ceedf
Changued PINTIC for esp8266
roberbike Apr 23, 2022
184765a
CAJOE Geiger Counter refactored
iw2lsi Jun 7, 2022
e7bf179
Merge branch 'master' of github.com:iw2lsi/canairio_sensorlib into fi…
hpsaturn Jun 8, 2022
2cafc54
Merge pull request #134 from roberbike/Geiger
hpsaturn Jun 8, 2022
a45cd13
Merge branch 'geiger_sensor' of https://github.com/kike-canaries/cana…
hpsaturn Jun 8, 2022
5f42833
code cleanup
iw2lsi Jun 9, 2022
e755c65
Merge branch 'kike-canaries:master' into moving_sum_feature
iw2lsi Jun 9, 2022
15aa0f3
Merge branch 'moving_sum_feature'
iw2lsi Jun 9, 2022
d24b36f
Merge branch 'master' of github.com:kike-canaries/canairio_sensorlib …
hpsaturn Jun 9, 2022
15dedca
Merge branch 'devel' of github.com:kike-canaries/canairio_sensorlib i…
hpsaturn Jun 9, 2022
872317a
moving sum is now evaluated on a 60s timeline, 1 sample every second;…
iw2lsi Jun 9, 2022
9610490
CAJOE example reviewed
iw2lsi Jun 9, 2022
b48354a
added new example test and changed src_filter directive to new one
hpsaturn Jun 9, 2022
92422b5
renamed the basic example for radiation_CAJOE
hpsaturn Jun 9, 2022
0a44fd2
ESP8266: GEIGER_PINTIC temporarily configured as INPUT_PULLUP; ESP826…
iw2lsi Jun 10, 2022
d95aa6b
CAJOE Geiger counts fixed for ESP8266: pulses are counted onces (as e…
iw2lsi Jun 13, 2022
f567429
Merge branch 'master' of github.com:iw2lsi/canairio_sensorlib into mo…
hpsaturn Jun 13, 2022
c4991eb
FIX compilation errors by forcing [esp32_common] platform = espressif…
iw2lsi Jun 13, 2022
ade67b1
double counting issue on TTGO-TDisplay not detected anymore w/ using …
iw2lsi Jun 15, 2022
9e8a768
Merge pull request #139 from iw2lsi/moving_sum_feature
hpsaturn Jun 28, 2022
a7623f6
Merge branch 'master' of github.com:kike-canaries/canairio_sensorlib …
hpsaturn Jun 28, 2022
a67c231
Merge branch 'devel' of github.com:kike-canaries/canairio_sensorlib i…
hpsaturn Jul 29, 2022
7a8a852
Merge branch 'devel' of github.com:kike-canaries/canairio_sensorlib i…
hpsaturn Sep 13, 2022
fbe2b23
set build flag for complete test of Geiger version
hpsaturn Sep 13, 2022
e621eb9
Merge branch 'master' of github.com:kike-canaries/canairio_sensorlib …
hpsaturn Jul 6, 2023
a9d2644
fixed issue on uncompleted sample for CAJOE
hpsaturn Jul 6, 2023
2224382
fixed issues with atmelsam architecture
hpsaturn Jul 6, 2023
808dc88
complete refactor of Geiger implementation
hpsaturn Jul 11, 2023
824a24e
fixed architecture issue for atmelsam
hpsaturn Jul 11, 2023
9414691
minor fix for possible issue on Geiger getters
hpsaturn Jul 12, 2023
68f1c94
added getter instead public access to geiger fields
hpsaturn Jul 13, 2023
0343187
added log notification of pin selected
hpsaturn Jul 13, 2023
64344a4
fix issue and object constructor refactor
hpsaturn Jul 13, 2023
7bf37bb
removed specif test for Geiger sample. (only architecture tests)
hpsaturn Jul 14, 2023
a4541b6
added missing init Geiger sample call
hpsaturn Jul 14, 2023
552a297
fixed some header issues and added contributors
hpsaturn Jul 16, 2023
95a6a88
v0.6.9r376 Geiger sensor RC1. Thanks to @roberbike @iw2lsi
hpsaturn Jul 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/advanced_multivariable/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ void setup() {
Serial.println("\n== Sensor test setup ==\n");
Serial.println("-->[SETUP] Detecting sensors..");

sensors.setSampleTime(10); // config sensors sample time interval
sensors.setSampleTime(10); // config sensors sample time interval
sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback
sensors.setDebugMode(true); // [optional] debug mode
sensors.setDebugMode(true); // [optional] debug mode
sensors.detectI2COnly(false); // disable force to only i2c sensors
sensors.init(); // Auto detection to UART and i2c sensors
delay(1000);
Expand Down
65 changes: 65 additions & 0 deletions examples/radiation_CAJOE/radiation_CAJOE.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* @file main.cpp
* @authors @roberbike @iw2lsi @hpsaturn
* @date June 2018 - 2023
* @brief Radiation sensor example
* @license GPL3
*
* Full documentation:
* https://github.com/kike-canaries/canairio_sensorlib#canairio-air-quality-sensors-library
*
* Full implementation for WiFi and Bluetooth Air Quality fixed and mobile station:
* https://github.com/kike-canaries/canairio_firmware#canairio-firmware
*
* Main pull requests and discussions:
* https://github.com/kike-canaries/canairio_sensorlib/pull/144
* https://github.com/kike-canaries/canairio_firmware/pull/226
*
* CanAirIO project:
* https://canair.io
*
* CanAirIO Docs:
* https://canair.io/docs
*
*/

#include <Arduino.h>
#include <Sensors.hpp>

void onSensorDataOk() {
Serial.print(" CPM: " + String(sensors.getGeigerCPM()));
Serial.print(" uSvh: " + String(sensors.getGeigerMicroSievertHour()));
}

void onSensorDataError(const char* msg) {
Serial.println(msg);
}

/******************************************************************************
* M A I N
******************************************************************************/

void setup() {
Serial.begin(115200);
delay(1000);

Serial.println("\n== Sensor test setup ==\n");
Serial.println("-->[SETUP] Detecting sensors..");

sensors.setSampleTime(5); // config sensors sample time interval
sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback
sensors.setOnErrorCallBack(&onSensorDataError); // [optional] error callback
sensors.setDebugMode(true); // [optional] debug mode
sensors.detectI2COnly(true); // [optional] skip UART detection
sensors.enableGeigerSensor(27); // Geiger in sensor pin 27

sensors.init(); // forced UAQ sensor. Empty for auto detection

delay(500);
}

void loop() {
sensors.loop(); // read sensor data and showed it
}


2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CanAirIO Air Quality Sensors Library",
"version": "0.6.8",
"version": "0.6.9",
"homepage":"https://canair.io",
"keywords":
[
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=CanAirIO Air Quality Sensors Library
version=0.6.8
version=0.6.9
author=@hpsaturn, CanAirIO project <[email protected]>
maintainer=Antonio Vanegas <[email protected]>
url=https://github.com/kike-canaries/canairio_sensorlib
Expand Down
42 changes: 37 additions & 5 deletions src/Sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ bool Sensors::readAllSensors() {
aht10Read();
DFRobotCORead();
DFRobotNH3Read();
geigerRead();

#ifdef DHT11_ENABLED
dhtRead();
#endif
Expand Down Expand Up @@ -133,7 +135,7 @@ void Sensors::init(u_int pms_type, int pms_rx, int pms_tx) {
#ifdef DHT11_ENABLED
dhtInit();
#endif

printSensorsRegistered(true);
}

Expand Down Expand Up @@ -332,8 +334,6 @@ float Sensors::getCO() {
return co;
}



/**
* @brief UART only: check if the UART sensor is registered
* @return bool true if the UART sensor is registered, false otherwise.
Expand Down Expand Up @@ -550,7 +550,11 @@ float Sensors::getUnitValue(UNIT unit) {
case ALT:
return alt;
case GAS:
return gas;
return gas;
case CPM:
return rad->getTics();
case RAD:
return rad->getUSvh();
case NH3:
return nh3;
case CO:
Expand Down Expand Up @@ -1601,7 +1605,6 @@ void Sensors::DFRobotNH3Init() {
}

// Altitude compensation for CO2 sensors without Pressure atm or Altitude compensation

void Sensors::CO2correctionAlt() {
DEBUG("-->[SLIB] CO2 altitud original\t:", String(CO2Val).c_str());
float CO2cor = (0.016 * ((1013.25 - hpa) /10 ) * (CO2Val - 400)) + CO2Val; // Increment of 1.6% for every hpa of difference at sea level
Expand Down Expand Up @@ -1646,8 +1649,37 @@ void Sensors::resetAllVariables() {
pres = 0.0;
nh3 = 0;
co = 0;
rad->clear();
}

// #########################################################################

void Sensors::geigerRead(){
if(rad->read()){
unitRegister(UNIT::CPM);
unitRegister(UNIT::RAD);
}
}
/**
* @brief Enable Geiger sensor on specific pin
* @param GPIO pin
*/
void Sensors::enableGeigerSensor(int gpio){
sensorAnnounce(SENSORS::SCAJOE);
rad = new GEIGER(gpio,devmode);
sensorRegister(SENSORS::SCAJOE);
}

uint32_t Sensors::getGeigerCPM(void) {
return rad->getTics();
}

float Sensors::getGeigerMicroSievertHour(void) {
return rad->getUSvh();
}

// #########################################################################

void Sensors::DEBUG(const char *text, const char *textb) {
if (devmode) {
_debugPort.print(text);
Expand Down
24 changes: 21 additions & 3 deletions src/Sensors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
#include <s8_uart.h>
#include <sps30.h>
#include <drivers/pm1006.h>
#include <drivers/geiger.h>
#include <DFRobot_MultiGasSensor.h>

#ifdef DHT11_ENABLED
#include <dht_nonblocking.h>
#endif

#define CSL_VERSION "0.6.8"
#define CSL_REVISION 375
#define CSL_VERSION "0.6.9"
#define CSL_REVISION 376

/***************************************************************
* S E T U P E S P 3 2 B O A R D S A N D F I E L D S
Expand Down Expand Up @@ -97,6 +98,8 @@
X(PRESS, "hPa", "P") \
X(ALT, "m", "Alt") \
X(GAS, "Ohm", "Gas") \
X(CPM, "CPM", "CPM") \
X(RAD, "uSv/h", "RAD") \
X(NH3, "ppm", "NH3") \
X(CO, "ppm", "CO") \
X(UCOUNT, "COUNT", "UCOUNT")
Expand Down Expand Up @@ -126,6 +129,7 @@ typedef enum UNIT : size_t { SENSOR_UNITS } UNIT;
X(SDHTX, "DHTX", 3) \
X(SDFRCO, "DFRCO", 3) \
X(SDFRNH3, "DFRNH3", 3) \
X(SCAJOE, "CAJOE", 3) \
X(SCOUNT, "SCOUNT", 3)

#define X(utype, uname, umaintype) utype,
Expand All @@ -136,7 +140,9 @@ typedef enum SENSORS : size_t { SENSORS_TYPES } SENSORS; // backward compatibil
enum class SensorGroup { SENSOR_NONE,
SENSOR_PM,
SENSOR_CO2,
SENSOR_ENV };
SENSOR_ENV,
SENSOR_RAD // CAJOE_GEIGER
};

typedef void (*errorCbFn)(const char *msg);
typedef void (*voidCbFn)();
Expand Down Expand Up @@ -219,6 +225,9 @@ class Sensors {
// DFRobot gravity NH3 sensor addr 0x77
DFRobot_GAS_I2C dfrNH3;

// Geiger CAJOE sensor
GEIGER *rad;

void init(u_int pms_type = 0, int pms_rx = PMS_RX, int pms_tx = PMS_TX);

void loop();
Expand Down Expand Up @@ -267,6 +276,12 @@ class Sensors {

float getCO();

void enableGeigerSensor(int gpio);

uint32_t getGeigerCPM(void);

float getGeigerMicroSievertHour(void);

void setTempOffset(float offset);

void setCO2AltitudeOffset(float altitude);
Expand Down Expand Up @@ -428,6 +443,8 @@ class Sensors {
void sps30Errorloop(char *mess, uint8_t r);
void sps30DeviceInfo();

void geigerRead();

void onSensorError(const char *msg);

void startI2C();
Expand Down Expand Up @@ -469,3 +486,4 @@ extern Sensors sensors;
#endif

#endif

Loading