From 54144afb5fe7ba62504274d2df7e4243582ca60d Mon Sep 17 00:00:00 2001 From: oscgonfer Date: Fri, 4 Oct 2024 18:07:23 +0200 Subject: [PATCH 1/3] Atlas delay should be sufficient after transmission is ended to avoid non-ready data --- sam/src/SckAux.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sam/src/SckAux.cpp b/sam/src/SckAux.cpp index 718bf61..554a64e 100644 --- a/sam/src/SckAux.cpp +++ b/sam/src/SckAux.cpp @@ -1682,13 +1682,14 @@ bool Atlas::sendCommand(char* command) auxWire.requestFrom(deviceAddress, 1, true); uint8_t confirmed = auxWire.read(); auxWire.endTransmission(); + delay(shortWait); if (confirmed == 1) { lastCommandSent = millis(); return true; } - delay(300); + // delay(300); } return false; } From 2c3c57aaef7415078d6818a06b1fb30396698ccd Mon Sep 17 00:00:00 2001 From: oscgonfer Date: Fri, 4 Oct 2024 18:09:37 +0200 Subject: [PATCH 2/3] Add sleep wakeup to atlas drivers and avoid erroneous data on wake --- sam/src/SckAux.cpp | 10 +++++++++- sam/src/SckAux.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sam/src/SckAux.cpp b/sam/src/SckAux.cpp index 554a64e..55e5519 100644 --- a/sam/src/SckAux.cpp +++ b/sam/src/SckAux.cpp @@ -1577,7 +1577,13 @@ bool Atlas::getBusyState() if (millis() - lastUpdate < 2) return true; switch (state) { - case REST: { + case SLEEP: { + + if (millis() - lastCommandSent >= shortWait) { + if (sendCommand((char*)"r")) state = REST; + } + + } case REST: { // ORP doesn't need temp compensation so we jump directly to ask reading if (ORP) { @@ -1668,7 +1674,9 @@ void Atlas::goToSleep() auxWire.beginTransmission(deviceAddress); auxWire.write("Sleep"); auxWire.endTransmission(); + state = SLEEP; } + bool Atlas::sendCommand(char* command) { diff --git a/sam/src/SckAux.h b/sam/src/SckAux.h index 49db7a8..cb7147b 100644 --- a/sam/src/SckAux.h +++ b/sam/src/SckAux.h @@ -360,6 +360,7 @@ class Atlas uint32_t lastUpdate = 0; enum State { REST, + SLEEP, TEMP_COMP_SENT, ASKED_READING, }; From 079e7b96a6d79eebccb6cebe25a48c282408d59a Mon Sep 17 00:00:00 2001 From: oscgonfer Date: Mon, 28 Oct 2024 18:04:52 +0100 Subject: [PATCH 3/3] Revert delay position. Increment to shortwait --- sam/src/SckAux.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sam/src/SckAux.cpp b/sam/src/SckAux.cpp index 55e5519..c350b1b 100644 --- a/sam/src/SckAux.cpp +++ b/sam/src/SckAux.cpp @@ -1690,14 +1690,13 @@ bool Atlas::sendCommand(char* command) auxWire.requestFrom(deviceAddress, 1, true); uint8_t confirmed = auxWire.read(); auxWire.endTransmission(); - delay(shortWait); if (confirmed == 1) { lastCommandSent = millis(); return true; } - // delay(300); + delay(shortWait); } return false; }