Powering off via UI while using a Mausberry Circuit
-
@cyperghost said in Powering off via UI while using a Mausberry Circuit:
ATTENTION! Definate correct GPIOPin!
Are you saying we should adjust the line as it applies to our setup--so if we used pin 23 for the for GPIOpin1 as suggested by Mausberry, the line should be:
sudo echo "1" > /sys/class/gpio/gpio$GPIOpin23/value && sleep 3 #<-- very likely here
-
No!
sudo echo "1" > /sys/class/gpio/gpio23/value && sleep 3
-
@cyperghost Ok, so setting this value really does affect the pin voltage. That's was my hope, fearing that it might just be a script variable.
-
@caver01 You can just test without altering any script. Quit ES and type in terminal the command above. Maybe the sudo command is not needed :) (I doubt it but let us find out)
-
@cyperghost said in Powering off via UI while using a Mausberry Circuit:
No!
sudo echo "1" > /sys/class/gpio/gpio23/value && sleep 3
Hahaha. Gotcha. Ok. I will give this a try later. Thanks so much, and especially for your patience. You were way ahead of me, going straight for the pin itself.
If this works, as I now suspect it will, you just closed the last little loop as I can see with using this circuit on a RetroPie setup. Thanks in advance!
@madmodder123 I hope you are following along and can try this too. I think we were having the same issue (actually, everyone who uses a MB circuit can benefit).
-
@cyperghost said in Powering off via UI while using a Mausberry Circuit:
@caver01 You can just test without altering any script. Quit ES and type in terminal the command above. Maybe the sudo command is not needed :) (I doubt it but let us find out)
Good idea. Consider that my first test. I will report back later.
-
@cyperghost I tried the command at CLI. got an error:
echo: write error: Operation not permitted -
@cyperghost after a little reading I tried something else:
First, I considered the fact that pin 23 is exported and set to input. That may have been preventing me from setting the value, so I tried changing it to output with:
sudo echo "out" > /sys/class/gpio/gpio23/direction
then I tried setting the value to 1 with
sudo echo "1" > /sys/class/gpio/gpio23/value
this immediately triggered the shutdown. However, the LED wired to the mausberry is still lit, the Pi is sleeping but power still on. And in this state, the power switch is non-functional, as if the MB circuit still thinks the Pi is on, like it has not seen a button press.It strikes me that the power button is wired to the MB circuit, not to a GPIO pin. The MB circuit is wired to pins 23 INPUT and 24 output. So, the button tells the circuit to shutdown and the circuit triggers the input on pin 23 which kicks off the script. I honestly don't know what pin 24 is doing. I expect the MB is monitoring this pin, so when the power goes out, it sees that the pin is no longer set to "1", but it appears that the circuit does not bother to look at 24 unless it has received a button press from the wired button.
I am starting to think I need a transistor in this equation, or that the MB circuit is not as versatile as I wish it was. It should detect if the pi is shutdown, not just when the button gets used.
-
@caver01
I See .... That is because the switch is labeled as input.
So there is no chance to with an simple echo AS it expects an input. I will report in a few hours ...
I have a small test circuit available at home. One LED connected with a button. -
@caver01 I was on the wrong track - sorry!
But there is an solution... you need a Solid State Relais like this and connect the output in parallel direction to your switch. So you can use the switch or the SSR...The innput for the SSR is annother GPIO in ouput direction... if you set now echo 1 command in this GPIO direction.. LED inside the relais will glow and switch is closed.
So you have 2 switches ... the physical and one software remoted. I have some of these bought cost 1$ each and work fine.
@caver01 What happens if you change direction to the second GPIO?
-
What happens if you change direction to the second GPIO?
If we change direction on pin 24, I can’t write to it. I tried change the value too and it does nothing.
I think I will look into the relay option. Do I need any other components such as resistors connected anywhere? I don’t think I have ever hooked up a relay before.
-
@caver01 I'll be back ;)
I tried change the value too and it does nothing.
I can't get this... Was there an error message? So can you please test if you change status uf $GPIOpin2 with sudo command
sudo echo "1" > /sys/class/gpio/gpio$GPIOpin2/value
It is setted to 1 what happens if it is setted to 0?I don't get what the purpose. It seems like a check state... for, is the Pie is running!
As the mausberry contains a AVR µc I can't get it why the developer sends voltage output and does not wait for receiving a signal?As you mentioned:
is there a way to force the signal on the GPIO pin itself so that the MB circuit hardware really DOES detect something? This would get picked up by the script too.
and I said:
Maybe you're right and the hardware button does something with the mausberry but as far as I understood the mausberry works with permanent and momentary switches
the mausberry sends a high signal to the Pie..... sadly!
I tested with a switch and LED and I was able to trigger the switch by change input to output direction. But as the MB sends the signal.... it won't work like that.
About the opto-mosfet... yes you will need a resistor to not damage the build in LED. For 3.3 V I used 330 Ohm. But those values are in the data sheet delivered with the IC. I think that will be the nicest way to get the mausberry full working and you need just to plug one more GPIO. And this device acts as a switch... I think the resistance is just 1 Ohm... that's a very bad value for a "switch" but it will surly work.
-
@cyperghost
If I set the gpio2 (actually, it's wired to 24) to "0" it does nothing.That pin gets set to "1" in the script, so it must be for monitoring. When the Pi finishes the soft shutdown, the pin will drop, and the MB circuit should see that, right? But my thinking is that the MB circuit doesn't check GPIO2 for drop to "0" until AFTER it detects a button press. Because, if it DID check all the time, it would immediately cut power before the script gets executed that sets it to "1"!
-
@caver01 Yes this behaviour sounds logical.
Man... it could be so easy but I think the SSR is also a good catch. I use one to activate and deactivate the monitor from LCD by switching on/off the video input via GPIO. So in fact it is just the same approach as to toggle a LED on/off. -
It's hard to blame the design--if all you ever do is use the power button, it's fine. But if you do a soft shutdown without using the button, it seems as though the mausberry has no way to detect that, and it sits in a powered state.
-
@caver01 We will change this via SSR-GPIO software switch ;)
-
What I need is a normally open switch that closes when power gets cut. If I wired that in parallel with the power button, it will trigger when the Pi shuts down without any need for a GPIO command to be sent.
<EDIT> ha ha I just read the first sentence on the link to the SSR. Says it is a normally open switch. . . I may have to pick one up.
-
@caver01 Normally means powered, so indeed it should work ;)
-
@cyperghost
Ok, so I was thinking if we had a component that was OPEN when powered, but closes when the power goes off, we could wire this to a power pin and in parallel with the power button. It would trigger the mausberry like a button press when the Pi goes off. But that would make the circuit think the power button is being held down!So, if you plug in the system, it would power up immediately. Maybe it would even loop.
-
@caver01 But the mausberry works with permanent switches?
But I think the real button won't work anymore ;(So use a GPIO to set event on/off ;)
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.