Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
void loop() {
getWaterLevel();
checkWaterLevel();
delay(DELAY_IN_SECONDS * 1000);
}
int getWaterLevel() {
waterLevel = analogRead(waterLevelPin);
return waterLevel;
}
int sendSms(String command) {
if(command.length() > 0){
Particle.publish("twilio", command, 60, PRIVATE);
}
return 0;
}
void checkWaterLevel() {
int currentLevel = analogRead(waterLevelPin);
if(currentLevel > waterThreshold) {
if(!isMessageSent){
char msg[255];
snprintf(msg, sizeof(msg), "Dags att tömma vatten i källarn! Nivå: %d", waterLevel);
sendSms(msg);
isMessageSent = true;
}
}
if(isMessageSent && (currentLevel < waterThreshold)) {
isMessageSent = false;
sendSms("Du har tömt ser jag, lysande polarn!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment