Skip to content

Commit

Permalink
Merge branch 'Y513_BGA' into develop
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
2 parents f02ea01 + 332adbc commit b21009a
Show file tree
Hide file tree
Showing 5 changed files with 327 additions and 8 deletions.
8 changes: 4 additions & 4 deletions continuous_integration/dependencies.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"action_cache_version": 19,
"action_cache_version": 20,
"dependencies": [
{
"name": "EnviroDIY_DS3231",
Expand Down Expand Up @@ -289,7 +289,7 @@
"owner": "envirodiy",
"library id": "1824",
"url": "https://github.com/EnviroDIY/SensorModbusMaster",
"version": "~0.7.0",
"version": "~0.7.3",
"note": "EnviroDIY SensorModbusMaster - Arduino library for communicating via modbus with the Arduino acting as the modbus master.",
"authors": [
"Sara Damiano"
Expand All @@ -313,7 +313,7 @@
"owner": "envirodiy",
"library id": "2078",
"url": "https://github.com/EnviroDIY/YosemitechModbus",
"version": "~0.4.1",
"version": "~0.5.0",
"note": "Arduino library for communication with Yosemitech sensors via Modbus.",
"authors": [
"Sara Damiano",
Expand All @@ -335,4 +335,4 @@
"platforms": "atmelavr, atmelsam"
}
]
}
}
36 changes: 36 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 @@ -2163,6 +2163,38 @@ Variable* y511Temp =
#endif


#if defined(BUILD_SENSOR_YOSEMITECH_Y513)
// ==========================================================================
// Yosemitech Y513 Blue Green Algae (BGA) Sensor
// ==========================================================================
/** Start [yosemitech_y513] */
#include <sensors/YosemitechY513.h>

// NOTE: Extra hardware and software serial ports are created in the "Settings
// for Additional Serial Ports" section

// NOTE: Use -1 for any pins that don't apply or aren't being used.
byte y513ModbusAddress = 0x13; // The modbus address of the Y513
const int8_t y513AdapterPower = sensorPowerPin; // RS485 adapter power pin
const int8_t y513SensorPower = modbusSensorPowerPin; // Sensor power pin
const int8_t y513EnablePin = -1; // Adapter RE/DE pin
const uint8_t y513NumberReadings = 5;
// The manufacturer recommends averaging 10 readings, but we take 5 to minimize
// power consumption

// Create a Y513 Blue Green Algae (BGA) sensor object
YosemitechY513 y513(y513ModbusAddress, modbusSerial, y513AdapterPower,
y513SensorPower, y513EnablePin, y513NumberReadings);

// Create Blue Green Algae (BGA) concentration and temperature variable
// pointers for the Y513
Variable* y513BGA =
new YosemitechY513_BGA(&y513, "12345678-abcd-1234-ef00-1234567890ab");
Variable* y513Temp =
new YosemitechY513_Temp(&y513, "12345678-abcd-1234-ef00-1234567890ab");
/** End [yosemitech_y513] */
#endif

#if defined(BUILD_SENSOR_YOSEMITECH_Y514)
// ==========================================================================
// Yosemitech Y514 Chlorophyll Sensor
Expand Down Expand Up @@ -2801,6 +2833,10 @@ Variable* variableList[] = {
y511Turb,
y511Temp,
#endif
#if defined(BUILD_SENSOR_YOSEMITECH_Y513)
y513BGA,
y513Temp,
#endif
#if defined(BUILD_SENSOR_YOSEMITECH_Y514)
y514Chloro,
y514Temp,
Expand Down
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
"owner": "envirodiy",
"library id": "1824",
"url": "https://github.com/EnviroDIY/SensorModbusMaster",
"version": "~0.7.0",
"version": "~0.7.3",
"note": "EnviroDIY SensorModbusMaster - Arduino library for communicating via modbus with the Arduino acting as the modbus master.",
"authors": ["Sara Damiano"],
"frameworks": "arduino",
Expand All @@ -323,7 +323,7 @@
"owner": "envirodiy",
"library id": "2078",
"url": "https://github.com/EnviroDIY/YosemitechModbus",
"version": "~0.4.1",
"version": "~0.5.0",
"note": "Arduino library for communication with Yosemitech sensors via Modbus.",
"authors": ["Sara Damiano", "Anthony Aufdenkampe"],
"frameworks": "arduino",
Expand Down
4 changes: 2 additions & 2 deletions src/sensors/YosemitechParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ bool YosemitechParent::wake(void) {

// Manually activate the brush
// Needed for newer sensors that do not immediate activate on getting power
if (_model == Y511 || _model == Y514 || _model == Y551 || _model == Y560 ||
_model == Y4000) {
if (_model == Y511 || _model == Y513 || _model == Y514 || _model == Y551 ||
_model == Y560 || _model == Y4000) {
MS_DBG(F("Activate Brush on"), getSensorNameAndLocation());
if (_ysensor.activateBrush()) {
MS_DBG(F("Brush activated."));
Expand Down
283 changes: 283 additions & 0 deletions src/sensors/YosemitechY513.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
/**
* @file YosemitechY513.h
* @copyright Stroud Water Research Center
* Part of the EnviroDIY ModularSensors library for Arduino.
* This library is published under the BSD-3 license.
* @author Anthony Aufdenkampe <[email protected]>
*
* @brief Contains the YosemitechY513 sensor subclass and the variable
* subclasses YosemitechY513_BGA and YosemitechY513_Temp.
*
* These are for the Yosemitech Y513 Blue Green Algae (BGA) sensor with wiper.
*
* This depends on the YosemitechParent super class.
*
* Documentation for the Modbus Protocol commands and responses can be found
* within the documentation in the YosemitechModbus library at:
* https://github.com/EnviroDIY/YosemitechModbus
*/
/* clang-format off */
/**
* @defgroup sensor_y513 Yosemitech Y513 self-cleaning Blue Green Algae (BGA) sensor.
* Classes for the Yosemitech Y513 Blue Green Algae (BGA) sensor with wiper.
*
* @ingroup yosemitech_group
*
* @tableofcontents
* @m_footernavigation
*
* @section sensor_y513_datasheet Sensor Datasheet
* - [Y513 product webpage](https://e.yosemitech.com/CHL/Y513-A.html)
*
* @note The reported resolution (32 bit) gives far more precision than is significant
* based on the specified accuracy of the sensor, so the resolutions kept in the
* string representation of the variable values is based on the accuracy not the
* maximum reported resolution of the sensor.
*
* @section sensor_y513_ctor Sensor Constructor
* {{ @ref YosemitechY513::YosemitechY513 }}
*
* ___
* @section sensor_y513_examples Example Code
* The Yosemitech Y513 Blue Green Algae sensor is used in the @menulink{yosemitech_y513}
* example.
*
* @menusnip{yosemitech_y513}
*/
/* clang-format on */

// Header Guards
#ifndef SRC_SENSORS_YOSEMITECHY513_H_
#define SRC_SENSORS_YOSEMITECHY513_H_

// Included Dependencies
#include "sensors/YosemitechParent.h"

/** @ingroup sensor_y513 */
/**@{*/

// Sensor Specific Defines
/// @brief Sensor::_numReturnedValues; the Y513 can report 2 values.
#define Y513_NUM_VARIABLES 2
/// @brief Sensor::_incCalcValues; we don't calculate any additional values.
#define Y513_INC_CALC_VARIABLES 0

/**
* @anchor sensor_y513_timing
* @name Sensor Timing
* The sensor timing for a Yosemitch Y513
*/
/**@{*/
/// @brief Sensor::_warmUpTime_ms; time before sensor responds after power - 1.3
/// seconds (1300ms).
#define Y513_WARM_UP_TIME_MS 1300
/// @brief Sensor::_stabilizationTime_ms; time between "StartMeasurement"
/// command and stable reading - 8sec (8000ms).
#define Y513_STABILIZATION_TIME_MS 8000
/// @brief Sensor::_measurementTime_ms; the Y513 takes ~2000ms to complete a
/// measurement.
#define Y513_MEASUREMENT_TIME_MS 2000
/**@}*/

/**
* @anchor sensor_y513_bga
* @name Chlorophyll Concentration
* The blue green algae concentration variable from a Yosemitch Y513
* - Range is 0 to 400 µg/L or 0 to 100 RFU
* - Accuracy is ± 1 %
*
* {{ @ref YosemitechY513_BGA::YosemitechY513_BGA }}
*/
/**@{*/
/// @brief Decimals places in string representation; blue green algae concentration
/// should have 1 - resolution is 0.1 µg/L / 0.1 RFU.
#define Y513_BGA_RESOLUTION 1
/// @brief Sensor variable number; blue green algae concentration is stored in
/// sensorValues[0].
#define Y513_BGA_VAR_NUM 0
/// @brief Variable name in
/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/);
/// "blue_GreenAlgae_Cyanobacteria_Phycocyanin"
#define Y513_BGA_VAR_NAME "Blue-green algae (cyanobacteria), phycocyanin"
/// @brief Variable unit name in
/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/units/);
/// "countPerMilliliter" (cells/mL)
#define Y513_BGA_UNIT_NAME "countPerMilliliter"
/// @brief Default variable short code; "Y513BGA"
#define Y513_BGA_DEFAULT_CODE "Y513BGA"
/**@}*/

/**
* @anchor sensor_y513_temp
* @name Temperature
* The temperature variable from a Yosemitch Y513
* - Range is 0°C to + 50°C
* - Accuracy is ± 0.2°C
*
* {{ @ref YosemitechY513_Temp::YosemitechY513_Temp }}
*/
/**@{*/
/// @brief Decimals places in string representation; temperature should have 1 -
/// resolution is 0.1°C.
#define Y513_TEMP_RESOLUTION 1
/// @brief Sensor variable number; temperature is stored in sensorValues[1].
#define Y513_TEMP_VAR_NUM 1
/// @brief Variable name in
/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/);
/// "temperature"
#define Y513_TEMP_VAR_NAME "temperature"
/// @brief Variable unit name in
/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/units/);
/// "degreeCelsius" (°C)
#define Y513_TEMP_UNIT_NAME "degreeCelsius"
/// @brief Default variable short code; "Y513Temp"
#define Y513_TEMP_DEFAULT_CODE "Y513Temp"
/**@}*/


/* clang-format off */
/**
* @brief The Sensor sub-class for the
* [Yosemitech Y513 sensor](@ref sensor_y513).
*
* @ingroup sensor_y513
*/
/* clang-format on */
class YosemitechY513 : public YosemitechParent {
public:
// Constructors with overloads
/**
* @brief Construct a new Yosemitech Y513 object.
*
* @param modbusAddress The modbus address of the sensor.
* @param stream An Arduino data stream for modbus communication. See
* [notes](@ref page_arduino_streams) for more information on what streams
* can be used.
* @param powerPin The pin on the mcu controlling power to the Y513.
* Use -1 if it is continuously powered.
* @param powerPin2 The pin on the mcu controlling power to the RS485
* adapter, if it is different from that used to power the sensor. Use -1
* or omit if not applicable.
* @param enablePin The pin on the mcu controlling the direction enable on
* the RS485 adapter, if necessary; use -1 or omit if not applicable.
* @note An RS485 adapter with integrated flow control is strongly
* recommended.
* @param measurementsToAverage The number of measurements to take and
* average before giving a "final" result from the sensor; optional with a
* default value of 1.
*/
YosemitechY513(byte modbusAddress, Stream* stream, int8_t powerPin,
int8_t powerPin2 = -1, int8_t enablePin = -1,
uint8_t measurementsToAverage = 1)
: YosemitechParent(modbusAddress, stream, powerPin, powerPin2,
enablePin, measurementsToAverage, Y513,
"YosemitechY513", Y513_NUM_VARIABLES,
Y513_WARM_UP_TIME_MS, Y513_STABILIZATION_TIME_MS,
Y513_MEASUREMENT_TIME_MS, Y513_INC_CALC_VARIABLES) {}
/**
* @copydoc YosemitechY513::YosemitechY513
*/
YosemitechY513(byte modbusAddress, Stream& stream, int8_t powerPin,
int8_t powerPin2 = -1, int8_t enablePin = -1,
uint8_t measurementsToAverage = 1)
: YosemitechParent(modbusAddress, stream, powerPin, powerPin2,
enablePin, measurementsToAverage, Y513,
"YosemitechY513", Y513_NUM_VARIABLES,
Y513_WARM_UP_TIME_MS, Y513_STABILIZATION_TIME_MS,
Y513_MEASUREMENT_TIME_MS, Y513_INC_CALC_VARIABLES) {}
/**
* @brief Destroy the Yosemitech Y513 object
*/
~YosemitechY513() {}
};


/* clang-format off */
/**
* @brief The Variable sub-class used for the
* [blue green algae concentration output](@ref sensor_y513_bga) from a
* [Yosemitech Y513 Blue Green Algae (BGA) sensor with wiper](@ref sensor_y513).
*
* @ingroup sensor_y513
*/
/* clang-format on */
class YosemitechY513_BGA : public Variable {
public:
/**
* @brief Construct a new YosemitechY513_BGA object.
*
* @param parentSense The parent YosemitechY513 providing the result
* values.
* @param uuid A universally unique identifier (UUID or GUID) for the
* variable; optional with the default value of an empty string.
* @param varCode A short code to help identify the variable in files;
* optional with a default value of "Y513BGA".
*/
explicit YosemitechY513_BGA(
YosemitechY513* parentSense, const char* uuid = "",
const char* varCode = Y513_BGA_DEFAULT_CODE)
: Variable(parentSense, (const uint8_t)Y513_BGA_VAR_NUM,
(uint8_t)Y513_BGA_RESOLUTION, Y513_BGA_VAR_NAME,
Y513_BGA_UNIT_NAME, varCode, uuid) {}
/**
* @brief Construct a new YosemitechY513_BGA object.
*
* @note This must be tied with a parent YosemitechY513 before it can be
* used.
*/
YosemitechY513_BGA()
: Variable((const uint8_t)Y513_BGA_VAR_NUM,
(uint8_t)Y513_BGA_RESOLUTION, Y513_BGA_VAR_NAME,
Y513_BGA_UNIT_NAME, Y513_BGA_DEFAULT_CODE) {}
/**
* @brief Destroy the YosemitechY513_BGA() object - no action
* needed.
*/
~YosemitechY513_BGA() {}
};


/* clang-format off */
/**
* @brief The Variable sub-class used for the
* [temperature output](@ref sensor_y513_temp) from a
* [Yosemitech Y513-A blue green algae sensor with wiper](@ref sensor_y513).
*
* @ingroup sensor_y513
*/
/* clang-format on */
class YosemitechY513_Temp : public Variable {
public:
/**
* @brief Construct a new YosemitechY513_Temp object.
*
* @param parentSense The parent YosemitechY513 providing the result
* values.
* @param uuid A universally unique identifier (UUID or GUID) for the
* variable; optional with the default value of an empty string.
* @param varCode A short code to help identify the variable in files;
* optional with a default value of "Y513Temp".
*/
explicit YosemitechY513_Temp(YosemitechY513* parentSense,
const char* uuid = "",
const char* varCode = Y513_TEMP_DEFAULT_CODE)
: Variable(parentSense, (const uint8_t)Y513_TEMP_VAR_NUM,
(uint8_t)Y513_TEMP_RESOLUTION, Y513_TEMP_VAR_NAME,
Y513_TEMP_UNIT_NAME, varCode, uuid) {}
/**
* @brief Construct a new YosemitechY513_Temp object.
*
* @note This must be tied with a parent YosemitechY513 before it can be
* used.
*/
YosemitechY513_Temp()
: Variable((const uint8_t)Y513_TEMP_VAR_NUM,
(uint8_t)Y513_TEMP_RESOLUTION, Y513_TEMP_VAR_NAME,
Y513_TEMP_UNIT_NAME, Y513_TEMP_DEFAULT_CODE) {}
/**
* @brief Destroy the YosemitechY513_Temp object - no action needed.
*/
~YosemitechY513_Temp() {}
};
/**@}*/
#endif // SRC_SENSORS_YOSEMITECHY513_H_

0 comments on commit b21009a

Please sign in to comment.