Difference between revisions of "Raspberry Juice"
(→Use) |
|||
Line 8: | Line 8: | ||
The Juice always uses about 2mA/10mW. The board is rated for a maximum current of 1A. |
The Juice always uses about 2mA/10mW. The board is rated for a maximum current of 1A. |
||
= Protocol definitions = |
|||
= Use = |
|||
The Raspberry Juice can be found using I2C or SPI at address 0xA4, and has the following read ports: |
The Raspberry Juice can be found using I2C or SPI at address 0xA4, and has the following read ports: |
||
All times are in ms, and are 32 bits in size. |
All times are in ms, and are 32 bits in size. |
Revision as of 16:41, 2 June 2015
Overview
The Raspberry Juice serves as a power switch for the Raspberry Pi. This expansion board can turn the power on or off at a scheduled time. shop link
Specifications
The Juice always uses about 2mA/10mW. The board is rated for a maximum current of 1A.
Protocol definitions
The Raspberry Juice can be found using I2C or SPI at address 0xA4, and has the following read ports: All times are in ms, and are 32 bits in size.
Port | Returned value (in milliseconds) | |
---|---|---|
0x20 | Time until power off | |
0x21 | Time until power on | |
0x30 | button active | 0: don't react to button press. 1: react to button press (default), others: undefined. |
0x31 | external input active | 0: inactive (default), 1: active, others: undefined. |
0x32 | external input polarity | 0: active low (default), 1: active high, others: undefined. |
0x33 | power set on/off state | 0: off, 1: on, others: undefined. |
0x38 | button active powerupstate | 0: don't react to button press. 1: react to button press (default), others: undefined. |
0x39 | external input active powerupstate | 0: inactive (default), 1: active, others: undefined. |
0x3a | external input polarity powerupstate | 0: active low (default), 1: active high, others: undefined. |
0x3b | power set on/off state powerupstate | 0: off, 1: on, others: undefined. |
Additionally, the following can be written to the Juice:
Port | Effect | |
---|---|---|
0x20 | Set the time in milliseconds until power off | |
0x21 | Set the time in milliseconds until power on | |
0x30 | button active | 0: don't react to button press. 1: react to button press (default), others: undefined. |
0x31 | external input active | 0: inactive (default), 1: active, others: undefined. |
0x32 | external input polarity | 0: active low (default), 1: active high, others: undefined. |
0x33 | power set on/off state | 0: off, 1: on, others: undefined. |
0x38 | button active powerupstate | 0: don't react to button press. 1: react to button press (default), others: undefined. |
0x39 | external input active powerupstate | 0: inactive (default), 1: active, others: undefined. |
0x3a | external input polarity powerupstate | 0: active low (default), 1: active high, others: undefined. |
0x3b | power set on/off state powerupstate | 0: off, 1: on, others: undefined. |
usage
Connect the raspberry pi to your raspberry juice by I2C or SPI. Take care that the "power" of the I2C or SPI connector on the 'juice is connected to the 5V of the 'pi. Connecting it to the 3.3V supply rails will most likely end in disaster.
Now connect the adapter that you normally use to power the 'pi to the USB connector on raspberry juice board. The raspberry pi should start to boot.
user input
If you hit the button on the 'juice the power to the 'pi will toggle. It is better not to do this when the 'pi is on, but you can force a shutdown this way, just like pulling the power cord.
software control
You can use SPI or I2C to tell the 'juice to do things with the power to the 'pi. First of all, writing a 32-bit integer to register 0x20 and 0x21 will schedule a power-down and a subsequent power-up after the specified number of miliseconds. This way you can put your 'pi to deep-sleep under software-control, and schedule a wakeup at some future time. An example might be that you have to perform a certain task every hour, but that task only takes a few minutes. So after performing the task, the 'pi will schedule a "poweron" event after about 60 minutes, perform a clean shutown, and then request a powerdown in the shutdown-procedure.
halting the 'pi
In the function "do_stop () " in the file /etc/init.d/halt, just before the last line that has "halt" in it you can add:
bw_tool -I -D /dev/i2c-1 -a a4 -W 20:800:i
this will powerdown the 'pi 2048 miliseconds after executing this command. This gives the 'pi time to finish the shutdown procedure, and then cuts the power.
examples
So, for instance, writing 10000 to port 0x21 and 1000 to 0x20 will cut the power in 1 second, and then turn on the power 9 seconds later.
bw_tool -I -D /dev/i2c-1 -a a4 -W 21:2710:i 20:3e8:i
Note that bw_tool works with hexadecimal numbers. So 2710(hex) is 10000 decimal, and 3e8 is 1000 decimal.