Bluetooth DC energy monitor

flangefrog

1 kW
Joined
Jun 26, 2013
Messages
379
Location
Auckland, New Zealand
Hi All. It's been a while.

Some may remember a BMS project I was working on when I was last active here. I was also working on a concept of a simpler project which shared some of the key components. I decided I should focus on the simpler project and once I finished that I could apply what I learned to the BMS or other projects. For various reasons I haven't' been able to do much work on any of these projects until now but I have continued researching/learning and refining the ideas.

I've recently started working on that simpler project again which is an Open Source Bluetooth DC energy monitor. Basically an upgrade to the Watts Up or GT Power meters. I've used the latter for several years and while they're useful there is a lot that could be improved - I.e. my first one is dead. Often it is tucked deep inside a frame bag which is why bluetooth would be useful to me.

I learned to use KiCad last week which was much easier than expected - I found the interface very intuitive. My current draft PCB (the first I've ever designed) is below. There are still some more components to add and some to change such as the nRF52 module (I need more GPIO).

FW8gtsG.png


Here is a real life mock up of what the bare device could look like. I'm looking at making a proper case for it. References are ISDT UC1 or ISDT BG-Linker but the case will probably need to be plastic.



I made a proof of concept a while ago using an INA226, nRF52 DK running Apache Mynewt and a web bluetooth app which could run on a phone or PC.

I've also made another energy monitor (hacked together overnight with the AC monitoring added later) using the INA226 and WSL4026 shunt (same as WSL2726 in 3d render but with leads turned out) as well as AC voltage and current monitoring using a standard and current transformer for a cycle powered cinema I was helping out with.



Video of the above working including coulomb counter

Back to the DC energy monitor...

What makes it different
  • Bidirectional current sensing
  • Reverse voltage protection
  • Bluetooth connection
  • Logging/saving measurements
  • High voltage support
  • High accuracy
  • Open Source
  • Low power consumption
  • Waterproof

Product Requirements

Must have
  • Support 9-60VDC
  • Measure up to 25A continuous, 50A peak
  • 1% accuracy
  • 100mA precision / accuracy at low range
  • 0.1V accuracy at 9V
  • Bidirectional current sensing
  • Support BLE
  • Companion app for phones
  • Support logging
  • Easy to use and open-source friendly SOC and peripherals
  • Low power consumption
  • Small size
  • Water resistant
  • Multiple connector options through adapters
  • Survive reverse connection

High want
  • Support 6-102VDC
  • Measure 50A continuous, 100A peak
  • <0.1% voltage accuracy
  • <0.5% current accuracy
  • 10-20mA precision / accuracy at low range
  • Web bluetooth app for phones and PCs
  • Extremely low standby power consumption (leave on battery for a year)
  • Low cost
  • Waterproof
  • Lightweight
  • Graphic display support
  • Amass XT series connector

Nice to have
  • Support 3-120VDC
  • Piezo buzzer
  • <0.1% current accuracy
  • 0.001V precision
  • Memory to store more log data
  • Stay on for a while when power drops out
  • Auxiliary connector for I2C/ADC etc
  • Survive continuous overvoltage

I think that that <0.1% voltage accuracy and <0.5% current accuracy specs will be very achievable with some calibration and compensation for the current measurements. I'm currently waiting on some display samples to arrive but the new 0.96" 160*80 IPS TFT displays are looking very promising and are almost pin compatible with a similar OLED display. Even with a display the BOM cost is looking reasonable. A case would probably add a bit though.

I'm about to enter into early stage discussions with a contract manufacturer and EMC testing facility so I can get all the DFM stuff right from the start. I want to get a working prototype as soon as possible but I'm thinking I should probably wait to talk to the EMC testing place before I decide on the new nRF52 module as I'd prefer not to have to swap it out again.

The current design has a 2x06 2.54mm pitch female header on it which is probably where the display will be mounted (it could be optional). The header could also be used to connect other sensors or I2C/SPI devices.

A couple of questions I have:
  • What are your overall impressions? Would you find this useful?
  • Do you care about having a case? Either way it would be potted (or at least conformally coated) but it would make it more rugged and slightly larger.
  • Is a standard display (in addition to bluetooth support) something that people want?
  • Is an external connector important? E.g. some people may want to add a temp or RPM sensor etc. It's something that could compromise the water resistance a bit.
  • Would anybody here actually use this above 60V?
 
I think 50A continuous will be no problem provided you can currently use an XT60 without melting it. Technically XT60 connectors are only rated at 30A continuous, 60 peak but they are usually sold as 60A continuous. Ezee use MT60s on most of their new hub motors which use up to 80A phase current (but maybe it's 80A/3 per terminal). I don't know of a single Ezee bike in New Zealand that's ever had one of those fail.

The shunts are available down to 0.2mΩ but it wouldn't be necessary to go that low. I've designed the board so there will be a big manual solder bridge from the connectors to the shunt. The jumper on the other side will probably be beefed up and will also have a lot of solder.

The limiting factor for the voltage is currently the power dissipation of the linear regulator when the TFT display is on. This would probably not be an issue with an OLED. I'm thinking this could be managed (or simply don't use a display above 60V) but I'm also looking into using a buck converter. There is also the issue of trace clearance (current design should be compatible with IPC2221B) and maybe lack of isolation of the external connector. I also need to investigate any safety certifications that may be required for higher voltages.
 
Pretty neat project! I remember trying to find "smart" power meters for my ebike but they all seemed pretty expensive. I recently completed a similar project where I found power consumption by communicating with a JBD BMS. While the BMS interface side may not be relevant to you, I did create an LCD display to output data. It may be cool to make an LCD display so don't need to pull out your phone/mount it on the handlebars when riding. Anyways, here's the GitHub repository for that project.
 
I had a quick chat to the EMC test lab today. The tech guy wasn't in but they indicated the costs for certification would likely be much lower than what I was expecting. They're not far away from me which is good. I'll try to set up a meeting when the tech guy is back.

fordtheriver said:
Pretty neat project! I remember trying to find "smart" power meters for my ebike but they all seemed pretty expensive. I recently completed a similar project where I found power consumption by communicating with a JBD BMS. While the BMS interface side may not be relevant to you, I did create an LCD display to output data. It may be cool to make an LCD display so don't need to pull out your phone/mount it on the handlebars when riding. Anyways, here's the GitHub repository for that project.

I'd like this to be cheap but I think that if this project becomes successful there are companies in china who could reproduce the design and produce it much more cheaply than I ever could. I wouldn't have a problem with that. Instead I want to produce it locally and focus on the quality and calibration. Even still I am aiming around $50 NZD for a direct sales price. That's including 50% gross margin and local shipping. It will be interesting to find out what the contract manufacturer will charge and how much they can save me on the BOM. I've been working off a $5 NZD per unit PCBA cost estimate.

I've considered remote displays like that but I think a semi-permanently installed display is better left to a BMS related project like yours or a cycle analyst. Personally I always have my phone mounted on the stem when riding. Of course a remote display would be relatively easy for someone to add, whether by implementing a bluetooth host on the display or simply extending the SPI/I2C bus from the meter. Good work on your display, It's good to see more info and code for those BMSs around.

Something I forgot to mention is that the current design allows for a common 0.96" 128x64 OLED module (available everywhere on eBay or AliExpress) to be plugged directly into female header. The new displays I'm looking at have exactly the same viewable area but with a different panel layout for a more streamlined design when mounted on a custom PCB. The smaller one in this video is the IPS TFT I'm considering: https://www.youtube.com/watch?v=PUV9_OdMcCA
 
Grantmac said:
Can you base it around XT90s for those of us running higher power? For that price I'd happily test for you.

I've considered that but I think the market for XT60s will be bigger, especially outside of the ebike field. Unfortunately with certification costs of $1k to $10k+ it's not really viable to sell other models. I'd be happy to design an XT90 derivative for others to build though. I think it would be better to use this model but solder on 10AWG wires with XT90 connectors similar to how the GT Power meter is designed. This will provide better heat sinking to the shunt although it would invalidate the calibration.
 
A bare wire version might work, doing a complete build is beyond me.

Really XT60s should work for almost any Ebike/Eskate/Scooter since few are sustaining more than 60a and they can do ~100 in bursts.
 
This is how I'm thinking of mounting a display. Might be better if the FPC is on top of the board though instead of underneath. Probably I wouldn't add the button as it could compromise the water resistance, reliability and make a case design harder. The TFT display has a single built in touch pad (not a gridded touch screen) that could be used to switch views or reset measurements.\

p6nY9id.png


Edit: after some more communication with one of the LCD module manufacturers, most modules don't come with a touchscreen. They do however have two touchscreen inputs (plus ground) half way up the FPC for connecting a touchscreen. That's just to make it easier than connecting the touchscreen separately to the PCB. I think this should allow for two seperate touch areas. One manufacturer did have some modules with a touchscreen already included under development.

A touchscreen like this would be nice as it should allow touching the left or right of the screen, or swiping left-right or right-left. I think it would only need two connections plus ground.

e3Lwsov.png

Source: Silicon Labs AN0040

I'll be revisiting the touch screen possibility later on when I'm looking at the enclosure design.
 
I've been working on finalising the schematic and component placement for the prototype. Besides the RF module choice (I've been communicating with several suppliers) the main thing remaining is the reverse protection.

Can anyone more knowledgeable than me comment on this reverse protection circuit? I've done some simulation and it seems to work fine. D3 is just to quickly switch off the gate on a fast reverse transient. Seeing as the reverse protection is mainly to stop the device being destroyed when plugged in backwards I think I could probably leave this out.

54YhX2a.png
 
Here's my (not so) shortlist for the RF modules. Narrowed down from pretty much every nRF52832/40 module available. Aparrently there will be new modules coming out based on nRF52833 later this year but I'm not waiting for those.
https://docs.google.com/spreadsheets/d/1jpMkvUb8zNvMu7qHBSZdNHMILwkR7YVSrGhYouuh_gA/edit?usp=sharing
 
I received the display I'm planning to use today. It looks a lot sharper in real life. I've also finally got answers for most of the RF certification questions I had. Installing Apache Mynewt with it's open source bluetooth stack NimBLE won't invalidate the certification of a pre-certified RF module. So I think the only costs to certify this will be $3000 NZD for unintentional radiator testing and $2500 USD (first time, otherwise $8000 or $4000 for members) for Bluetooth qualification.

I've asked my preferred contract manufacturer for their prices for the RF modules to help choose the right one and I also have a meeting and tour of their facilities planned for next week.

arJvsJW.jpg
 
My meeting with the contract manufacturer - QuickCircuit - went well. I had been there before around a decade ago but the factory was much bigger than I remembered and that's only one of two that they have in Auckland. It was really helpful to have a tour of the factory to see all the different processes a board needs to go through to be assembled.

They can do LGA, BGA, DFN, 0201 (or even 01005) although 0201/01005 can cost a bit more in rework time. They have several assembly lines and can do selective soldering (most likely not used for this project). At their other factory they can do automated conformal coating, sealant, glue etc. Once the feeders have been set up, making several different boards at once is no problem, they can even customise each board for a specific customer (e.g. shunt selection) and keep track of it throughout the whole process until it's shipped.

I was told that the sealing/enclosure will probably be the hardest part of this design. Conformal coating gets everywhere, into connectors etc and unless the RF module is manually masked off (expensive) then it can severely reduce range. There are options to manually brush on a thicker coating which may be better but again it requires human labour which is expensive here. It would be nice to have a mold that keeps a free space around the RF module while the rest of the device is filled up with a transparent potting compound.

The display module most likely requires the FPC to be hand soldered which generally means it's best to order that from a display module manufacturer. The problem is that they will likely have a large minimum order. I will investigate the option of having a FPC connector (unusual pitch and connector is probably too thick) and also making a jig with pins that poke through some unplated holes on the PCB and through the guide holes on the FPC which would keep the FPC aligned and make manual soldering much easier.

At the moment my discussions with the CM will be around getting the base module built and then at a later stage I'll look at the LCD module and enclosure. The latter items could be released separately at a later date if necessary. They're going to be quoting me for the assembly and once I've finalised the BOM I'll send that to them for a quote.

My current roadmap is that I will build two or three prototypes with slightly different component selection (e.g. RF modules, shunts, battery positive bus bar) and evaluate them while writing some basic software and getting some feedback. I had hoped to get the prices for the RF modules by now but I'm think I have a good idea of which ones will be best for me. I think I will be ready to order the first prototype PCB variation within a couple of days.

I'll leave you with some renders of my latest design iteration including what the case could look like, and I have also attached the current schematic (missing a few parts). You can see the schematic is very simple. I think it's likely that my final design will end up with the Rigado BMD-350 or maybe the Insight SIP ISP1507-AX.

 

Attachments

  • power-analyzer.pdf
    76.4 KB · Views: 126
Here's the progress I've made. I ordered the boards several days ago except for the adapter board which I finished today. I chose to order them from both OSH Park (probably higher quality but slower) and JLCPCB (faster shipping, cheap stencil). My routing is pretty terrible but it's my first revision so it can only get better. Base board is four layer while the others are two layer.

These are the BOMs which I am constantly refining. Some of the components on there are more expensive than the ones I'd use for production but they're what I'm working at the moment. I've added a couple of sets of all these components to my Mouser cart along with lots of other variations to test. I'll make that order in a few days. I'll also need to buy some solder paste and better quality flux. I'm hoping I will be able to assemble them with just a hot plate and/or my big heat gun. The components are mostly 0402 with one 0201.

Base board: https://octopart.com/bom-tool/LRijOiPK
Display board: https://octopart.com/bom-tool/zFk5ejN8

Base board

Display Board

Right Angle Adaptor Board


Base board front layer

Base board back layer
 
I went to QuickCircuit again today where they were kind enough to give me a bit of Loctite GC 10 solder paste. I arrived home to a big pile of mail. My PCBs from JLCPCB arrived as well as my orders from Mouser, Arrow, RS Components and samples from various manufacturers.

I now have pretty much everything I need to build a prototype except for a reflow oven. My brother has some thermocouples and a hotplate and I have a heat gun (the type used for heat shrink tubing) as well as an ADC suitable for thermocouples and some SSRs. I could also go and buy a toaster oven.

Usually the board should be assembled starting with the SMT female header socket on the back which needs to be glued on. Then it would be turned over and the other SMT components would be added. Then the XT60PW connectors would be manually soldered. If I'm using a hot plate I think I could start with the front side SMT components, then manually solder the header socket before adding the XT60PW connectors.

I will see if I can set something up so I can assemble a board tonight.

 
looking great.

are you planning on making a beefier model (200A range) with a remote screen?

ow does it deal with rapidly changing loads? how often does it poll the values? the crappy chinese ones have bad polling times so it misses a lot of current/power in its calculations.
 
flippy said:
looking great.

are you planning on making a beefier model (200A range) with a remote screen?

I would like to eventually make several different models but I just want to keep my focus on this model until it is finished. The idea is that the web bluetooth, PC or Android software as well as the embedded firmware will be hardware agnostic. This is helped by using a RTOS which has hardware abstraction layers. So it shouldn't really care what sort of sensor or hardware platform you're using. Of course some small changes would need to be made for different models.

It's possible to use this model with an external shunt. You can leave off the XT60PW connectors and SMT shunt, then connect a bigger shunt with 4 wires (kelvin connection) plus a wire to the battery positive.

I answered the display question earlier. And of course a phone can always be used as a remote screen. Those little Bafang SW102 displays have an nRF51822 chip so it would be fairly easy to use one of those as a display.
flangefrog said:
I've considered remote displays like that but I think a semi-permanently installed display is better left to a BMS related project or a cycle analyst. Personally I always have my phone mounted on the stem when riding. Of course a remote display would be relatively easy for someone to add, whether by implementing a bluetooth host on the display or simply extending the SPI/I2C bus from the meter.
 
i missed that piece. thanks.

i am looking for a power sensor that can accuratly measure high currents in stationary applications without a fancy bms.
having a phone is fine in most cases but a fixed setup that has a simple LCD that is separate from the bms is often warranted, most bms dont have the option for a external lcd, especially fairly dumb ones. it also allows for applications were you want to measure specific outputs if you power multiple devices from a singe battery/power source.
 
flippy said:
i missed that piece. thanks.

i am looking for a power sensor that can accuratly measure high currents in stationary applications without a fancy bms.
having a phone is fine in most cases but a fixed setup that has a simple LCD that is separate from the bms is often warranted, most bms dont have the option for a external lcd, especially fairly dumb ones. it also allows for applications were you want to measure specific outputs if you power multiple devices from a singe battery/power source.

How accurate do you need? In most cases when using an external shunt, the shunt absolute accuracy and TCR is going to be the bottleneck. 1% absolute accuracy shunts are easy to find and larger ones with lower resistances may not be affected by the TCR too much. If you need more accuracy it must be calibrated. I want to buy one of these precision shunts to use for calibration - 0.01% accuracy: http://www.ohm-labs.com/precision-shunts/cs-20-50.html They cost about $3000 USD.

Depending on what people are after in terms of a remote display (e.g. distance, display size, ruggedness/waterproofing) I could create a reference design that's easy to build with a few through hole components and eBay display modules. The display module I've shown above could also be used remotely but will probably be limited to a couple of meters and may require an external 3.3V power supply.
 
flangefrog said:
How accurate do you need? In most cases when using an external shunt, the shunt absolute accuracy and TCR is going to be the bottleneck. 1% absolute accuracy shunts are easy to find and larger ones with lower resistances may not be affected by the TCR too much. If you need more accuracy it must be calibrated. I want to buy one of these precision shunts to use for calibration - 0.01% accuracy: http://www.ohm-labs.com/precision-shunts/cs-20-50.html They cost about $3000 USD.

Depending on what people are after in terms of a remote display (e.g. distance, display size, ruggedness/waterproofing) I could create a reference design that's easy to build with a few through hole components and eBay display modules. The display module I've shown above could also be used remotely but will probably be limited to a couple of meters and may require an external 3.3V power supply.
nice to see you are taking this seriously with buying the proper tools.

the problem with the chinese meters is that the polling times when they take the measurement is shit, often only 2~3 times per second, when you have very "pulsy" loads they miss a lot if current and then the coloumb measurements are way off after a while. in a bike those currents are not that much but on bigger things like scooters, cars and stationairy battery banks those numbers add up.
usuallt the current readings are fairly accurate (for chinese quality) but the actual power readings are just way off after discharing a couple kWh. so fast polling is needed for a accurate kWh/Ah measurement.

if you have a bit more modulair system with a removable/extendable screen and a simple STL for a 3d printed case and frontpanel for the lcd for exampleit would mean people can mount the display anywere on the bike or in my case on the front of a battery box. a couple meters would be plenty, prehaps not on a boat but 3.3v signals can carry 4~5 meters with proper wires.
guiding the actual power cables to the front of a box/bike or car is not very practical. using a phone or table is fun to play with but not very practical to have on a vehicle, it also means you need a phone to see anything instead if just glancing at the lcd.
 
flippy said:
the problem with the chinese meters is that the polling times when they take the measurement is shit, often only 2~3 times per second, when you have very "pulsy" loads they miss a lot if current and then the coloumb measurements are way off after a while. in a bike those currents are not that much but on bigger things like scooters, cars and stationairy battery banks those numbers add up.
usuallt the current readings are fairly accurate (for chinese quality) but the actual power readings are just way off after discharing a couple kWh. so fast polling is needed for a accurate kWh/Ah measurement.

The INA226 is capable of about 3.6k samples per second :) Obviously it's not usually practical to measure that fast though.

flippy said:
if you have a bit more modulair system with a removable/extendable screen and a simple STL for a 3d printed case and frontpanel for the lcd for exampleit would mean people can mount the display anywere on the bike or in my case on the front of a battery box. a couple meters would be plenty, prehaps not on a boat but 3.3v signals can carry 4~5 meters with proper wires.
guiding the actual power cables to the front of a box/bike or car is not very practical. using a phone or table is fun to play with but not very practical to have on a vehicle, it also means you need a phone to see anything instead if just glancing at the lcd.

Not sure if you noticed but the display is already removable - the base module has a socket with 3.3V, GND, I2C, SPI etc. I can see how a remote display would be useful in those situations. I'll play with some ideas later.
 
The assembly process was actually easier than I expected. I boxed in the PCB with some protoboards and then aligned the stencil and made a hinge with tape.


I spread the paste with an old credit card. The first time wasn't perfect - the stencil was very thin so it bowed up a bit and allowed too much paste to get through and spread underneath. The second time I used a lot more pressure on the card to keep the stencil flat.


I then placed the components using some Ideal-tek tweezers I just bought. I also bought another model that's better suited for the smaller components I'm using but it's still on the way. My hands were shaking a bit when I placed the BC832 so the paste got spread around a bit. The same with the INA226 which got knocked around a few times when placing nearby components.


I used a hot plate to reflow the board. I placed a thermocouple on the board and used a standard mercury thermometer to estimate the cold junction temperature.


After reflowing. One of the diodes at the top left needed some manual rework. I also had to remove some solder bridges under the INA226. I really need to buy some solder wire with the same composition as the paste I'm using (SAC305). Everything else looked good, I hope the LGA pads under the BC832 are all ok.


The finished board. I added three bodge wires for some problems I noticed before I started the assembly. One was forgetting to connect the MIC5283 regulator sense pin (behind C4). The other was that the RGB LED footprint was flipped so I cut a trace and switched two pins. The board is very dirty from all the flux I used but I don't have any alcohol to clean it right now. An ultrasonic cleaner would be nice.


I tested the board and the 3.3V regulator seems to work. I'll try programming it tomorrow.
 
Learning how to use Apache Mynewt and all the required toolchains again has a pretty big learning curve. Especially when I don't have a lot of previous experience with this sort of embedded development. Mynewt is great but it's still changing fast and the documentation is never up to date. I managed to use the proof of concept web bluetooth app and firmware (including INA226 driver) I made earlier for the nRF52832 dev kit with very few changes once I set the firmware app to use my new BSP (board support package) with the correct pin assignments etc.

Here it is wirelessly measuring an ebike battery being charged slowly over several hours. The big spike is when it stopped charging because of a faulty wire on the charger. The small spikes are greatly exaggerated in this view - there's only a few out of the thousands of samples. I think it's from the charger, not the INA226. Any noise is only up to 1 LSB (5mA in this case). Even that can be mostly eliminated with the right sampling time and averaging settings. Currently I'm using the longest sample time and no averaging.

Interestingly enough I found that charger doesn't switch off at end-of-charge and instead just floats the battery at 42V. Note the current is negative by default when current is flowing into the battery.

ogHJbyt.png
 
That behaviout is standard for lipo chargers. If it does not do that something is wrong with it.
 
flippy said:
That behaviout is standard for lipo chargers. If it does not do that something is wrong with it.

Some of them cut off when the current is below a threshold (e.g. 1/10 - 1/20 of the charging current) and may even start again when the voltage goes below a certain threshold.
 
Back
Top