Author Topic: rPi - what else is needed?  (Read 2863 times)

johnny2678

  • NewMember
  • *
  • Posts: 4
rPi - what else is needed?
« on: April 09, 2018, 04:03:04 PM »
I've got the mote w/radio, mightyboost, and a 2000mAh battery.  Everything is soldered and the sample sketch loaded ok.

What do I need to do to wire this to the Pi?  Obviously the USB to power the pi.  The pinout mention the "battery monitor is on A7: 10K+4.7K divider from the Input". 

Sorry for the noobish question, but what does this mean in laymans terms ;)  I know enough to know that 10K and 4.7K are resistors, right?  How does that come into play?

Does that mean I can connect to A7 to a GPIO pin on the Pi and read the battery voltage and issue shutdown commands based on the readings?

Has anyone done this with python and have any code to share?  TIA


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6867
  • Country: us
    • LowPowerLab
Re: rPi - what else is needed?
« Reply #1 on: April 10, 2018, 09:41:53 AM »
This was designed to control power to a load (Pi or whatever 5V load).
So it's the responsibility of the Moteino to determine that. Moteino runs at 3.3v. The battery can be up to 4.2v (LiPo). So to read that voltage, we use a voltage divier with a certain ratio. A7 is the result of that divided voltage. Knowing the resistor values/ratio, we can determine the actual voltage of the battery by some reverse math. I have shown this in many examples in the RFM69 library. To note that different products use different resistors for this. More recently I have used 1+2MEG. But anyway the concept is the same. This topic of battery V reading a voltage that is higher than the VCC has been discussed in the forum many times, including some illustrations and more explanation etc.
The MightyBoost and MightyHat sketches in the RFM69 library also illustrate how to monitor the voltage and perhaps control the 5V* output from these boards to the load.

johnny2678

  • NewMember
  • *
  • Posts: 4
Re: rPi - what else is needed?
« Reply #2 on: April 10, 2018, 02:01:46 PM »
This was designed to control power to a load (Pi or whatever 5V load).
So it's the responsibility of the Moteino to determine that. Moteino runs at 3.3v. The battery can be up to 4.2v (LiPo). So to read that voltage, we use a voltage divier with a certain ratio. A7 is the result of that divided voltage. Knowing the resistor values/ratio, we can determine the actual voltage of the battery by some reverse math. I have shown this in many examples in the RFM69 library. To note that different products use different resistors for this. More recently I have used 1+2MEG. But anyway the concept is the same. This topic of battery V reading a voltage that is higher than the VCC has been discussed in the forum many times, including some illustrations and more explanation etc.
The MightyBoost and MightyHat sketches in the RFM69 library also illustrate how to monitor the voltage and perhaps control the 5V* output from these boards to the load.

Ok, I understood... *most* of that  ;D

Getting everything soldered correctly was a big win for me, but I'm still learning. 

Quote
perhaps control the 5V* output from these boards to the load.

Is there something I need to add to the sample sketch to enable the 5V output via the included USB-A port?

Right now when I plug in a micro USB to the 5v-in, the moteino powers on, the power/charge LEDs are liton the MightyBoost, but the rPi connected to the USB doesn't get any power.

From the sample sketch:
Code: [Select]
#define OUTPUT_5V           4     // HIGH on this pin will switch the "5V*" output ON

Sounds like I need to do this to turn 5V output on?
Am I on the right track?  If so, it's not clear to me from the code how to set D4 to 'HIGH'

johnny2678

  • NewMember
  • *
  • Posts: 4
Re: rPi - what else is needed?
« Reply #3 on: April 10, 2018, 04:19:48 PM »
Answering my own question.

Solution was to change line 88 from LOW to HIGH.  Pi is now getting power via 5V and continues from battery when input power is pulled.

OR, just short the shutoff BTN - flips D4 to HIGH - no code change required  8)

The learning continues...

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6867
  • Country: us
    • LowPowerLab
Re: rPi - what else is needed?
« Reply #4 on: April 11, 2018, 06:29:54 PM »
You can turn D4 HIGH: digitalWrite(4, HIGH)
Or there is a jumper on the bottom that you can solder short, does the same thing but it will force output ON always.