Can I use the Notecard to turn my Raspberry Pi on and off?

I would like to have the ability to remotely control the power to my Raspberry Pi.

  1. Is this possible?

  2. Can I do it using the Notecarrier Pi

Yes, but you cannot use the Notecarrier Pi for this

There are a couple of reasons:

  1. The Notecarrier-Pi is powered by the header pins from the Raspberry Pi

  2. The Notecarrier Pi wires the ATTN Pin to GPIO6 on the Raspberry Pi (pin 31 on the header). It also uses I2C for communication between the Raspberry Pi and the Notecard.

You could use any other currently available Notecarrier such as the Notecarrier AL

Use the Notecard ATTN Pin

This will require some hardware development.

NOTE Raspberry Pi is not generally considered for low power applications. You may want to consider using a different host processor that is better suited for low power applications. See Host Power Management for more about using Notecard to control the host MCU power state

The ATTN pin on the Notecard can be configured to change state depending on changes to Notefiles, timeouts, cellular connection status, location updates, and motion.

That is, you can configure the ATTN pin to go HIGH if it receives a Note in a specific QI-Notefile. In this case we will make up a name “wakeup.qi”

{"req":"card.attn","mode":"arm, files","files":["wakeup.qi"]}

This will set the ATTN pin LOW.

When the Notecard receives changes to “wakeup.qi” from a sync with Notehub, it will set the ATTN pin HIGH.

Hardware Configuration

The part I’m a little unclear about the “best” way to wire this up. It will depend on your application and experience with Raspberry Pi and hardware development.

Control Power Directly Option:

You could wire it directly to a transistor, relay, or opto-isolator that gates the power supply to the Raspberry Pi.

This means:

  • power is only applied to the Raspberry Pi if the ATTN pin is HIGH
  • power will be disabled after issuing the card.attn request above.

Straight forward, but it prevents you from using the ATTN pin for other purposes.

The RUN Pin:

You could wire the ATTN pin to the RUN pin on the Raspberry Pi.
I’m not sure of all of the implications here. I believe it is similar to the “control power directly” option listed above

Soft shutdown/restart Pin:

You could wire the ATTN pin to GPIO3 on the Raspberry Pi.
This is not particularly well documented, but this pin can by used to “wake up” a Raspberry Pi that has been disabled using a soft shutdown. I don’t believe this entirely powers down the Raspberry Pi.

In this case, I believe you would need to invert the logic of the ATTN pin with some gates.

GPIO3 on the Raspberry Pi shares functionality with the I2C communications. So if you use this method, you will have to use the UART RX/TX lines for Raspberry Pi to exchange messages with the Notecard.

The advantage here is you could potentially use the ATTN pin to react to other events while the Raspberry Pi is powered on, and not be limited to just the wakeup event request.

1 Like

Great piece thanks. Very helpful although I’ve battled through most of this over the past week!

Currently trying to make this work with the ATTN pin…

The other way you can skin the cat is what I was doing, which is to power through the Witty Pi 3 Mini which then powers both the Pi and the Note/Carrier based on an alarm event

The problem I see with this is that I don’t believe my NB-IoT Note should be turned off. The modem is designed to be left on in low power and it can’t be a good thing to be dropping off the network randomly/periodically due to power loss.

In fact the events I was seeing were somewhat bothering me really, I see you’re sending texts when there’s a power cut…

Now I think if I was going to carry on with the Pi carrier what I could do is separate the power pin from the bus and instead connect it to the power out bergstick header from the Witty which I think would leave the Note on all the time. Haven’t looked at that as I am going to move over to a NoteCarrier A instead I think.

Here’s a quick video I did on powering a Pi Zero via the ATTN pin