Skip to content

Commit

Permalink
Set default wake delay back to 0
Browse files Browse the repository at this point in the history
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
  • Loading branch information
SRGDamia1 committed May 5, 2021
1 parent fcea815 commit 6a3c047
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 22 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

****

## v2.1.4 (2021-05-05) [Revert wake delay to 0ms](https://github.com/EnviroDIY/Arduino-SDI-12/releases/tag/v2.1.4)

### Possibly breaking changes
- Reverted the default wake delay to 0ms.
- In 92055d377b26fa862c43d1429de1ccbef054af01 this was bumped up to 10ms, which caused problems for several people.
- The delay can now also be set using the build flag `-D SDI12_WAKE_DELAY=#`

## v2.1.3 (2021-03-24) [Migrate to GitHub Actions](https://github.com/EnviroDIY/Arduino-SDI-12/releases/tag/v2.1.3)

### Improvements
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.1.3
v2.1.4
2 changes: 1 addition & 1 deletion docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "SDI-12 for Arduino"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 2.1.3
PROJECT_NUMBER = 2.1.4

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SDI-12",
"version": "2.1.3",
"version": "2.1.4",
"keywords": "SDI-12, sdi12, communication, bus, sensor, Decagon",
"description": "An Arduino library for SDI-12 communication with a wide variety of environmental sensors.",
"repository": {
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=SDI-12
version=2.1.3
version=2.1.4
author=Kevin M. Smith <Kevin@elite-education.org>, Shannon Hicks <shicks@stroudcenter.org>
maintainer=Sara Damiano <sdamiano@stroudcenter.org>
sentence=An Arduino library for SDI-12 communication with a wide variety of environmental sensors.
Expand Down
16 changes: 13 additions & 3 deletions src/SDI12.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ typedef const __FlashStringHelper* FlashString;
/// a char not found in a valid ASCII numeric field
#define NO_IGNORE_CHAR '\x01'

#ifndef SDI12_WAKE_DELAY
/**
* @brief The amount of additional time in milliseconds that the sensor takes to wake
* before being ready to receive a command. Default is 0ms - meaning the sensor is
* ready for a command by the end of the 12ms break. Per protocol, the wake time must
* be less than 100 ms.
*/
#define SDI12_WAKE_DELAY 0
#endif

#ifndef SDI12_BUFFER_SIZE
/**
* @brief The buffer size for incoming SDI-12 data.
Expand Down Expand Up @@ -894,11 +904,11 @@ class SDI12 : public Stream {
* the sensor is ready for a command by the end of the 12ms break. Per protocol, the
* wake time must be less than 100 ms.
*/
void sendCommand(String& cmd, int8_t extraWakeTime = 10);
void sendCommand(String& cmd, int8_t extraWakeTime = SDI12_WAKE_DELAY);
/// @copydoc SDI12::sendCommand(String&, int8_t)
void sendCommand(const char* cmd, int8_t extraWakeTime = 10);
void sendCommand(const char* cmd, int8_t extraWakeTime = SDI12_WAKE_DELAY);
/// @copydoc SDI12::sendCommand(String&, int8_t)
void sendCommand(FlashString cmd, int8_t extraWakeTime = 10);
void sendCommand(FlashString cmd, int8_t extraWakeTime = SDI12_WAKE_DELAY);

/**
* @brief Send a response out on the data line (for slave use)
Expand Down
38 changes: 23 additions & 15 deletions tools/TestCommands/TestCommands.ino
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@
#define DATA_PIN 7 /*!< The pin of the SDI-12 data bus */
#define POWER_PIN 22 /*!< The sensor power pin (or -1 if not switching power) */
#define FIRST_ADDRESS 0
#define LAST_ADDRESS 1 // 62
#define LAST_ADDRESS 6 // 62
#define WAKE_DELAY 0 /*!< The extra time needed for the board to wake. */
#define COMMANDS_TO_TEST \
10 /*!< The number of measurement commands to test, between 1 and 10. */
2 /*!< The number of measurement commands to test, between 1 and 11. */

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

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

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

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

// return getResults(i, numResults,printCommands);
String res= getStringResults(i, numResults, printCommands);
String res = getStringResults(i, numResults, printCommands);
Serial.print("Result: ");
Serial.println(res);
return res;
Expand Down Expand Up @@ -529,9 +529,9 @@ void setup() {
}

void loop() {
flip = !flip; // flip the switch between concurrent and not
// flip = !flip; // flip the switch between concurrent and not
// flip = 1;
// flip = 0;
flip = 0;
uint32_t start = millis();
Serial.print("Flip: ");
Serial.println(flip);
Expand Down Expand Up @@ -559,8 +559,11 @@ void loop() {
if (isActive[i]) {
for (uint8_t a = 0; a < COMMANDS_TO_TEST; a++) {
Serial.print("Command ");
Serial.println(commands[a]);
this_result[i] = takeMeasurement(addr, commands[a], false);
Serial.print(i);
Serial.print("M");
Serial.print(commands[a]);
Serial.println('!');
this_result[i] = takeMeasurement(addr, commands[a], true);
}
// getContinuousResults(addr, 3);
Serial.println();
Expand All @@ -570,19 +573,24 @@ void loop() {
Serial.println(millis() - start);
} else {
for (uint8_t a = 0; a < COMMANDS_TO_TEST; a++) {
Serial.print("Command ");
Serial.println(commands[a]);
uint8_t min_wait = 127;
uint8_t max_wait = 0;
uint8_t min_wait = 127;
uint8_t max_wait = 0;
uint32_t for_start = millis();
// start all sensors measuring concurrently
for (byte i = FIRST_ADDRESS; i < LAST_ADDRESS; i++) {
char addr = decToChar(i);
if (isActive[i]) { startConcurrentMeasurement(addr, commands[a], false); }
if (isActive[i]) {
Serial.print("Command ");
Serial.print(i);
Serial.print("C");
Serial.print(commands[a]);
Serial.println('!');
startConcurrentMeasurement(addr, commands[a], true);
}
if (waitTime[i] < min_wait) { min_wait = waitTime[i]; }
if (waitTime[i] > max_wait) { max_wait = waitTime[i]; }
}
min_wait = max(0, (min_wait - 1) / 2);
min_wait = max(1, (min_wait - 1) / 2);
max_wait = max(1, max_wait + 1);
// Serial.print("minimum expected wait: ");
// Serial.println(min_wait);
Expand All @@ -604,7 +612,7 @@ void loop() {
// if (millis() > millisReady[i]) {
// if (millis() > millisStarted[i] + a) {
if (returnedResults[i] > 0) {
this_result[i] = getStringResults(addr, returnedResults[i], false);
this_result[i] = getStringResults(addr, returnedResults[i], true);
// if (this_result[i] != "") {
// Serial.print("timeWaited: ");
// Serial.print(timeWaited);
Expand Down

0 comments on commit 6a3c047

Please sign in to comment.