So my Arduino code seems to stop after a while, and I don't see why it's doing that. Now... when I say a "while" of usage, I generally mean a couple hours
So here's what is going on, after running the following code:
//TMP36 Pin Variable
int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures
int tweetBluePin = 2;
void setup()
{
pinMode(tweetBluePin, OUTPUT);
Serial.begin(9600); //Start the serial connection with the computer
}
char inData[40]; // Allocate some space for the string
char inChar; // Where to store the character read
byte index = 0;// this tracks position in a char array that serial is writing to
int reading; //variable used for AdaFruit code
float voltage; //variable used for AdaFruit code
float temperatureC; //variable used for AdaFruit code
void loop()
{
//following code from http://forum.arduino.cc/index.php/topic,45629.0.html
inData[0] = '\0';
index = 0; // Index into array; where to store the character
while(Serial.available() > 0) // Don't read unless
// there you know there is data
{
if(index < 39) // One less than the size of the array
{
inChar = Serial.read(); // Read a character
inData[index] = inChar; // Store it
index++; // Increment where to write next
inData[index] = '\0'; // Null terminate the string
}
}
// Now do something with the string (but not using ==)
//end code from http://forum.arduino.cc/index.php/topic,45629.0.html
if (strcmp(inData, "temperatRoomAI") == 0)
{
//AdaFruit code for use with: http://www.adafruit.com/products/165
//though much of this is probably going to be moved to computer side with python
reading = analogRead(sensorPin);
// converting that reading to voltage, for 3.3v arduino use 3.3
voltage = reading * 5.0;
voltage /= 1024.0;
// now convert to the temperature in Celsius
temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree with 500 mV offset
//to degrees ((volatge - 500mV) times 100)
//end of AdaFruit code
Serial.print("temperatureRoomAI: ");//display the temp in celsius to serial
Serial.print(temperatureC);
Serial.print("degreesC\n");
}
if (strcmp(inData, "newTweetRoomAI: 1") == 0)//from a twitter python program, when new tweets are received it turns on an led until it receives the code to turn it off
{
digitalWrite(tweetBluePin, HIGH);
}
if (strcmp(inData, "newTweetRoomAI: 0") == 0)//this is the code to turn off the led, for when all tweets are read
{
digitalWrite(tweetBluePin, LOW);
}
delay(1000);
}
So this code hooks up for Serial communication with a Raspberry Pi, turns on a blue LED through the Arduino if I receive a new tweet, turns it off once read, and through a temperature sensor pin can relay back that temperature information. However after a couple hours of running, suddenly the Arduino stops receiving/transmitting data.
I'm EXTREMELY new to this (and coding in general) so my question is: if anyone has any idea whats happening could you please point me in the right direction? I can include (almost) any other setup information if necessary. (note, this is Arduino 1.0.4 IDE)