I am trying to capture serial data from an arduino sensor (humidity, temperature, etc) and have a shell script send to a server to add to a MySQL database.
Jeff Keyzer seems to do something similar here http://mightyohm.com/files/wifiradio/interface.sh:
while true # loop forever
do
inputline="" # clear input
# Loop until we get a valid reading from AVR
until inputline=$(echo $inputline | grep -e "^temp: ")
do
inputline=$(head -n 1 < /dev/ttyUSB0)
done
echo "$inputline"
done
When I run the above script on my linux machine and the below test code on my arduino, I don't get consistent results.
int count = 0;
void setup() // run once, when the sketch starts
{
Serial.begin(9600); // set up Serial library at 9600 bps
}
void loop() // run over and over again
{
Serial.print("temp: ");
Serial.println(count);
count++;
delay (5000);
}
Anybody know what I am doing wrong?
I get stuff like :
temp: 5
temp: 7
temp: 9
temp: 2
temp: 27
etc
Thanks in advance!