Tuesday, July 10, 2018

Bluetooth Battery Monitor Using WICED Board

My electric skateboard so far has been great. The performance and battery life is better than I originally expected. However, there is one issue that bothers me: checking the battery voltage quickly. Right now, I have to take out a multimeter, open the enclosure on the bottom of the board, and measure the voltage. To solve this problem, I thought of making a Bluetooth-based battery monitor. I recently got an internship at a company in Silicon Valley called Cypress Semiconductors. One of their specialties is in WiFi and Bluetooth chips for devices such as game consoles, phones, smart home appliances and much more. They make Raspberry Pi-like boards aimed to help developers that can be programmed using a custom SDK. The particular board that I used is part of their WICED line of devices, and is called the BCM94343W_AVN. This product line focuses on connectivity, mainly Wi-Fi and Bluetooth. My particular board includes both Bluetooth Low Energy and WiFi, and is normally used for IOT (Internet of Things) applications. As the first main project for my internship, I decided to use this board to make a Bluetooth voltage monitor for my skateboard. I envisioned somehow measuring the skateboard battery voltage and sending that data to app on my phone so I could easily monitor the voltage. First, I focused on measuring the voltage. After some research, I found a feature built into the board that was called ADC, which allows any power source up to 3.3V to be connected to the board via the GPIO pins and measured. I found some code for the ADC online that worked with an Arduino board, so I changed the code a bit to work with my board and tested it with a AA battery (max of 1.5V). The problem was that the battery in the skateboard has a much higher voltage, around 12.5V fully charged. So I did some research and found out that there was something that could solve my problem known as a voltage divider circuit. Basically, two resistors, one higher impedance than the other, are used to bring down the voltage of a source to a manageable level. Then, you do some calculations to find out how much the voltage was divided by the resistors and use that data in your code to find the actual voltage of the source. I used a voltage divider calculator online to do my calculations. My skateboard is made up of two 3s batteries, each having a max voltage of around 12.5V when fully charged, and I only wanted to measure one of the batteries. In the voltage divider calculator, I used 13V as my input voltage to be on the safe side, and 3.3V as my output voltage, as that is what the max ADC voltage of the board was. There are no specific values to the impedance of the resistors that you need to use in a voltage divider circuit, but I settled on an 18K and 4.7K resistor, as that is what I could find in the company workshop. Next, I wrote some code to factor in the voltage divider circuit and everything worked properly. Finally, I had to find a way to send this voltage to my phone. Fortunately for me, Cypress makes an app that is designed for testing these Bluetooth boards. They also provide starter code that is compatible with this app. Once I modified their starter code a bit by adding my voltage measurer code and doing some small fixes, I was able to receive the battery voltage on my phone through the Cypress-made app. I put the board into the enclosure on the skateboard and did some soldering and tidying up with all the wires. The board, which needs 5V 2A for power, is powered by the skateboard batteries through a LiPo to USB converter that I bought online. However, there are still a few issues. For some reason, I couldn't get the Cypress app to display the voltage in a decimal format, so for example, 12.5 volts shows up as 125. Secondly, the voltage doesn't update as you ride unless you restart the whole system. In the end, it probably would've been easier to use an Arduino, but this project helped me get familiar with the WICED system and SDK. Click this to see my the voltage measuring code.

No comments:

Post a Comment