Switching off arduino and pi

arduino
raspberrypi

#1

Hi I’m building up a retropie barcade and I was hoping to implement a power button like so on the pi:

I was hoping to then get the pi to turn an arduino on or off i.e. Pi is on, arduino is on… pi is off arduino is off.

The arduino runs some lighting for the arcade machine.

I was wondering if anyone had any suggestions on where to begin.

I didn’t want the equivalent of pulling the plug not good for the pi!


#2

How is the Arduino powered at the moment? i.e. where does it get power from.

How much power does the Arduino need? i.e. in watts, or volts and amps.

Lots of ways to do it, but depends a bit on how much power is needed, otherwise risk of getting something way more expensive than it needs to be.


#3

Hi!
It’s an arduino uno (the sparkfun sik kit board) being powered off a powered usb port. It’s only being used to control 2 pots and some neopixels who will be getting their power from another source…

I’m just thinking something obvious… why not plug the arduino in to the pi and when the pi shuts down via the button the arduino will too… hmmm

Thanks quozl


#4

Yes, as long as the current is not too great, just power it from a Raspberry Pi USB socket.

The Raspberry Pi will usually let you know if insufficient power is there.

An Arduino Uno itself isn’t much at all.

As you are powering the Neopixels from another source, they will continue to glow even if the Arduino is powered down. That can be fixed by sending a “go black” message to them first.


#5

That would require the pi to tell the arduino it was powering down right? then we need serial comms between the pi and arduino too?

This seems interesting: https://www.buildxyz.xyz/raspberry-pi-shutdown-via-arduino/


#6

Yes, it would require some form of communication, but it need not be serial. It could be a GPIO output from the Pi as an input to the Arduino. But serial is easier, since the Arduino Uno already has a USB serial interface.

This latest reference you make is to an Arduino Uno that controls power to a Pi. That’s a different way of doing it.

Up to you whether you do the power switch like in your first post today, which means the Pi controls its own power, or have the power controlled by the Arduino and add a power switch as input to the Arduino.


#7

If I used the switch like in the first post could it set a gpio pin high or send serial before shutting down to set the neo pixels lights to black? I’m not too familiar with process but could I have a python daemon on startup and if it detects the button is pressed talk to the arduino then wait x seconds then shut down the pi?


#8

Yes, that’s one way. There’s so many ways.

On most Raspberry Pi operating systems there’s a feature where you can ask it to run your script during a power down but before the power is turned off. You can have that script send serial or set a GPIO pin. Then the Arduino sketch could wait for either the serial data or the GPIO pin and respond by sending a go dark command to the Neopixels.

There’s also a feature that keeps a script running; it starts the script during boot, and stops it during the lead up to power down. If that kind of script was to regularly send serial or toggle a GPIO pin, then the Arduino could wait for the serial data to stop, or the GPIO to stop changing, and respond by sending a go dark command to the Neopixels. That way if the script on the Raspberry Pi fails, the Neopixels will go dark too.

Yet a third way would be to do away with the Arduino and connect the pots and the Neopixels to the Raspberry Pi, but that will require much more work. In particular level shifting the control signal from the 3.3V power domain of the Raspberry Pi to the 5V power domain of the Neopixels.

Hope that helps!


#9

It certainly does!!!thanks so much for all your help!


#10

Hi…i am a new user here. As per my knowledge Raspberry Pi will usually let you know if insufficient power is there.An Arduino Uno itself isn’t much at all.As you are powering the Neopixels from another source, they will continue to glow even if the Arduino is powered down.