Skip to content

Commit 827d366

Browse files
committed
1 parent 1c03387 commit 827d366

File tree

2 files changed

+285
-5
lines changed

2 files changed

+285
-5
lines changed

src/sensors/YosemitechY4000.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@
7979
*
8080
* This is the time for communication to begin.
8181
*/
82-
#define Y4000_WARM_UP_TIME_MS 1600
82+
#define Y4000_WARM_UP_TIME_MS 1000
8383
/**
8484
* @brief Sensor::_stabilizationTime_ms; the Y4000 is stable after 60000ms.
8585
*
86-
* Y4000 Modbus manual says 60s; we find Cond takes about that long to respond.
86+
* Y4000 Modbus manual says 60s; we find Cond takes about 40s to respond.
8787
*/
88-
#define Y4000_STABILIZATION_TIME_MS 60000
89-
/// @brief Sensor::_measurementTime_ms; the Y4000 takes ~3000ms to complete a
88+
#define Y4000_STABILIZATION_TIME_MS 50000
89+
/// @brief Sensor::_measurementTime_ms; the Y4000 takes ~4000ms to complete a
9090
/// measurement.
91-
#define Y4000_MEASUREMENT_TIME_MS 3000
91+
#define Y4000_MEASUREMENT_TIME_MS 4000
9292
/**@}*/
9393

9494
/**

src/sensors/YosemitechY700.h

Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
/**
2+
* @file YosemitechY700.h
3+
* @copyright 2017-2022 Stroud Water Research Center
4+
* Part of the EnviroDIY ModularSensors library for Arduino
5+
* @author Anthony Aufdenkampe <aaufdenkampe@limno.com>
6+
*
7+
* @brief Contains the YosemitechY700 sensor subclass and the variable
8+
* subclasses YosemitechY700_Pressure and YosemitechY700_Temp.
9+
*
10+
* These are for the Yosemitech Y700 Pressure sensor.
11+
*
12+
* This depends on the YosemitechParent super class.
13+
*
14+
* Documentation for the Modbus Protocol commands and responses can be found
15+
* within the documentation in the YosemitechModbus library at:
16+
* https://github.com/EnviroDIY/YosemitechModbus
17+
*/
18+
/* clang-format off */
19+
/**
20+
* @defgroup sensor_y700 Yosemitech Y700 Pressure Sensor
21+
* Classes for the Yosemitech Y700 pressure sensor.
22+
*
23+
* @ingroup yosemitech_group
24+
*
25+
* @tableofcontents
26+
* @m_footernavigation
27+
*
28+
* @section sensor_y700_datasheet Sensor Datasheet
29+
*
30+
* @note The reported resolution (32 bit) gives far more precision than is significant
31+
* based on the specified accuracy of the sensor, so the resolutions kept in the
32+
* string representation of the variable values is based on the accuracy not the
33+
* maximum reported resolution of the sensor.
34+
*
35+
* @section sensor_y700_ctor Sensor Constructor
36+
* {{ @ref YosemitechY700::YosemitechY700 }}
37+
*
38+
* ___
39+
* @section sensor_y700_examples Example Code
40+
* The Yosemitech Y700 pressure sensor is used in the @menulink{yosemitech_y700}
41+
* example.
42+
*
43+
* @menusnip{yosemitech_y700}
44+
*/
45+
/* clang-format on */
46+
47+
// Header Guards
48+
#ifndef SRC_SENSORS_YOSEMITECHY700_H_
49+
#define SRC_SENSORS_YOSEMITECHY700_H_
50+
51+
// Included Dependencies
52+
#include "sensors/YosemitechParent.h"
53+
54+
/** @ingroup sensor_y700 */
55+
/**@{*/
56+
57+
// Sensor Specific Defines
58+
/// @brief Sensor::_numReturnedValues; the Y700 can report 2 values.
59+
#define Y700_NUM_VARIABLES 2
60+
/// @brief Sensor::_incCalcValues; we don't calculate any additional values.
61+
#define Y700_INC_CALC_VARIABLES 0
62+
63+
/**
64+
* @anchor sensor_y700_timing
65+
* @name Sensor Timing
66+
* The sensor timing for a Yosemitch Y700
67+
*/
68+
/**@{*/
69+
/// @brief Sensor::_warmUpTime_ms; time before sensor responds after power -
70+
/// 1000 ms.
71+
#define Y700_WARM_UP_TIME_MS 1000
72+
/// @brief Sensor::_stabilizationTime_ms; time between "StartMeasurement"
73+
/// command and stable reading - Y700 takes 4 s to get stability <1 mm,
74+
/// but 12 s for <0.1 mm. If highest precision is required, increase to 12000.
75+
#define Y700_STABILIZATION_TIME_MS 4000
76+
/// @brief Sensor::_measurementTime_ms; the Y700 takes <1 s for new values.
77+
/// but >1 s for values that don't seem autocorrelated.
78+
#define Y700_MEASUREMENT_TIME_MS 1000
79+
/**@}*/
80+
81+
/**
82+
* @anchor sensor_y700_pres
83+
* @name Pressure
84+
* The Pressure variable from a Yosemitch Y700
85+
* - Range is 0mH2O, ~2mH2O, or 100mH2O, depending on model
86+
* - Accuracy is ± 0.1 % Full Scale
87+
*
88+
* {{ @ref YosemitechY700_Pressure::YosemitechY700_Pressure }}
89+
*/
90+
/**@{*/
91+
/// @brief Decimals places in string representation; Pressure should have 1
92+
/// - resolution is 0.01 mm.
93+
#define Y700_PRES_RESOLUTION 2
94+
/// @brief Sensor variable number; pressure is stored in sensorValues[0].
95+
#define Y700_PRES_VAR_NUM 0
96+
/// @brief Variable name in
97+
/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/);
98+
/// "pressureGauge"
99+
#define Y700_PRES_VAR_NAME "pressureGauge"
100+
/// @brief Variable unit name in
101+
/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/units/);
102+
/// "millimeterofWater" (mm H2O)
103+
#define Y700_PRES_UNIT_NAME "millimeterofWater"
104+
/// @brief Default variable short code; "Y700Pres"
105+
#define Y700_PRES_DEFAULT_CODE "Y700Pres"
106+
/**@}*/
107+
108+
/**
109+
* @anchor sensor_y700_temp
110+
* @name Temperature
111+
* The temperature variable from a Yosemitch Y700
112+
* - Range is 0°C to + 50°C
113+
* - Accuracy is ± 0.2°C
114+
*
115+
* {{ @ref YosemitechY700_Temp::YosemitechY700_Temp }}
116+
*/
117+
/**@{*/
118+
/// @brief Decimals places in string representation; temperature should have 1 -
119+
/// resolution is 0.1°C.
120+
#define Y700_TEMP_RESOLUTION 1
121+
/// @brief Sensor variable number; temperature is stored in sensorValues[1].
122+
#define Y700_TEMP_VAR_NUM 1
123+
/// @brief Variable name in
124+
/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/variablename/);
125+
/// "temperature"
126+
#define Y700_TEMP_VAR_NAME "temperature"
127+
/// @brief Variable unit name in
128+
/// [ODM2 controlled vocabulary](http://vocabulary.odm2.org/units/);
129+
/// "degreeCelsius" (°C)
130+
#define Y700_TEMP_UNIT_NAME "degreeCelsius"
131+
/// @brief Default variable short code; "Y700Temp"
132+
#define Y700_TEMP_DEFAULT_CODE "Y700Temp"
133+
/**@}*/
134+
135+
136+
/* clang-format off */
137+
/**
138+
* @brief The Sensor sub-class for the
139+
* [Yosemitech Y700 pressure sensor](@ref sensor_y700).
140+
*
141+
* @ingroup sensor_y700
142+
*/
143+
/* clang-format on */
144+
class YosemitechY700 : public YosemitechParent {
145+
public:
146+
// Constructors with overloads
147+
/**
148+
* @brief Construct a new Yosemitech Y700 object.
149+
*
150+
* @param modbusAddress The modbus address of the sensor.
151+
* @param stream An Arduino data stream for modbus communication. See
152+
* [notes](@ref page_arduino_streams) for more information on what streams
153+
* can be used.
154+
* @param powerPin The pin on the mcu controlling power to the Y700.
155+
* Use -1 if it is continuously powered.
156+
* @param powerPin2 The pin on the mcu controlling power to the RS485
157+
* adapter, if it is different from that used to power the sensor. Use -1
158+
* or omit if not applicable.
159+
* @param enablePin The pin on the mcu controlling the direction enable on
160+
* the RS485 adapter, if necessary; use -1 or omit if not applicable.
161+
* @note An RS485 adapter with integrated flow control is strongly
162+
* recommended.
163+
* @param measurementsToAverage The number of measurements to take and
164+
* average before giving a "final" result from the sensor; optional with a
165+
* default value of 1.
166+
*/
167+
YosemitechY700(byte modbusAddress, Stream* stream, int8_t powerPin,
168+
int8_t powerPin2 = -1, int8_t enablePin = -1,
169+
uint8_t measurementsToAverage = 1)
170+
: YosemitechParent(modbusAddress, stream, powerPin, powerPin2,
171+
enablePin, measurementsToAverage, Y700,
172+
"YosemitechY700", Y700_NUM_VARIABLES,
173+
Y700_WARM_UP_TIME_MS, Y700_STABILIZATION_TIME_MS,
174+
Y700_MEASUREMENT_TIME_MS, Y700_INC_CALC_VARIABLES) {}
175+
/**
176+
* @copydoc YosemitechY700::YosemitechY700
177+
*/
178+
YosemitechY700(byte modbusAddress, Stream& stream, int8_t powerPin,
179+
int8_t powerPin2 = -1, int8_t enablePin = -1,
180+
uint8_t measurementsToAverage = 1)
181+
: YosemitechParent(modbusAddress, stream, powerPin, powerPin2,
182+
enablePin, measurementsToAverage, Y700,
183+
"YosemitechY700", Y700_NUM_VARIABLES,
184+
Y700_WARM_UP_TIME_MS, Y700_STABILIZATION_TIME_MS,
185+
Y700_MEASUREMENT_TIME_MS, Y700_INC_CALC_VARIABLES) {}
186+
/**
187+
* @brief Destroy the Yosemitech Y700 object
188+
*/
189+
~YosemitechY700() {}
190+
};
191+
192+
193+
/* clang-format off */
194+
/**
195+
* @brief The Variable sub-class used for the
196+
* [pressure output](@ref sensor_y700_pres) from a
197+
* [Yosemitech Y700 pressure sensor](@ref sensor_y700).
198+
*
199+
* @ingroup sensor_y700
200+
*/
201+
/* clang-format on */
202+
class YosemitechY700_Pressure : public Variable {
203+
public:
204+
/**
205+
* @brief Construct a new YosemitechY700_Pressure object.
206+
*
207+
* @param parentSense The parent YosemitechY700 providing the result
208+
* values.
209+
* @param uuid A universally unique identifier (UUID or GUID) for the
210+
* variable; optional with the default value of an empty string.
211+
* @param varCode A short code to help identify the variable in files;
212+
* optional with a default value of "Y700Pres".
213+
*/
214+
explicit YosemitechY700_Pressure(YosemitechY700* parentSense,
215+
const char* uuid = "",
216+
const char* varCode = Y700_PRES_DEFAULT_CODE)
217+
: Variable(parentSense, (const uint8_t)Y700_PRES_VAR_NUM,
218+
(uint8_t)Y700_PRES_RESOLUTION, Y700_PRES_VAR_NAME,
219+
Y700_PRES_UNIT_NAME, varCode, uuid) {}
220+
/**
221+
* @brief Construct a new YosemitechY700_Pressure object.
222+
*
223+
* @note This must be tied with a parent YosemitechY700 before it can be
224+
* used.
225+
*/
226+
YosemitechY700_Pressure()
227+
: Variable((const uint8_t)Y700_PRES_VAR_NUM,
228+
(uint8_t)Y700_PRES_RESOLUTION, Y700_PRES_VAR_NAME,
229+
Y700_PRES_UNIT_NAME, Y700_PRES_DEFAULT_CODE) {}
230+
/**
231+
* @brief Destroy the YosemitechY700_Pressure object - no action needed.
232+
*/
233+
~YosemitechY700_Pressure() {}
234+
};
235+
236+
237+
/* clang-format off */
238+
/**
239+
* @brief The Variable sub-class used for the
240+
* [temperature output](@ref sensor_y700_temp) from a
241+
* [Yosemitech Y700 pressure sensor](@ref sensor_y700).
242+
*
243+
* @ingroup sensor_y700
244+
*/
245+
/* clang-format on */
246+
class YosemitechY700_Temp : public Variable {
247+
public:
248+
/**
249+
* @brief Construct a new YosemitechY700_Temp object.
250+
*
251+
* @param parentSense The parent YosemitechY700 providing the result
252+
* values.
253+
* @param uuid A universally unique identifier (UUID or GUID) for the
254+
* variable; optional with the default value of an empty string.
255+
* @param varCode A short code to help identify the variable in files;
256+
* optional with a default value of "Y700Temp".
257+
*/
258+
explicit YosemitechY700_Temp(YosemitechY700* parentSense,
259+
const char* uuid = "",
260+
const char* varCode = Y700_TEMP_DEFAULT_CODE)
261+
: Variable(parentSense, (const uint8_t)Y700_TEMP_VAR_NUM,
262+
(uint8_t)Y700_TEMP_RESOLUTION, Y700_TEMP_VAR_NAME,
263+
Y700_TEMP_UNIT_NAME, varCode, uuid) {}
264+
/**
265+
* @brief Construct a new YosemitechY700_Temp object.
266+
*
267+
* @note This must be tied with a parent YosemitechY700 before it can be
268+
* used.
269+
*/
270+
YosemitechY700_Temp()
271+
: Variable((const uint8_t)Y700_TEMP_VAR_NUM,
272+
(uint8_t)Y700_TEMP_RESOLUTION, Y700_TEMP_VAR_NAME,
273+
Y700_TEMP_UNIT_NAME, Y700_TEMP_DEFAULT_CODE) {}
274+
/**
275+
* @brief Destroy the YosemitechY700_Temp object - no action needed.
276+
*/
277+
~YosemitechY700_Temp() {}
278+
};
279+
/**@}*/
280+
#endif // SRC_SENSORS_YOSEMITECHY700_H_

0 commit comments

Comments
 (0)