Alternatively, you can supply a lower voltage into the barrel jack to reduce the amount of heat dumped on the regulator, for instance 9 volt power supplies are common and easy to find.

If you are dealing with motors, robots, relays and the like, they should be supplied with power separately from your microcontroller. For bigger projects, the design of power supply is a whole subject in itself, and you should invest time in learning about it. Make sure you cover the following:

Does the system over-stress the power supply in ‘normal’ operation?

Does the power supply overheat, as is typical for Arduinos?

Do you have bursts of power demand — typical for relays, 3G modems, etc.

Do you have the voltage you need — i.e. 5 volts. not 5.4.

Do you have noise is the system, i.e. the voltage jitters up and down.

Do power-hungry items like relays and motors make sure your board is protected.

I2C hang

I2C bus is a two-wire communication bus that allows a microcontroller to talk to a wide variety of chips (typically sensors), and all of them can share the same wire, which is great.

This is where Arduino has created a pitfall. Every reasonable MCU programming framework, such as MBED, will issue a command to the sensor, and if there is no response withing a defined period of time, it will assume that the sensor is disconnected or damaged. The function will return an error and your code will continue working.

However, when Arduino is given a command to talk to an I2C sensor, it will wait for a response forever. Disconnecting or damaging I2C sensors will cause your program to stop dead.

This can be fine if all the I2C devices you are using are integral to your system. For example if you have a timed irrigation system, and have an I2C clock, without knowing the time your system can’t work anyway. In other cases it is a major problem — we had I2C soil moisture probes that are connected and disconnected quite often, and having our system get stuck every time owuld be unacceptable.

There are some re-implementations of the I2C library where this problem does not occur,. This is the one I have used in my projects and can recommend.

Watchdog Timer

Sometimes despite our best efforts our code gets stuck or malfunctions. This could be cause by I2C hang, bugs in our code, or cosmic radiation. Whatever the cause, if we deployed an Arduino on a remote island or in space, we can’t afford to keep sending people to click the reset button. This is where the watchdog timer comes in.

Watchdog timer is a countdown mechanism withing the microcontroller that will reset the MCU when it reaches 0. Let’s say you activated the Watchdog, and set it to a 4-second timer. Somewhere in your code you need to ‘Pet the Dog’ every 4 seconds. If your code ever gets stuck, the Watchdog will no longer gets ‘petted’ and will byte, causing the whole microcontroller to reset.

It is up to you to decide when and why you want to pet or not pet the dog, for instance you could reset the Micro-controller if you are experiencing networking problems. Watchdog time is one of the most effective ways to improve reliability of your project.

The Reset Line

Regardless of the reason why your microcontroller got reset, if you have other chips attached to your main board, you can’t assume that they got reset as well. This is especially true if you are using a Watchdog — it will only affect the MCU and not any other chips.

You have to write your firmware so that as soon as the microcontroller starts, it sets all the shields, sensors, motors, whatever — into a known state. Usually that just means resetting everything. Normally chips that need resetting have a special pin for it, but it is often left unconnected in different development kits and Arduino shields for ‘ease of use’.

The Arduino Ethernet Shield is a prime example — it has a network chip that manages communication, keep connections to the server open, etc. It is vital to know what state it is in, and the official Ethernet shield has the reset pin connected to GND, so you can’t reset the chip from software.