Picaxe Pi power control

julianE

Senior Member
Hello,

I'd like to setup a remote raspberry pi picaxe combination, all battery powered. The raspberry pi zero wireless would be used to program the picaxe and to collect data from picaxe. I'd like to have everything run on a single LiPo cell with a 3.3V LDO regulator. To conserve power pi would be powered off most of the time, done through the WiFi with the sudo poweroff command. To bring the pi power back on I'd like to use a picaxe with a 315 Mhz radio link. What would be the best way to power it on? I tried a power NPN transistor and the voltage loss is around .5V so that might be too much, maybe place the 3.3V regulator after the transistor.. I think the best solution would be a latching relay but I'm open to suggestions. Perhaps a mosfet that works at lower voltages, I've only used 5 volt mosfets and am not aware of lower voltage types. I looked at the pi GPIO pins and don't see any enable pins or way to power up using logic levels.
 

AllyCat

Senior Member
Hi,

We may need a circuit diagram for the complete arrangement, but normally you would use a PNP as a high side switch. Probably before the regulator because "LDO" is not necessarily the same as "Low Quiescent Current" (there's a slightly relevant current thread, from about #12 onwards).

There have also been some recent threads on bistable (latching) relays.

EDIT: If you want to program the PICaxe from the Pi, then you may not have any option but a bistable relay (or similar) because the PICaxe won't be able to hold on the power whilst it's being programmed.

Cheers, Alan.
 
Last edited:

hippy

Technical Support
Staff member
A block diagram of what you envisage and how things connect and interact may help. I can't tell if you have a Pi plus PICAXE together or separate, what's controlling what.

I'm not clear on what power you are switching; if to the Pi as it seems, that would normally require 5V.

I'm also no clear on how the Pi would program the PICAXE wirelessly.
 

julianE

Senior Member
I'm sorry for a confusing post. My project will have multiple picaxes and a single raspberry pi. the pi controlling picaxe will only cycle the power to the pi. I have that piece working using a latching relay,
http://www.weclonline.com/downloads/pdf/07-01-4005.pdf
I have the model number AL5WN-K which needs 3.75V to latch the relay so I had to switch to 5V supply for the 08M2. With the parts I have on hand it looks like I will have to go with a 5 volt supply and also a 3.3V, the 3.3V will power the pi and second picaxe and the relay will be switching the power to the pi.

Raspberry pi zero will be programming a different picaxe. As of now I will have 2 picaxes and a single pi. The way I will program a picaxe is using this thread,

http://www.picaxeforum.co.uk/showthread.php?22547-ARM-binaries-for-command-line-compilers

I also have that piece working.

I may end up using 4 AA NiMh batteries and 2 LDO regulators and a solar cell charger. Please forgive me for posting a half cooked question, I'll do better in the future and will learn to draw block diagrams.
 

Jeremy Harris

Senior Member
I thought Raspberry Pi was a 5v device?
They are, definitely. I have a couple of RPi3's, a few Pi Zero's and a Pi Zero W. All will crash on boot if the power dips below about 4.5V, even for a few tens of ms. It's a nuisance, as the peak current drawn during boot ends up being the thing that determines the power supply capacity, as when up and running (as long as there are no power-hungry USB devices connected) all the Raspberry Pi's seem to be happy on a supply with a much lower current capacity.

Having said that, all the Raspberry Pi's run on 3.3 V internally, so if you ignore the USB port(s) and bypass the onboard regulator you could probably run one on 3.3V. It would be a bit iffy though, as the on board regulator provides some protection to the system on a chip itself.
 

hippy

Technical Support
Staff member
The Raspberry Pi Foundation will not release full circuit diagrams of their recent products nor electrical and full datasheets for their processor chips so it is difficult to know exactly what the requirements are.

In normal use the boards are powered from 5V and various on-board regulators are used to provide the 3V3, 2V5 and 1V8 power rails the processor needs. The later two supplied by the 3V3 rail.

Earlier circuit diagrams of boards using the same processor as used in the Pi Zero range show the 5V input supply going direct to the processor. It is not clear if this is the case for the Pi Zero range, why this is 5V or what the consequences actually are if connected to anything other than 5V.

Despite that, it does appear that it is possible to power Pi boards from 3V3 providing the 5V and 3V3 supplies are connected together, and some people have done that.

The full consequences of doing that are not clear though obviously the Vusb USB supply voltages will no longer be 5V, any voltage low detection will be permanently activated, and, as already the case, the board must not be connected to any PC, USB device or hub which can put a voltage into the Pi. Doing that may damage the PC, USB device, hub or Pi.

Likewise the Pi should not be connected to any HDMI or DVI screen as that interface also passes 5V which would conflict with the 3V3 the Pi would be using. Doing that could damage the TV or monitor and Pi.

Obviously care must also be taken to ensure that the Pi GPIO pins are not connected to anything sourcing over 3V3.

The Pi Zero is said to draw up to 350mA and the Pi Zero W will draw more when WiFi or Bluetooth is enabled or other devices are connected. Any power supply or switching of that has to be able to handle that and any in-rush current there may be.

Finally, care must be taken when powering down the Pi as just killing power or allowing power to fail or go too low can corrupt SD Cards or permanently damage them.

So it seems a Pi can be used with a 3V3 supply providing the consequences of doing that are taken into account.

The hard part would seem to be in interfacing it to anything else to allow program development or access to it while powered from 3V3. Having a separate Pi for development and moving the SD Card between the two or headless development over WiFi would be the best solutions.

Rather than providing a 3V3 supply and connecting 5V and 3V3 together; as long as the supply has enough headroom to drive the 3V3 regulator, that voltage could be applied to the 5V input, even if less than 5V. That may simplify some configurations though the same precautions would apply as for supplying 3V3.
 
Last edited:

SteveDee

Senior Member
...I'd like to have everything run on a single LiPo cell with a 3.3V LDO regulator...
Check out this thread: https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=59474

The second from last post (at time of writing) seems to suggest that you can run a Pi3 by simply connecting 3.3V to the 3.3V side of the regulator. I'd be interested to know if this really works. It may also have an impact on wifi strength.

...To conserve power pi would be powered off most of the time, done through the WiFi with the sudo poweroff command...
The poweroff command does not power-off the Pi, it just halts the processor, so the Pi will continue to draw current (sorry if you already know this, I'm just trying to interpret your intentions from what you have written).

To bring the pi power back on I'd like to use a picaxe with a 315 Mhz radio link...
The 315MHz receiver will also add complexity and draw power. Could you just run the Pi at set times during the day/week (e.g. run Pi for x mins every y hours to download current data?)

...What would be the best way to power it on?
I plan to build a time-lapse camera using a Pi and Picaxe (I drafted out some ideas early this year, but have yet to make a start!). My plan was to use the Picaxe to turn on the Pi, the Pi would boot and take a single photo then shutdown, and the Picaxe would remove the power from the Pi after (say) 2mins. Repeat (say) twice per hour. Therefore Pi power drain would only be 2 x 2 x 24 = 96min or approx 1hr 36m per day. I have a ZeroLipo board which seems to solve the power problem and how to control it, but I need to find some time to properly test this out.

ZeroLipo.JPG

How do you plan to use the Pi>Picaxe programming feature? Is it acceptable to have manual intervention (e.g. fit/remove a link) or is the system to be "untouchable" after it is deployed?
 

hippy

Technical Support
Staff member
The second from last post (at time of writing) seems to suggest that you can run a Pi3 by simply connecting 3.3V to the 3.3V side of the regulator.
Note though that an earlier post by a forum moderator says doing that will cause damage. But it's also true, as a subsequent post notes that things have changed over time, so it's not clear what the situation is. Different boards have different circuits and power supply arrangements.

It is possible to provide power to a regulator and not its input - that can be done with the AXE091 and I believe other PICAXE boards - but it perhaps depend on the regulator used.

Reports that something 'works perfectly' usually rest upon things seeming to work with 'no observable damage seen'. That does not necessarily mean everything is perfect or damage has not been done or is being caused.

Only the Foundation and its engineers could provide definitive answers but, as its outside normal intended use, it seems unlikely that they would.

It seems the only pragmatic course if prepared to risk it is to try it, see what happens. As noted, others have reported they have had what they consider success.

It may also have an impact on wifi strength.
I don't think that will be the case as my understanding is that the WiFi is normally powered from 3V3 anyway.
 

Jeremy Harris

Senior Member
I'm pretty sure that the WiFi will be fine, as it runs on 3.3V internally on the RPi3 and RPi Zero W. Even the USB WiFi dongle I took apart ran on 3.3V internally, with a voltage regulator to drop the 5V USB supply.

I can confirm that when powered off via software (i.e. just using the poweroff command) the power reduction isn't that great, as all the stuff on the board is still powered on.

Raspberry Pi's are great, but their power consumption can be a bit of a problem for a battery powered project. I spent ages trying to get a RPi Zero W to run on as low a power as possible, for a battery powered WiFi project, and gave up in the end. I think that very low power consumption wasn't that high on the feature list for any of the RPi models, which is fair enough as they are aimed fairly and squarely at the educational environment, where this may well not be a significant consideration.

My solution was to use a pair of Picaxes, together with HC-12 transceivers, for the wireless link, with the battery powered end having a Picaxe 08M2 turning the power on to the HC-12 whenever data needed to be transmitted. I then used a RPi Zero as the web server at the receive end, with the RPi Zero, 08M2 and HC-12 powered via 5V fed down the spare pairs in an Ethernet cable, with a modified USB to Ethernet adapter to connect to the RPi Zero. All the 08M2 does at the receive end is data control; it listens for serial data over the HC-12 link, does some handshaking to tell the transmit end that all is OK, and then sends that data, plus some added stuff, to the RPi Zero UART pins. This was a cheap way of doing things, even though the RPi Zero is very much under utilised.
 

julianE

Senior Member
I powered the zero w by just connecting 3.3 V to the 3.3 V pins on the gpio connector. The pi zero w sells for $10 I will not cry a river if it goes poof. I will take the advice of removing power to the pi after sudo power off.
I have used the cheap cell phone chargers, the ones with a single lipo inside and an up converter, they last surprisingly long on a pi3.
 

julianE

Senior Member
I plan to build a time-lapse camera using a Pi and Picaxe (I drafted out some ideas early this year, but have yet to make a start!). My plan was to use the Picaxe to turn on the Pi, the Pi would boot and take a single photo then shutdown, and the Picaxe would remove the power from the Pi after (say) 2mins. Repeat (say) twice per hour. Therefore Pi power drain would only be 2 x 2 x 24 = 96min or approx 1hr 36m per day. I have a ZeroLipo board which seems to solve the power problem and how to control it, but I need to find some time to properly test this out.
Thanks for pointing out the ZeroLipo board, it's an excellent solution.
 

julianE

Senior Member
Read some information on resetting a pi, there are two pins labeled RUN if they are shorted the pi will reset or if it's been sudo poweroff it will boot up. Would think that a picaxe can provide a signal to activate the pins if all else fails a 4066 chip can be used as a switch but fairly sure just grounding a pin may do it. Will try the RUN pads method and report back.

here is a link explaining it,
https://raspberrypi.stackexchange.com/questions/29339/what-are-the-run-pin-holes-on-raspberry-pi-2
it's for pi2 but i found the same pins on pi zero w as well.
 

hippy

Technical Support
Staff member
The Pi RUN (Reset) pins are not much use in power control applications other than to ensure the Pi is held in reset until after power is applied.

Holding the SoC in reset may reduce its power consumption but it and the rest of the circuit will still be drawing power.

RUN is just like a reset button on those PICAXE devices which have them; a brutal 'stop dead and restart' function. One does not want to reset or forcibly restart a Pi when it is running because that will eventually corrupt the SD Card. There is no need for an external reset when power is applied because that is implicit in power coming on.

Its main useful functionality is that, after a 'shutdown', it can be used to restart a Pi without having to cycle the power.
 

SteveDee

Senior Member
I powered the zero w by just connecting 3.3 V to the 3.3 V pins on the gpio connector. The pi zero w sells for $10 I will not cry a river if it goes poof...
Good for you.

Its always difficult posting comments or advice on internet forums, because you don't know who you are 'talking' to. For some people there is nothing better than pushing-the-envelope for electronic components, while for others, $10 is still a lot of money. So the destruction of a Picaxe chip or Pi computer board may be seen by some (me included) as a valuable educational experience, while to others it may be considered a tragedy.

I've gone against best advice on many occasions and also used my soldering iron to experiment on several of my Pi boards (I think I currently have 16 or 17) and so far haven't broken any. So here is another suggestion, but its just between me, you & other like-minded hackers; if you need to just disconnect power to your Pi in your current project, just try it. Best advice says don't do it, but in my experience SD card corruption is quite rare unless you are writing to the card when the power is switched off.

Now I know people will say that just because YOU are not writing to the sd, it doesn't mean another process is not performing a write operation. However, I currently have 5 Pi computer systems which operate as media players. None have gui enabled, they all auto-run a command-line program. None have a safe way to be shut down, so the power is simply switched off. 3 of the 5 are switched on & off every day, and none have suffered corruption in over 18 months of operation. That is a somewhat better result than can simply be attributed to luck.
 

julianE

Senior Member
Glad you understand SteveDee, I'm hesitant to post at all out of respect to all the good people on the picaxe forum, last thing I want to do is spoil a good thing.

I spent many hours getting pi zero w/picaxe combo working. Ran into issue from something I expected to be zero effort, the wireless connectivity using cheap 315MHz modules. I have a number of receivers that work on 3.3V, I've made many projects where I had no issues, not this time, it maybe something as simple as the new batch of sockets I'm using, I prefer socketing everything but they are loose and when I push on the module it starts working but I'm also having range issues. I'll eventually solve it.

As far as the PI RUN pin, as Hippy pointed out it's only good for booting the pi after sudo poweroff. I'm not sure about the results others are getting but the current draw i'm reading is miniscule after issuing the poweroff command. Since I power the pi and picaxe from the same power supply all that needs doing is to momentarily bring the picaxe pin low and idle it high. A 20ms low on the RUN pin wakes the pi and in no time I can putty into it. Once done with the pi sudo poweroff and the battery draw goes way down.
BTW, ended up adding about 1500uF of capacitance after the regulator, with less the pi never fully boots. I'm using an HT7333 regulator with a 18650 single cell LiPo. I've also tried it with 3 NiMh cells, AAA size. Either battery will bring the pi up, of course the LiPo will have a longer run time.
I've programmed a picaxe remotely with this setup using SteveDee's instructions.

Any suggestions for a block diagram drawing program, would be easier to draw everything out. Right now it's just two picaxes and a pi. I'm using a 20M2 as the picaxe hooked up for programming from the pi, any information from the picaxe will come back to the pi via programming pins, just a sertxd from the pi. Plan is to attach all sort of sensors to the 20M2 and just sertxd it to pi. The second picaxe,14M2 is just there to receive a signal over the 315Mhz modules and once the proper command is received it brings the run pin on pi low to boot the pi. Pretty simple. I have enough room on the board to add some 24LC256 memory and maybe an RTC.
 

hippy

Technical Support
Staff member
I'm not sure about the results others are getting but the current draw i'm reading is miniscule after issuing the poweroff command.
That is interesting because other users of the Pi Zero report anything from 25mA up to 80mA when shut down ( 200mA for a Pi3B ).

A great deal may depend on the equipment being used to measure current and a lot seem to be relying on cheap USB power monitors bought from eBay and probably without any calibration having been done.

Unfortunately I could not find any official shut down figures. That there are power management solutions available suggests it's high enough for those to be needed.

Any suggestions for a block diagram drawing program
ASCII Art is one suggestion but that does take a bit of practice to get up to speed and discover what looks good.

Any paint program should be usable but the easiest option is often to draw on paper using a thick marker and take a photo with a mobile phone.
 

Jeremy Harris

Senior Member
That is interesting because other users of the Pi Zero report anything from 25mA up to 80mA when shut down ( 200mA for a Pi3B ).
I've just measured one of my Pi Zeros and when shutdown, but powered on, it was drawing 62mA. That was measured with a Fluke multimeter that is generally pretty reliable, even though it's a bit old now.
 

julianE

Senior Member
A great deal may depend on the equipment being used to measure current and a lot seem to be relying on cheap USB power monitors bought from eBay and probably without any calibration having been done.
Hippy, you are absolutely right, I did rely on cheap USB power monitors. Brought out the fluke and my figure is close to Jeremy's, 42.5 mA. My Fluke is an older vintage too, been a long while since it was calibrated. The 20mA difference between our reading falls within the range you mentioned people reporting. The other difference might be that I'm measuring with 3.3V going to the GPIO pins 1 and 9 (3.3V and Ground) not through the USB port.

For now, I can accept the current draw but it certainly needs a better solution. I have tried latching relays something like this post,
http://www.picaxeforum.co.uk/showthread.php?10024-5V-Latching-Relays
needs 5V and I could not get the example with a single picaxe pin control to work and the 2 pin control where the voltage is reversed works but causes the picaxe to reset due to lack of freewheeling diodes which I don't know how to place on a circuit that reverses voltage.

SteveDee suggestion of Zero LiPO,

https://www.adafruit.com/product/3196

is the most elegant.

the easiest option is often to draw on paper using a thick marker and take a photo with a mobile phone
I have used that option before, works well and has charm, like a handwritten letter.

Thanks Jeremy for taking the effort to measure the current draw.

All the best.
 

hippy

Technical Support
Staff member
I have tried latching relays something like this post,
http://www.picaxeforum.co.uk/showthread.php?10024-5V-Latching-Relays
needs 5V and I could not get the example with a single picaxe pin control to work and the 2 pin control where the voltage is reversed works but causes the picaxe to reset due to lack of freewheeling diodes which I don't know how to place on a circuit that reverses voltage.
I haven't studied that thread but one option might be to use an L293D or similar as a H-bridge driver for reversing the relay coil current, or just go for a latching relay which has two coils and traditional transistor low-side drives.

Ignoring any RUN connection; the PICAXE and PI will be entirely separate, except perhaps for a common 0V, so it should be okay to run the PICAXE side and relays from 5V and the Pi at 3V3.
 

slimplynth

Senior Member
I powered the zero w by just connecting 3.3 V to the 3.3 V pins on the gpio connector. The pi zero w sells for $10 I will not cry a river if it goes poof. I will take the advice of removing power to the pi after sudo power off.
I have used the cheap cell phone chargers, the ones with a single lipo inside and an up converter, they last surprisingly long on a pi3.
Old thread but (happy new year) - I would do the same as Julian; I set up an rpi2 with the IR cam and even on a 15 month old.. 10,000mA - Ravpower Bank.

It was alive for a good few hours of messing around with.. the 2.4A USB on the power bank stopped working about 6 months ago but the pi seems fine on the 2.1A.. was very happy with the thought of it as part of a solar robot idea I'm 'trying' to 3d print.
 
Top