The Sleepy Pi is very flexible about power and can take power from many sources. However, to get the lowest power consumption you need to be aware of a couple of things:
If you put 5V into the Power I/P Header it will most likely work, BUT the regulator will work flat-out to ferry the 5V from the input straight to the output and not be able to go into a low power mode. Thus, you’ll find that the “Sleep” current is much higher than expected (10-20mA) whereas it should be 200uA or below.
Yes, There seem to be a lot of these coming onto the market, typically used to recharge your mobile phone or tablet whilst on the go.
Plug these into the USB power socket on the Sleepy Pi 2 (NOT the Raspberry Pi) which will pipe the power straight through the regulator giving you the lowest possible power consumption. Don’t use the power jack as that is meant for voltages above 5V.
However be aware that some of these batteries have a minimum current draw; typically 50mA which they use to work out whether they are charging anything or not. If they think there’s no load, then they will switch off. When running the Sleepy Pi 2 with the Raspberry Pi asleep, the current draw will be well below this threshold and they will switch off, which means no power to the system and it will never wake.
Yes, the main supply (not the 5V) is fed into an analogue input (ADC6) of the Arduino or A6 using the analogRead function. There is an Arduino Sleepy Pi 2 function that directly returns the scaled voltage reading:
When the Raspberry Pi is switched off and the Arduino is in a low power sleep, it consumes around 180uA for a 12V input.
You will find that most bench multimeters are not able to measurement currents this low accurately. If you are into your low power, I recommend getting hold of one of Dave Jones’s uCurrent boxes which will turn your multimeter into a super accurate, low current measuring device.
This will depend on how often you power up the Raspberry Pi and for how long. For best battery life optimise the boot time and shutdown the Raspberry as soon as you can.
The Sleepy Pi 2 has 3 switched power outputs. These share power with the Raspberry Pi and Sleepy Pi 2 circuitry, but can supply to the outside world:
For the V+ and the 5V you can draw up to 500mA from either but not together i.e. the total draw shouldn’t exceed 500mA.
Note: The expansion power is separately switched from the Raspberry Pi power. Therefore, when you power up the Raspberry Pi you can choose if and when, to power up the expansion power. Similarly, you can leave the expansion powered when the Raspberry Pi is powered down.
The expansion power is normally off and needs to be switched on in software. The command:
will switch the power on and “false” will switch it off.
The optional power jumper is mainly used when developing Arduino code in the Raspberry Pi and uploading the code to the Sleepy Pi 2. Because the Arduino controls power to the Raspberry Pi, if you reset it, which occurs when you upload code, the Pi will be instantly powered off. Which is a bit of a chicken and egg situation! Adding in the power jumper forces the power to the Pi regardless of what the Arduino is doing and allows you to upload code.
Sleepy Pi 2 has both a hardware and software jumper – either can be used. The software jumper is described in more detail on the programming page.
There are a number of ways to do this, and all need 3 additional things:
One way, is to use a setup commonly used for either camping or sailing. These can be found quite cheaply on eBay or similar and consist of e.g 10W solar panel intended for 12v use, 12V lead acid battery and 12V solar charge controller. Connect the output of the controller to the Vin input of the Sleepy Pi.
No, the Raspberry Pi does not have any power management capabilities. It is in effect always on, even when you command the system to “halt”. This is one of the reasons why the Sleepy Pi was created, to allow a virtual low power mode to be realised on the Raspberry Pi.
The Sleepy Pi 2 controls the power to the Raspberry Pi via a switch. When it “decides” that the Raspberry Pi is needed it will switch on the power to the Raspberry Pi and wait for it to boot.
There are various ways that you can set-up the Sleepy Pi 2 to switch on the Raspberry Pi. These could be:
The Sleepy Pi 2 has two handshake lines available over the Raspberry Pi GPIO: 24 & 25. These can be used to co-ordinate a safe shutdown of the Operating System (OS) i.e. Raspbian. Once the Sleepy Pi 2 has detected that the OS is no longer running it will physically cut the power from the Raspberry Pi and go into a low power mode.
Sleepy Pi 2 also has an alternative / augmented way of detecting that it is safe to shutdown the Raspberry Pi. It has the ability to measure the current draw of the Raspberry Pi, which changes significantly after the Raspberry Pi has executed an OS shutdown using something like:
In certain applications, you can use this feature instead of using the handshake lines, thus freeing up additional GPIO pins. The example ButtonOnOff_CurrentRead shows how to do this.
No, if the handshake lines are used correctly, they ensure that the Operating System is in a safe state before cutting the power. This avoids power-loss SD card corruption.
The speed of boot is dependent on many factors. These include:
As an example a plain vanilla Raspbian install running off a typical SD card will boot up in around 30 seconds.
There is an interesting series of articles in The MagPi magazine issues 15 and 20 entitled “Baking your own Raspberry Pi filling”. This describes a way of building your own linux image with only the parts you need. Boot times are slated to be region of 5 – 10 seconds.
This thread on the Raspberry Pi forums also contains some interesting information about how to optimise the boot process.
Yes, the Sleepy Pi 2 has a current measurement chip build into it that measures the Raspberry Pi current draw. The main design reason for this, was to provide an measurement of the Raspberry Pi state that was independent of any GPIO handshake lines. When a Raspberry Pi is “running” in draws far more current than it does when the OS has been commanded to shutdown with a
Depending on the model of Raspberry Pi, this OS shutdown current will vary from about 50 – 90mA. Therefore, you can set a current threshold of around 100mA and use that to trigger removing the power from the Raspberry Pi. To measure the current from the Arduino:
The example ButtonOnOff_CurrentRead shows an implementation of this.
Of course, you can also use this feature to log Raspberry Pi current in various states or boot up.
Absolutely, the Arduino processor (ATMEGA328P) is totally uncommitted and is available for use with your own code. There is a Sleepy Pi 2 Arduino library that allows your code easy access to standard Sleepy Pi 2 functions. This page gives an further notes on writing code on the Sleepy Pi 2 and also check the Sleepy Pi 2 Github page for the latest code and examples.
Yes, the Sleepy Pi can run as a standalone, power optimised, Arduino style board. You can program the Arduino with either a direct link to a host computer, or you can temporarily connect it to a Raspberry pi.
Yes, you can talk to the Real-time clock from both the Raspberry Pi and the Arduino. The RTC on the Sleepy Pi uses the Linux driver for the PCF8523. See this page for more details.
The Sleepy Pi 2 is intended to be programmed via the bootloader and a serial link. However, if you want to burn another bootloader or want to flash code directly and dispense with the bootloader, then you can do this via an Atmel AVR programmer such as the AVR-ISP MkII.
There is a small programming header on the board that takes a special programming cable from Tag Connect – the TC2030-IDC-NL-10. This replaces the normal cable on the AVR-ISP. I’d also recommend getting the TC2030-CLIP to hold the cable in place.
Yes, the HAT eeprom is programmed as standard in the Sleepy Pi 2 with the following information:Product ID: 0x2785Product Version: 0x014AVendor: “Spell Foundry”Description: “Sleepy Pi 2 Power Management Board”
You can check that the board is present and view the product name from the command line with something like:
which will print out “Sleepy Pi 2 Power Management Board” on the command line.
es, you can use the Arduino watchdog facilities and the bootloader that is used is compatible with the watchdog.
This watchdog can be demonstrated with the following code:
The Arduino chip on the Sleepy Pi family is an ATMEGA328P and is similar to say, an Arduino Uno. However, it should be noted that the Sleepy Pi’s run at 8Mhz and have 3V3 GPIO’s whereas many Arduinos run at 16Mhz and has 5V GPIO (particularly the older ones). In most cases the clock speed is not an issue, but the GPIO voltages are important when porting an application from another Arduino setup.
The pinouts can be found here. Note that the Arduino on the Sleepy Pi is 3v3 the same as the GPIO on the Raspberry Pi. Do not connect 5V I/O to these pins.
The Arduino on the Sleepy Pi 2 is 3v3 the same as the GPIO on the Raspberry Pi. Do not connect 5V I/O to these pins.
The Sleepy Pi optionally uses the following Raspberry Pi GPIO lines:
Most of these lines are not exclusively for use with the Sleepy Pi 2 and can be used for other things if required. Further information can be found on this page.
Yes, but you need to check compatibility in terms of which GPIO pins are used. The Sleepy Pi 2 incorporates a stacking header on the Raspberry Pi GPIO which can be used with other expansion boards.
The RTC uses a CR1620 or CR1632 (best) coin cell. Due to legal restrictions with shipping Lithium batteries, this is not supplied with the Sleepy Pi 2.
No. The RTC battery will keep the time if you disconnect the main power supply from the board, but if you keep your main power supply to connected after you have set the clock, then the main supply will keep the clock running even when the Sleepy Pi is asleep and the Raspberry Pi powered down. In these circumstances you don’t need the battery backup.
To power a Sleepy Pi 2 / Raspberry Pi setup in a car, connect a power feed from the car battery to the Power I/P Header of the Sleepy Pi (this is good up to 30V). This feed should not go off when the ignition is off – it needs to remain so that you can safely shutdown the Raspberry Pi after you stop and then the Sleepy Pi will go into a low power mode to prevent battery drain.
In most cases to effectively shut the system down, you need to detect that the ignition is off. For this you need a battery / ignition feed that goes low / off when the ignition is off that you can feed into a Sleepy Pi GPIO. The key here is that, this will most likely be at 12V when the ignition is on and needs to be dropped down to 3v3 for the Sleepy Pi GPIO. The easiest way to do this, is via a voltage divider:
It’s worth noting that car batteries are seldom only 12V all the time and will often go a lot higher, so it’s worth calculating the divider to cope with voltages such as 14.4V. The resultant voltages into the Arduino GPIO needs to be above about 2V to register as a “high”, so there’s quite a range. In the example divider I’ve used 36k and 10k, but any values that give a rough 4:1 could be used. It’s also worth popping in a 3V3 zener (eg. BZX79-C3V3,113, just to clip the voltage to 3V3 in case it does go too high. You can make up this circuit on a piece of veroboard or on a prototyping blanket with appropriate headers (e.g.standard).
If you are trying to access the Real-Time Clock from the Raspberry Pi and you get an error such as:
Error: Could not open file /dev/i2c-1' or /dev/i2c/1′: No such file or directory
then it might be that you haven’t enabled the i2c bus from the Raspi-config utility.
From a Terminal type:
From the menu select “Advanced Options” and then “A7 i2c” and click “Yes”to enabling the interface.
You can often see this when running one of the examples such as WakeUpPiOnAlarm. The culprit is generally the Raspberry Pi and not the Sleepy Pi 2. As the Raspberry Pi has access to the RTC, it can sometimes talk to the RTC at boot and reset the RTC, hence you don’t get the subsequent boots.
You can check this by running the Sleepy Pi 2 standalone off the Raspberry Pi and setting the wake time to something like 10 seconds. You should see the LED’s flash every 10 seconds.
Another way to check is to install a fresh copy of Raspbian with no configuration and it shouldn’t mess with the clock.
The solution is to root out any code that might be taking to the clock.
Your email address will not be published. Required fields are marked *