Programming from the Arduino IDE

Configuring the Arduino IDE

If you have used the Sleepy Pi setup script the Arduino IDE and libraries should be installed and ready to use apart from selecting the Board.

The Arduino IDE can be found on the Main GUI menu in the Electronics section.

Arduino IDE on Electronics Menu

Once loaded the Sleepy Pi should be selected as a target from the Tools menu.

Select Sleepy Pi in the Arduino IDE

Power Bypass Jumper Options

If you are programming the Sleepy Pi from the Raspberry Pi, there is one important fact that ye must know:

The Arduino on the Sleepy Pi controls the Raspberry Pi power. When you program it, it gets reset. When it gets reset it forgets to keep the power on to the Raspberry Pi……Goodnight Vienna – the Pi powers down. Doh!

So before you can program the Arduino, you need to override the power. On both Sleepy Pi and Sleepy Pi 2 there is a physical jumper that you can bridge. Sleepy Pi 2 also has the facility to use a software jumper instead.

Hardware Jumper

On Sleepy Pi 1, the hardware jumper is pre-soldered in place. On Sleepy Pi 2 is suppled with a 2-pin header and a jumper which can be soldered into the Power Bypass location. This has the effect of bypassing any software control and forcing the power onto the Raspberry Pi.

Note: On Sleepy Pi 2 if you elect to use the Software Jumper, then you don’t need to solder in the Hardware Jumper….

Sleepy Pi 2 Software Jumper

The Power Bypass can alternatively be enabled in software via an 12c GPIO chip. This is independent of the Arduino so is not effected by code upload. To access this chip from the Raspberry Pi, first ensure that the i2c tools are installed (skip if they are already installed):

You can then check that the tools are working and that you can see the i2c devices:

i2c devices detected on Sleepy Pi 2 bus

i2c devices detected on Sleepy Pi 2 bus

The device at address 0x24 is the GPIO chip and the 0x68 is the Real Time Clock.

To switch the Software Jumper ON type:

to switch the Software Jumper OFF (power on default) type:

CAUTION if you remove the software jumper without the Arduino having “taken over” control of the power via your program, it will unceremoniously cut the power to the Raspberry Pi – NOT do a controlled shutdown.

Testing the Software Upload

To test that you can program the Arduino correctly the “Blink” sketch is always a favourite. It can be found from the File > Examples > 01.Basics > Blink menu.

Load Arduino "Blink" sketch

Ensure that you have a Power Bypass strategy in place and then press the “Upload” button and the sketch will be compiled and uploaded. You should see a message from the “autoreset” displayed in the bottom status area.

"Blink" sketch compilled and loaded showing autoreset

If the sketch is successfully loaded, then the amber LED will begin flashing.

NOTE: On later installations of Raspbian / Arduino IDE you can see a series of “broken pipe” messages on upload. Though disconcerting, these don’t seem to affect the code upload and can be ignored.

Back to Top