Skip to content

Commit

Permalink
Add to ReadMe, changelog, clang format
Browse files Browse the repository at this point in the history
Signed-off-by: Sara Damiano <[email protected]>
  • Loading branch information
SRGDamia1 committed Sep 27, 2024
1 parent 9da9277 commit 0f850f4
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 82 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Applied markdown lint to markdown files
- Bumped TinyGSM dependency
- Changed datatypes for modem voltage outputs.
- Switched from Soligen fork of ADS1115 library to the standard Adafruit version.

### Added

- Added support for Yosemitech Y513 Blue Green Algae Sensor thanks to @aufdenkampe
- Added support for Alphasense CO2 Sensor thanks to @aufdenkampe

### Removed

Expand Down
9 changes: 9 additions & 0 deletions examples/menu_a_la_carte/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ ___
- [Sensors and Measured Variables](#sensors-and-measured-variables)
- [The processor as a sensor](#the-processor-as-a-sensor)
- [Maxim DS3231 RTC as a sensor](#maxim-ds3231-rtc-as-a-sensor)
- [Alphasense CO2](#alphasense-co2)
- [AOSong AM2315](#aosong-am2315)
- [AOSong DHT](#aosong-dht)
- [Apogee SQ-212 Quantum Light Sensor](#apogee-sq-212-quantum-light-sensor)
Expand Down Expand Up @@ -604,6 +605,14 @@ As above, we create both the sensor and the variables measured by it.

___

### Alphasense CO2<!-- {#menu_walk_alphasense_co2} -->

@see @ref sensor_alphasense_co2

[//]: # ( @menusnip{alphasense_co2} )

___

### AOSong AM2315<!-- {#menu_walk_ao_song_am2315} -->

Here is the code for the AOSong AM2315 temperature and humidity sensor.
Expand Down
28 changes: 28 additions & 0 deletions examples/menu_a_la_carte/menu_a_la_carte.ino
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,30 @@ Variable* ds3231Temp =
#endif


#if defined(BUILD_SENSOR_ALPHASENSE_CO2)
// ==========================================================================
// Alphasense CO2 Sensor
// ==========================================================================
/** Start [alphasense_co2] */
#include <sensors/AlphasenseCO2.h>

// NOTE: Use -1 for any pins that don't apply or aren't being used.
const int8_t AlphasenseCO2Power = sensorPowerPin; // Power pin
const uint8_t AlphasenseCO2ADSi2c_addr =
0x48; // The I2C address of the ADS1115 ADC

// Create an Alphasense CO2 sensor object
AlphasenseCO2 alphasenseCO2(AlphasenseCO2Power, AlphasenseCO2ADSi2c_addr);

// Create PAR and raw voltage variable pointers for the CO2
Variable* asCO2 = new AlphasenseCO2_CO2(&alphasenseCO2,
"12345678-abcd-1234-ef00-1234567890ab");
Variable* asco2voltage = new AlphasenseCO2_Voltage(
&alphasenseCO2, "12345678-abcd-1234-ef00-1234567890ab");
/** End [alphasense_co2] */
#endif


#if defined(BUILD_SENSOR_AO_SONG_AM2315)
// ==========================================================================
// AOSong AM2315 Digital Humidity and Temperature Sensor
Expand Down Expand Up @@ -2618,6 +2642,10 @@ Variable* variableList[] = {
#if defined(ARDUINO_ARCH_AVR) || defined(MS_SAMD_DS3231)
ds3231Temp,
#endif
#if defined(BUILD_SENSOR_ALPHASENSE_CO2)
asCO2,
asco2voltage,
#endif
#if defined(BUILD_SENSOR_AO_SONG_AM2315)
am2315Humid,
am2315Temp,
Expand Down
29 changes: 17 additions & 12 deletions src/sensors/AlphasenseCO2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Part of the EnviroDIY ModularSensors library for Arduino
* @author Written by Anthony Aufdenkampe <[email protected]>
* and Bella Henkel <[email protected]>
* Adapted from ApogeeSQ212.h and https://github.com/bellahenkel/Soil-Sensing-Device
* Adapted from ApogeeSQ212.h and
* https://github.com/bellahenkel/Soil-Sensing-Device
*
* @brief Implements the AlphasenseCO2 class.
*/
Expand All @@ -17,11 +18,13 @@


// The constructor - need the power pin and the data pin
AlphasenseCO2::AlphasenseCO2(int8_t powerPin,
uint8_t i2cAddress, uint8_t measurementsToAverage)
: Sensor("AlphasenseCO2", ALPHASENSE_CO2_NUM_VARIABLES, ALPHASENSE_CO2_WARM_UP_TIME_MS,
ALPHASENSE_CO2_STABILIZATION_TIME_MS, ALPHASENSE_CO2_MEASUREMENT_TIME_MS, powerPin,
-1, measurementsToAverage, ALPHASENSE_CO2_INC_CALC_VARIABLES),
AlphasenseCO2::AlphasenseCO2(int8_t powerPin, uint8_t i2cAddress,
uint8_t measurementsToAverage)
: Sensor("AlphasenseCO2", ALPHASENSE_CO2_NUM_VARIABLES,
ALPHASENSE_CO2_WARM_UP_TIME_MS,
ALPHASENSE_CO2_STABILIZATION_TIME_MS,
ALPHASENSE_CO2_MEASUREMENT_TIME_MS, powerPin, -1,
measurementsToAverage, ALPHASENSE_CO2_INC_CALC_VARIABLES),
_i2cAddress(i2cAddress) {}

// Destructor
Expand All @@ -42,10 +45,10 @@ String AlphasenseCO2::getSensorLocation(void) {

bool AlphasenseCO2::addSingleMeasurementResult(void) {
// Variables to store the results in
int16_t adcCounts = -9999;
float adcVoltage = -9999;
float co2Current = -9999;
float calibResult = -9999;
int16_t adcCounts = -9999;
float adcVoltage = -9999;
float co2Current = -9999;
float calibResult = -9999;

// Check a measurement was *successfully* started (status bit 6 set)
// Only go on to get a result if it was
Expand Down Expand Up @@ -90,9 +93,11 @@ bool AlphasenseCO2::addSingleMeasurementResult(void) {

if (adcVoltage < 3.6 && adcVoltage > -0.3) {
// Skip results out of range
// Convert voltage to current (mA) - assuming a 250 Ohm resistor is in series
// Convert voltage to current (mA) - assuming a 250 Ohm resistor is
// in series
co2Current = (adcVoltage / 250) * 1000;
// Convert current to ppm (using a formula recommended by the sensor manufacturer)
// Convert current to ppm (using a formula recommended by the sensor
// manufacturer)
calibResult = 312.5 * co2Current - 1250;
MS_DBG(F(" calibResult:"), calibResult);
} else {
Expand Down
Loading

0 comments on commit 0f850f4

Please sign in to comment.