Automation phat and raspberry pi zero to run solar powered irrigation system

Hello everyone,

First post on here and first project. I bought a solar powered irrigation system from a vendor on a certain popular website, let’s call it ‘Nile’. It arrived from far away and, predictably, worked perfectly for two days before going weird: randomly switching itself off and shouting at me in the voice of an angry, Mandarin speaking dominatrix.

I got the screwdriver out and pretty quickly deduced that it was the little computer board in there that was causing the problems. My boss loves raspberry pi’s so I ended up getting a pi zero, wifi enabled etc. I also got an automation phat and an 8800 battery pack.

My work involves a lot of python coding, so I was not worried about that, but my practical electronics experience is limited and I’m always happy to let someone else put the computer together. Armed with a brand new soldering iron (a more successful purchase from ‘Nile’ ;), I set out and quite literally stuck the two together. Apologies if my soldering is offensive and looks like it was done by someone undergoing alcohol withdrawal, but it was my first go and nothing got hurt or broken:

I was able to ‘salvage’ the pumps, original battery and solar panel. I am aware that I will need a much bigger solar panel for the final version, but I am just wanting to get it working first.

Thanks largely to the guide on the support page, by connecting the panel to ADC1 (analog) and GND, I was able to read a voltage, which varied with light intensity and having connected a pump (from the 5V pin to NormallyOpen, COM to +ve on the pump and -ve on pump to GND), I was able to write a routine to switch the pump on when the light intensity surpasses a value.

So far so good…

But the problems come with the battery. The idea is for the solar panel to provide energy to the battery, which in turn powers the pi (permanently) and the pump (intermittently) and it has left me with a few questions. I’ll try to separate them as best I can:

  1. Connecting the battery: Can the battery be connected to the automation phat in such a way that it can be charged and power the pi (needs to be always so must be during charge too) and power the pumps (pumps can be run only when battery is not charging)??? From Tanya’s Teardown I can see that the outputs, when switched on can deliver up to 500mA, so this could be used to charge the battery (black -ve wire from battery to output)? From the same page, I see that the battery +ve(red wire) could connect to either another analog channel or an input, but I don’t know if this is doable.

Even if it can work and i could write code to turn the output on and off, I don’t know by what measure on the automation phat I would decide that the battery is charged, since the charge graphs for lithium ion batteries show that maximum charge is not reached when the voltage (the only thing i can ‘read’ off the phat, right?) maxes out… If this is not feasible, will I need some kind of extra shim to attach the battery to the pi? That brings me to my next question:

  1. Powering the pi from battery: Up to now I have been powering the pi through a micro usb into my mac, but ultimately it needs to be battery powered. If the set up remains as it is (through a solution to Q1) then the power must come from the automation phat. On there there is a 5V pin and another solder spot for 3.3V. Now I already have the NO side of the relay connected to the 5V pin and … POTENTIALLY DUMB QUESTION: EXHIBIT A I am not even sure whether I can connect two things to one 5V pin? The other option is the 3.3V hole…

Bringing us immediately to… POTENTIALLY DUMB QUESTION: EXHIBIT B I have read that the raspberry pi will work at 3.3V and this would help prolong battery life, but is it possible to still run the pump (3.7V) from the 5V pin on the phat? If I can do that, would the best option be to re-purpose a micro usb cable and just solder the end through the hole in the picture?

I guess I am really asking how best to connect a lithium ion battery pack to a pi zero/automation phat so that it can be charged by a solar panel at the same time as running the pi, and have the charging stop when full. I can write the code, but I need to know the connections! If I can’t do this through my set up as it is, though it pains me greatly to say it, I could remove my ‘impeccable’ soldering and add a something to handle the battery, but could anyone suggest what would be best (by ‘best’ I mean doing the above at minimum power consumption and cost).

Thanks most kindly for reading and any assistance that can be offered. Please, do not be afraid to insult my intelligence, especially when it comes to joining things with wires. :)

Your going to want a battery charger specifically made for LIPO batteries. I’m assuming that a LIPO battery. Bad things will happen if you just feed it 5V, smoke and or fire most likely.
This will charge the battery and give you a boosted 5V out

Its limited to a max of 1 amp out though.
This does basically the same thing but has up to 2.5A out.

Niether one is really meant to be feed from solar though. They want +5V in to run properly.

There is also this that will recharge the battery from solar.

If you go that route, they recommend using one of thier solar panels, which you were going to buy anyway.
You’ll also need a boost converter to get your 5V to run the Pi and automation path.

I wouldn’t recommend trying to run the Pi from the battery directly. It cah reach up to 4.2V when fully charged. Feed that into the Pi’s 3.3V pin and bad things will happen. I’m not sure the Pi will even run off of only 3.3V feed into the GPIO.