8/23/2023 0 Comments Arduino lipo voltage monitorA bat = ADC value returned by reading V bat.A ref = ADC value returned by reading V bg.V bg = Voltage of internal bandgap reference on the AVR = 1.1V.But here is the process that was used to determine how to calculate the battery voltage and current. Either way here's a nice little video of the library operating with the same program as above:Ĭhances are this has been worked out before, I don't know, I didn't really look. Its worth noting that the AREF pin of the Arduino should always be connected to the highest voltage in your circuit provided that it's not outside the operating range of the board itself. I used some generic boost converter module that was laying around so there's really just a stand in for the boost converter in the schematic below: For this the schematic gets a little bit more messy but really its not that bad. Now onto the good stuff, the library can now officially monitor a battery while being powered by a boost converter. I measured 1.42 ohms by just doing the math after putting it across the power supply set to 1V and reading the current (its a 5w resistor it could take it). I suspect this is due to the sense resistor I'm using, however, I currently don't own a multimeter that can measure resistances that low with any real accuracy. The voltage of the battery and the operating voltage appear to be reading pretty accurately but the current is somewhat off. Onto the simple battery monitor which was the original goal of this project it works! using the same schematic as is shown in the project image:Īnd the results of the test are shown in this video: Note the sketch prints battery input as Vbat, Battery Current as Ibat, and the operating voltage of the Arduino as Vop. All this sketch really does is use the library functions getCurrentBatteryVoltage(), getBatter圜urrent(), and getCurrentOperatingVoltage() then print the return values to the display. So a better test will come when some proper. because that's the best I could cobble together from my salvaged parts box. I cut out the setup(), but it is important to note that the resistance for these tests was set to 1.42 ohms. So lets talk about the code first, which doesn't change between either of the tests shown in this log: # include # include # include # include # define SCREEN_WIDTH 128 // OLED display width, in pixels # define SCREEN_HEIGHT 32 // OLED display height, in pixels Adafruit_SSD1306 display (SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET) # define batVoltagePin A0 //connect directly to positive terminal of the battery # define batCurrentPin A1 //connect to the other side of a shunt resistor going from the positive battery terminal to the rest of your circuitBatteryMonitor bat = BatteryMonitor(batVoltagePin, batCurrentPin) void loop () I also tested the library using a boost converter circuit powered from the same battery that's being monitored so basically this is just an all around project update with some actual test footage. Either way, I have been waiting on some OLED I2C displays to actually test this library properly and they finally arrived (I plugging into the arduino and using the serial monitor interferes with the results). This project has moved pretty fast overall, not sure how long I expected this project to take. This project is still ongoing, and awaiting parts for thorough testing. Where A terms represent the ADC value returned by reading the pin.įor anyone interested the full derivations are available in the logs of this project. This library is also capable of monitoring the battery while the Arduino is powered by a boost converter for those who need 5V instead of whatever the battery happens to be at.įor anyone curious about what's happening behind the scenes the battery voltage is calculated by: See the github page for some simple circuit guidelines for this library. As a result, be sure to have the battery disconnected whenever programming. It is worth noting that as the project stands right now for Arduino boards there is no way to prevent current from the USB programmer from going into the battery and causing problems. External components are kept to an absolute minimum, requiring only the battery and a shunt resistor (which isn't needed if you don't care about current draw). From these measurements the library is able to measure the external voltage, allowing users to choose what to do in undervoltage/overvoltage/overcurrent cases within their projects. This project utilizes the ATmega328's internal 1.1V bandgap reference to allow for accurate measurements of external voltages. The Arduino library can be downloaded from the github page here:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |