low voltage when using I2C comm

Started by loseymark, May 31, 2016, 10:04:06 PM

loseymark

When I use I2C comm from a raspberry PI to a moteino, my moteino registers low voltage, 1.4 to 2.0 volts, no matter how I power the moteino. I've used regular moteinos powered from a 5V 1.5A Raspberry PI power supply, or a 3.7V LIPO battery like is suggested for the Mighty Hat. I've also used a moteino USB powered through the USB adapter or via battery or direct 5V power supply.

I saw somewhere that there is a threshold setting that can be used to get rid of the low power icon, but I don;t want to go this low. Any ideas how I could address this problem?

luisr320

What pins of the Moteino are you using to connect to Pi? Some pins on the Moteino are exclusively dedicated to connect to the radio. I2C should not be a problem, as it is a "bus".

Felix

Quote from: loseymark on May 31, 2016, 10:04:06 PM
my moteino registers low voltage, 1.4 to 2.0 volts,
Can you explain what you mean by that?

loseymark

I'm using A4 - SDA and A5 - SCL plus ground.

"my moteino registers low voltage, 1.4 to 2.0 volts,"

By this I mean the gateway displays a low battery icon and the voltage metric reads in the range 1.4 to 2.0 volts.

I believe the voltage threshold can be set in the sketch and I kept the default of 3.6. The question is what voltage level I should expect to maintain when using a 5V power supply.

Felix

Oh you mean you are using the LPL Gateway? And you have a node for your gateway moteino? And that shows the little battery icon? How did you set that up?

loseymark

I used the weathershield sketch from the mailbox project. I removed all of the weather sensor logic and added my own logic to use I2C communications from a Raspberry PI to the moteino. The PI formulates the metrics values, sends them to the moteino which in turn sends the updated metrics to the gateway.

The sketch uses the standard battery read logic that I have seen in numerous node sketch examples. This has not been touched.

I modified metrics.js to add my own metrics for this node so that the gateway displays proper values for the node.

Is there something specific you are wanting to know beyond this?

Felix

I am trying to get a complete picture. When you said "low voltage when using I2c comm" that suggested something completely different. Ie that somehow i2c causes a low voltage on your pi-moteino.
So your node-moteino is reporting a low voltage.
That has to do entirely on how you read that voltage. Can you give more details about that? What is your voltage monitoring circuit looking like?

loseymark

The only voltage monitoring in place is the gateway metrics and the fact that it displays the low battery power icon. I used the default read battery method in the sketch for that.

I assumed the difference between this node and one of my four weathershield nodes in terms of the voltage level maintained by the metrics on the gateway was the fact that I used I2C.

Would having the I2c connection to the PI affect voltage readings in the read battery method of the sketch?

Felix

No, i2c has nothing to do with voltage monitoring.
What analog pin are you reading for the battery? What is attached to that analog pin?

loseymark

I just have A4, A5, Ground, and VIN pins in use. The sketch calls this routine

void readBattery()
{
  unsigned int readings=0;
 
  //enable battery monitor on WeatherShield (via mosfet controlled by A3)
  pinMode(BATT_MONITOR_EN, OUTPUT);
  digitalWrite(BATT_MONITOR_EN, LOW);

  for (byte i=0; i<5; i++) //take several samples, and average
    readings+=analogRead(BATT_MONITOR);
 
  //disable battery monitor
  pinMode(BATT_MONITOR_EN, INPUT); //highZ mode will allow p-mosfet to be pulled high and disconnect the voltage divider on the weather shield
   
  batteryVolts = BATT_FORMULA(readings / 5.0);
  dtostrf(batteryVolts,3,2, BATstr); //update the BATStr which gets sent every BATT_CYCLES or along with the MOTION message
  if (batteryVolts <= BATT_LOW) BATstr = "LOW";
}

loseymark

Maybe if I restated the problem/question it would help.

Why does the low battery icon appear on my gateway node when I power it directly from a 5V power supply or 3.7 volt LIPO battery?

My weathershield nodes don't show the icon and they are being powered exactly the same way.

One difference is that the node showing the low battery icon uses I2C communications on pins A4, A5 and a common ground with a Raspberry PI.

Felix

I think you are sending a metric that is read from a floating analog pin, that explains why the low voltage.
The WeatherShield has a "battery reading circuit" which is attached to A7 on the Moteino.
Your other "low voltage" node does not seem to have anything like that. Yet you are reading the input voltage the same way, it would of course read an invalid value that is probably very low.
So either:
- remove the battery reading code (also remove the V metric from the UI)
- add the voltage reading circuit (2 resistors, 1 cap) to A7, something like this:


loseymark

Amazing. With zero electronics training I was able to find the resistors and capacitor locally and put a circuit together on a breadboard that solved the problem. I had to use 2%

Now I can repeat that for my other moteinos.