OPEnSLab-OSU / Loom

Arduino library for Internet of Things Rapid Prototyping in environmental sensing
GNU General Public License v3.0
26 stars 3 forks source link

Analog Module Measuring Voltage #156

Closed BGoto808 closed 2 years ago

BGoto808 commented 2 years ago

Describe the bug Dendrometer had a 6 week deployment and in their code, they measured the Vbat pin through the Analog module. The values for all of the devices had a battery voltage starting from 4.9V, which physically isn't what we expect. They used a 3.7V LiPo battery which normally reads from 3.7V to 4.2V when fully charged.

Hardware in Use Adafruit Feather M0 LoRa 3.7V LiPo battery Hypnos SHT30 Neopixel AS5311

To Reproduce Upload the Dendrometer node code to the Feather and power it through the LiPo battery

Expected behavior The Vbat pin should read a voltage that's in between 3.7V and 4.2V when fully charged.

Code https://github.com/OPEnSLab-OSU/Dendrometer/blob/v1.1/AS5311_Prototype/Prototype_V1.1/node/node.ino

Config https://github.com/OPEnSLab-OSU/Dendrometer/blob/v1.1/AS5311_Prototype/Prototype_V1.1/node/config.h

Additional context Line 63 and 66 should be commented out in order to test if you don't have all of the sensors.

lukegoertzen commented 2 years ago

Just a cursory observation, but using pin 9 as GPIO (e.g. chip select) can mess with battery readings, as that is also pin A7 (connected to a voltage divider for the lipoly battery - https://learn.adafruit.com/adafruit-feather-m0-basic-proto/pinouts#logic-pins-2824853-8). You might be able to get away with it filling both roles, but have to make sure the pin mode changes correctly before reading and writing from/to it, not positive what impact that might have to the device using it as chip select though. This is also documented on https://github.com/OPEnSLab-OSU/Loom/wiki/Common-Pin-Allocations