Today I’d like to talk about one of the first mods I did to my Wio Terminal (Actually, to my Wio Terminal Battery Chassis). As you probably already know, the chassis doesn’t have an easy way to measure its battery voltage. Because of that, I wasn’t able to check if my battery was charged or not.
The idea is simple, if we check the 40-pin header and the grove connectors from the chassis, we’ll be able to see if any analog pin is not used:
After checking it, I was able to find out that pin A7 wasn’t used, so, this could be our battery sensing input. It’s good that we don’t choose an analog pin that has a grove connector attached to it, so we don’t disrupt the original functionality of the unit.
Another issue is that a common LiPo battery has a voltage range of up to 4.2 volts. This way, we wouldn’t be able to just connect it to A7, as it surpasses the maximum 3.3 volts of the Wio Terminal.
For solving that, we need to create a voltage divider. A voltage divider is a circuit made of two resistors, that make us able to decrease the voltage input by an X factor. This obey the following formula:
As so, choosing two resistors with the same value, we can divide the input voltage by a factor of two. This way, the maximum voltage we would be able to read is 6.6v, making it safe to connect to our battery.
Another thing to consider is the resistor value. High values may decrease accuracy and bandwidth, while the latter shouldn’t be a problem for our case cenario, bad accuracy can be an issue. In the other way, low values will increase the current consumption, which will decrease the capability of holding charge while not being used. I, myself, choose 10k resistors, as these were the ones I had available, but, I would recommend something between 100k and 1M. For me, a lower resistance isn’t that big of an issue, as I’ll be adding an on/off switch.
Here is how I did it:
- Planned circuit change:
- Disassemble the chassis:
- Find where the pins are:
- Solder the resistor (here I used some SMD resistors, you can also use through hole models).
- Attach an wire between our resistor and the VBAT terminal:
- Check if there is any short and if the wire isn’t loose, after that assemble everything and check if it works:
For checking the battery, use pin 7. You should remember to map the value to the correct voltage. Here is a sample code:
uint16_t val = map(analogRead(7), 0, 1023, 0, 6600);
SerialUSB.print(val);
SerialUSB.println(" mV");