Hi,
I am using a Yun to run a watering pump depending on the soil humidity in my greenhouse. Whilst this is working fine, I would like to be able to check the values when not being at home. So I am sending data to thingspeak. It's crucial that the sketch runs regardless of potential network dropouts, so I thought it would be a good idea to upload data on the Linux side (via curl) in a non-blocking way. I am new to Arduino but I guess that runShellCommandAsynchronously() should do the job.
Here is a short example
#include <Process.h>
Process p;
String command_string = "";
long THINGSPEAK_INTERVAL = 60000;
long lastThingspeakUpdate = 0;
void setup()
{
//...
}
void loop()
{
// control the watering
// Send data to ThingSpeak
if((millis() - lastThingspeakUpdate) >= THINGSPEAK_INTERVAL){
command_string = "curl --data \"api_key=";
command_string += String(myWriteAPIKey);
command_string += "&field1=";
//assembly of curl command
command_string+= "\" https://api.thingspeak.com/update";
p.runShellCommandAsynchronously(command_string);
//delay(10000);
//p.close();
lastThingspeakUpdate = millis();
}
}
This works fine but after each run it leaves curl as a zombie process on the Linux side. That zombie gets killed when a new data upload is due but it feels as if I am doing something wrong. Do I need to close the process? I thought about a p.close() after a delay but on the other hand this seems to contradict the idea of a process running in the background. When I run curl from the prompt it runs and finishes within a second.
Should I worry about the zombie?