The problems I have come along while prototyping
When you start prototyping with microcontrollers you will encounter certain problems and bugs. I have collected the issues I had, so that you do not have to google multiple hours.
There are some general rules which make your work with microcontrollers easier:
- When you get a new Arduino component, test it individualy before adding it to a bigger project!
- While testing a new Arduino component, take a look at the official datasheet, manual or guide!
- Use the serial monitor for debugging!
Picking the right Arduino IDE for the WiFi Shield
It took me a while to find out that there is only one Arduino IDE which is working with the WiFi Shield. When I started with my first Arduino UNO board I installed the latest Arduino IDE (1.0.6), because it was the latest and marked as stable. Unfortunately the Arduino WiFi Shield prefers Arduino IDE 1.0.2! Usually it is no problem to install multiple IDE versions on your computer...but I got a feeling that the multiple versions on my macbook triggered another error when working with the Arduino Mega 2560...
How to keep a persistent connection to a web-server alive?
When connecting to servers in the internet via WiFi I encountered some headstrong issues.
My Arduino WiFi Sensor Platform worked fine for about two weeks and then suddenly it stopped sending data to my server. So I thought that the WiFi Shield maybe lost connection to the WLAN router and I added the RSSI signal strength to data stream for my php-script. In my living room (location of the WLAN router) the signal strength is approx -50 dBm and when I move the WiFi sensor platform to my sleeping room it drops to - 72 dBm! As long as the signal is above - 80 dBm the connection should be ok.
After I made some adjustments in the code it worked perfectly for almost 24 hours and then stopped sending data my server again...
Learn to hate a dude called AVR
Probably the worst nightmare of Arduino Mega owners:
avrdude: stk500v2_ReceiveMessage(): timeout
It is a known bootloader problem since 2009...that is at least the oldest timestamp I could find on a related post. The first thing you should do is a loopback test on your board. Connect digital 0 to digital 1 with a jumper, type something into the serial monitor and hit return. If you do not get a response your board might be broken!
If you get a response from the loopback test your hardware seems so be ok. Try to upload your sketch from another PC. If that is also not working you have to burn the bootloader on your Arduino Mega. Notice: you need nother Arduino board to burn the bootloader. Instructions here...
That fixed it for me:
Using the Arduino IDE on a Windows PC instead of a Mac. I guess multiple Arduino IDE versions and cross launching them caused the problem in the first place.