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.
Once loaded the Sleepy Pi should be selected as a target from the Tools menu. If it doesn’t appear for whatever reason try just selecting the Arduino Fio which from a programming perspective, is identical.
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):
sudo apt-get install i2c-tools
You can then check that the tools are working and that you can see the i2c devices:
sudo i2cdetect -y 1
The device at address 0x24 is the GPIO chip and the 0x68 is the Real Time Clock.
To switch the Software Jumper ON type:
i2cset -y 1 0x24 0xFD
to switch the Software Jumper OFF (power on default) type:
i2cset -y 1 0x24 0xFF
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.
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.
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.
Well you did warn me that “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.” might corrupt the Pi, you didn’t warn me it would ‘brick’ the Sleepy Pi. My Pi is working fine, but now I can’t program the Sleepy Pi. I’m getting “avrdude-original: stk500_recv(): programmer is not responding”. Arduino.cc troubleshooting tells me this is a corrupted bootloader, any instructions on how to do that? I’ve ordered the FTDI 3.3v cable from Farnell, and have the programming circuit diagram.
Hi together,
I am using a pi zero and would like to access the arduino from command line (or vs code via ssh).
Is there a possibility to program the arduino from my pi zero without GUI?
My goal is simple. I want to PiZero to Power the PiZero every 3 hours (and additionally I want to button to be able to power on/off the pi.
Thank you 🙂