Skip to content

Commit 6a3c047

Browse files
committed
Set default wake delay back to 0
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
1 parent fcea815 commit 6a3c047

File tree

7 files changed

+47
-22
lines changed

7 files changed

+47
-22
lines changed

ChangeLog.md

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
****
88

9+
## v2.1.4 (2021-05-05) [Revert wake delay to 0ms](https://github.com/EnviroDIY/Arduino-SDI-12/releases/tag/v2.1.4)
10+
11+
### Possibly breaking changes
12+
- Reverted the default wake delay to 0ms.
13+
- In 92055d377b26fa862c43d1429de1ccbef054af01 this was bumped up to 10ms, which caused problems for several people.
14+
- The delay can now also be set using the build flag `-D SDI12_WAKE_DELAY=#`
15+
916
## v2.1.3 (2021-03-24) [Migrate to GitHub Actions](https://github.com/EnviroDIY/Arduino-SDI-12/releases/tag/v2.1.3)
1017

1118
### Improvements

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2.1.3
1+
v2.1.4

docs/Doxyfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "SDI-12 for Arduino"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 2.1.3
41+
PROJECT_NUMBER = 2.1.4
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

library.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SDI-12",
3-
"version": "2.1.3",
3+
"version": "2.1.4",
44
"keywords": "SDI-12, sdi12, communication, bus, sensor, Decagon",
55
"description": "An Arduino library for SDI-12 communication with a wide variety of environmental sensors.",
66
"repository": {

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SDI-12
2-
version=2.1.3
2+
version=2.1.4
33
author=Kevin M. Smith <Kevin@elite-education.org>, Shannon Hicks <shicks@stroudcenter.org>
44
maintainer=Sara Damiano <sdamiano@stroudcenter.org>
55
sentence=An Arduino library for SDI-12 communication with a wide variety of environmental sensors.

src/SDI12.h

+13-3
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ typedef const __FlashStringHelper* FlashString;
137137
/// a char not found in a valid ASCII numeric field
138138
#define NO_IGNORE_CHAR '\x01'
139139

140+
#ifndef SDI12_WAKE_DELAY
141+
/**
142+
* @brief The amount of additional time in milliseconds that the sensor takes to wake
143+
* before being ready to receive a command. Default is 0ms - meaning the sensor is
144+
* ready for a command by the end of the 12ms break. Per protocol, the wake time must
145+
* be less than 100 ms.
146+
*/
147+
#define SDI12_WAKE_DELAY 0
148+
#endif
149+
140150
#ifndef SDI12_BUFFER_SIZE
141151
/**
142152
* @brief The buffer size for incoming SDI-12 data.
@@ -894,11 +904,11 @@ class SDI12 : public Stream {
894904
* the sensor is ready for a command by the end of the 12ms break. Per protocol, the
895905
* wake time must be less than 100 ms.
896906
*/
897-
void sendCommand(String& cmd, int8_t extraWakeTime = 10);
907+
void sendCommand(String& cmd, int8_t extraWakeTime = SDI12_WAKE_DELAY);
898908
/// @copydoc SDI12::sendCommand(String&, int8_t)
899-
void sendCommand(const char* cmd, int8_t extraWakeTime = 10);
909+
void sendCommand(const char* cmd, int8_t extraWakeTime = SDI12_WAKE_DELAY);
900910
/// @copydoc SDI12::sendCommand(String&, int8_t)
901-
void sendCommand(FlashString cmd, int8_t extraWakeTime = 10);
911+
void sendCommand(FlashString cmd, int8_t extraWakeTime = SDI12_WAKE_DELAY);
902912

903913
/**
904914
* @brief Send a response out on the data line (for slave use)

tools/TestCommands/TestCommands.ino

+23-15
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@
3030
#define DATA_PIN 7 /*!< The pin of the SDI-12 data bus */
3131
#define POWER_PIN 22 /*!< The sensor power pin (or -1 if not switching power) */
3232
#define FIRST_ADDRESS 0
33-
#define LAST_ADDRESS 1 // 62
33+
#define LAST_ADDRESS 6 // 62
3434
#define WAKE_DELAY 0 /*!< The extra time needed for the board to wake. */
3535
#define COMMANDS_TO_TEST \
36-
10 /*!< The number of measurement commands to test, between 1 and 10. */
36+
2 /*!< The number of measurement commands to test, between 1 and 11. */
3737

3838
/** Define the SDI-12 bus */
3939
SDI12 mySDI12(DATA_PIN);
4040

4141
/// variable that alternates output type back and forth between parsed and raw
4242
boolean flip = 0;
4343

44-
String commands[] = {"2", "2", "2", "2", "2", "2", "2", "2", "", "1", "3", "4", "5", "6", "7", "8", "9"};
44+
String commands[] = {"","0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
4545

4646
// keeps track of active addresses
4747
bool isActive[LAST_ADDRESS - FIRST_ADDRESS] = {
@@ -425,7 +425,7 @@ String takeMeasurement(char i, String meas_type = "", bool printCommands = true)
425425
mySDI12.clearBuffer();
426426

427427
// return getResults(i, numResults,printCommands);
428-
String res= getStringResults(i, numResults, printCommands);
428+
String res = getStringResults(i, numResults, printCommands);
429429
Serial.print("Result: ");
430430
Serial.println(res);
431431
return res;
@@ -529,9 +529,9 @@ void setup() {
529529
}
530530

531531
void loop() {
532-
flip = !flip; // flip the switch between concurrent and not
532+
// flip = !flip; // flip the switch between concurrent and not
533533
// flip = 1;
534-
// flip = 0;
534+
flip = 0;
535535
uint32_t start = millis();
536536
Serial.print("Flip: ");
537537
Serial.println(flip);
@@ -559,8 +559,11 @@ void loop() {
559559
if (isActive[i]) {
560560
for (uint8_t a = 0; a < COMMANDS_TO_TEST; a++) {
561561
Serial.print("Command ");
562-
Serial.println(commands[a]);
563-
this_result[i] = takeMeasurement(addr, commands[a], false);
562+
Serial.print(i);
563+
Serial.print("M");
564+
Serial.print(commands[a]);
565+
Serial.println('!');
566+
this_result[i] = takeMeasurement(addr, commands[a], true);
564567
}
565568
// getContinuousResults(addr, 3);
566569
Serial.println();
@@ -570,19 +573,24 @@ void loop() {
570573
Serial.println(millis() - start);
571574
} else {
572575
for (uint8_t a = 0; a < COMMANDS_TO_TEST; a++) {
573-
Serial.print("Command ");
574-
Serial.println(commands[a]);
575-
uint8_t min_wait = 127;
576-
uint8_t max_wait = 0;
576+
uint8_t min_wait = 127;
577+
uint8_t max_wait = 0;
577578
uint32_t for_start = millis();
578579
// start all sensors measuring concurrently
579580
for (byte i = FIRST_ADDRESS; i < LAST_ADDRESS; i++) {
580581
char addr = decToChar(i);
581-
if (isActive[i]) { startConcurrentMeasurement(addr, commands[a], false); }
582+
if (isActive[i]) {
583+
Serial.print("Command ");
584+
Serial.print(i);
585+
Serial.print("C");
586+
Serial.print(commands[a]);
587+
Serial.println('!');
588+
startConcurrentMeasurement(addr, commands[a], true);
589+
}
582590
if (waitTime[i] < min_wait) { min_wait = waitTime[i]; }
583591
if (waitTime[i] > max_wait) { max_wait = waitTime[i]; }
584592
}
585-
min_wait = max(0, (min_wait - 1) / 2);
593+
min_wait = max(1, (min_wait - 1) / 2);
586594
max_wait = max(1, max_wait + 1);
587595
// Serial.print("minimum expected wait: ");
588596
// Serial.println(min_wait);
@@ -604,7 +612,7 @@ void loop() {
604612
// if (millis() > millisReady[i]) {
605613
// if (millis() > millisStarted[i] + a) {
606614
if (returnedResults[i] > 0) {
607-
this_result[i] = getStringResults(addr, returnedResults[i], false);
615+
this_result[i] = getStringResults(addr, returnedResults[i], true);
608616
// if (this_result[i] != "") {
609617
// Serial.print("timeWaited: ");
610618
// Serial.print(timeWaited);

0 commit comments

Comments
 (0)