Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only send temperature command if temperature reading is valid #65

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions sam/src/SckAux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1694,28 +1694,28 @@ bool Atlas::sendCommand(char* command)
}
bool Atlas::tempCompensation()
{
// Temperature compensation for PH, EC, and DO
float temperature;

if (!ORP) {
// Temperature compensation for PH, EC, and DO
float temperature = -1000;
#ifdef WITH_DS18B20
if (waterTemp_DS18B20.detected) temperature = waterTemp_DS18B20.getReading();
else if (atlasTEMP.detected) {
if (waterTemp_DS18B20.detected) {
temperature = waterTemp_DS18B20.getReading();
} else if (atlasTEMP.detected) {
#else
if (atlasTEMP.detected) {
#endif

if (millis() - atlasTEMP.lastUpdate > 10000) {
while (atlasTEMP.getBusyState()) delay(2);
}

temperature = atlasTEMP.newReading[0];
}

char data[10];
sprintf(data,"T,%.2f",temperature);
if (!sendCommand(data)) return false;

// Only compensate if temperature is actually there
if (temperature > -1000) {
char data[10];
sprintf(data,"T,%.2f",temperature);
if (!sendCommand(data)) return false;
}
}

// Salinity compensation only for DO
Expand All @@ -1734,6 +1734,7 @@ bool Atlas::tempCompensation()

return true;
}

uint8_t Atlas::getResponse()
{

Expand Down
Loading