Using these devices I have built a base station for wireless sensor nodes (with RFM12B). It works well for approximately 6h. After that the code seems to freeze and the LED next to pin 10 blinks rapidly. Reset does not help. When I remove the power source and reattach it, everything starts to work again. My code can be seen here: /* Open Kontrol Gateway (OKG) Example Receive data from an emonTx via RF - Pastebin.com
Do you have the serial monitor open when the fail occurs? What is the last thing displayed?
If you need a comparative test, I have my ethernet client code on the playground. It has all the "antifreeze" functions in it I could find. Give it a try and see if it locks up also. http://playground.arduino.cc/Code/WebClient
I have run it for days without failure or lockups, and I torture it by disconnecting the cat5, power cycle the router, disable the server, etc, and it keeps running.
Then these are both evaluating to false or you would get "disconnecting" or "Connecting". I would guess that "client.connected()" is evaluating to true, so "!client.connected()" would evaluate to false.
if (!client.connected() && lastConnected) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
if (!client.connected() && data_ready) {
Serial.println("Connecting");
Check client.connected() like this at line 256 (after the "ok" print at line 254)
When everything freezes after working stable for a while pin 13 blinks rapidly although I'm not even using it in my scetch... What could this error indicate?
mudem:
When everything freezes after working stable for a while pin 13 blinks rapidly although I'm not even using it in my scetch... What could this error indicate?
It could indicate that the D13 pin is floating and oscillating wildly. Set D13 as an OUTPUT and LOW in your setup function. It should be LOW by default, but I always make sure just in case.
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Does that stop the blinking?
What is the rf12 device? Is it connected also? Is it this device?
Did you notice it is also uses a SPI bus? How is it wired to the Mega/shield?
mudem:
When everything freezes after working stable for a while pin 13 blinks rapidly although I'm not even using it in my scetch... What could this error indicate?
I think arduino pin 13 is used for a clocking pin by the Ethernet shield. It may look some what dim when the Ethernet shield is in use (as opposed to a blink sketch) as it is actually blinking on/off very fast.
mudem:
When everything freezes after working stable for a while pin 13 blinks rapidly although I'm not even using it in my scetch... What could this error indicate?
I think arduino pin 13 is used for a clocking pin by the Ethernet shield. It may look some what dim when the Ethernet shield is in use (as opposed to a blink sketch) as it is actually blinking on/off very fast.
It's a Mega 2560. That model doesn't use D13 for the SPI clock. It uses D52.
mudem:
When everything freezes after working stable for a while pin 13 blinks rapidly although I'm not even using it in my scetch... What could this error indicate?
It could indicate that the D13 pin is floating and oscillating wildly. Set D13 as an OUTPUT and LOW in your setup function. It should be LOW by default, but I always make sure just in case.
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Does that stop the blinking?
What is the rf12 device? Is it connected also? Is it this device?
https://www.sparkfun.com/datasheets/Wireless/General/RF12B-IC.pdf
Did you notice it is also uses a SPI bus? How is it wired to the Mega/shield?
rf12 device: http://nathan.chantrell.net/tinytx-wireless-sensor/
It is connected to pins 50, 51, 52 and SS is connected not to pin 53 but to pin 11. This is configured just before initialize rf12_set_cs(11);
Still hangs eventually But now I have new debugging results.
I added few leds to the mix and using this code: http://pastebin.com/B344fJYX I was able to find that the code freezes somewhere between lines 276 and 288 because both pin 7 and 8 are high and this ony happens in those lines.
Before the issue was probably the same but because the code had watchdog it reseted Arduino when this was detected.
Seems like emoncms.org just does not accept data coming from client.print and thus ethernet code remains stuck.