{"id":308,"date":"2019-03-03T11:22:07","date_gmt":"2019-03-03T11:22:07","guid":{"rendered":"http:\/\/www.hardwarehacker.co.uk\/blog\/?p=308"},"modified":"2021-04-07T08:29:56","modified_gmt":"2021-04-07T08:29:56","slug":"power-monitoring","status":"publish","type":"post","link":"https:\/\/www.hardwarehacker.co.uk\/blog\/power-monitoring\/","title":{"rendered":"Power monitoring"},"content":{"rendered":"<p>Since we&#8217;re using unprotected LiPo batteries, which would be <del>seriously<\/del>\u00a0explosively damaged by over-discharge, we&#8217;ve worked some I2C voltage and power monitors into our bot this year.<\/p>\n<p>We&#8217;re using these INA219 boards in-line with the battery cables to measure\u00a0 voltage, current and power.<\/p>\n<p><a href=\"http:\/\/www.hardwarehacker.co.uk\/blog\/wp-content\/uploads\/2019\/03\/IMG_20190303_111310.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-309\" src=\"http:\/\/www.hardwarehacker.co.uk\/blog\/wp-content\/uploads\/2019\/03\/IMG_20190303_111310-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/www.hardwarehacker.co.uk\/blog\/wp-content\/uploads\/2019\/03\/IMG_20190303_111310-300x225.jpg 300w, https:\/\/www.hardwarehacker.co.uk\/blog\/wp-content\/uploads\/2019\/03\/IMG_20190303_111310-768x576.jpg 768w, https:\/\/www.hardwarehacker.co.uk\/blog\/wp-content\/uploads\/2019\/03\/IMG_20190303_111310-1024x768.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Out of the box, the sensors can read the bus voltage (i.e. potential difference between ground and the IN- connection).\u00a0 To get them to read current and power, you need to set a configuration value in one of the registers.<\/p>\n<p>One gotcha we hit was that the bus voltage register is not &#8220;right aligned&#8221;, some of the low-order bits are used for status flags so you have to take the voltage reading and shift the value 3 bits to the right to extract the voltage and then multiple by 4mV to scale it.<\/p>\n<p>With that out of the way and the calibration register programmed, we now have sensible-looking readings from the battery pack that is powering the Pi:<\/p>\n<pre>A: 7.95V &lt;nil&gt; A: 0.459A &lt;nil&gt; A: 3.615W &lt;nil&gt;\r\nA: 7.94V &lt;nil&gt; A: 0.431A &lt;nil&gt; A: 3.420W &lt;nil&gt;\r\nA: 7.97V &lt;nil&gt; A: 0.424A &lt;nil&gt; A: 3.339W &lt;nil&gt;<\/pre>\n<p>and, we should be able to alarm if the voltage of the pack drops too low.\u00a0 (We have a two-cell pack for the Pi, so anything less than 6V would mean that our pack would be damaged.)<\/p>\n<p>Since we had some strange power-related gremlins last year, we split the motor and Pi power so that the motors are powered by a completely separate battery pack.\u00a0 That means that we have two INA219s; one for each pack.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since we&#8217;re using unprotected LiPo batteries, which would be seriously\u00a0explosively damaged by over-discharge, we&#8217;ve worked some I2C voltage and power monitors into our bot this year. We&#8217;re using these INA219 boards in-line with the battery cables to measure\u00a0 voltage, current and power. Out of the box, the sensors can read the bus voltage (i.e. potential &hellip; <a href=\"https:\/\/www.hardwarehacker.co.uk\/blog\/power-monitoring\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Power monitoring<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,5,10],"tags":[8,2],"_links":{"self":[{"href":"https:\/\/www.hardwarehacker.co.uk\/blog\/wp-json\/wp\/v2\/posts\/308"}],"collection":[{"href":"https:\/\/www.hardwarehacker.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hardwarehacker.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hardwarehacker.co.uk\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hardwarehacker.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=308"}],"version-history":[{"count":1,"href":"https:\/\/www.hardwarehacker.co.uk\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions"}],"predecessor-version":[{"id":310,"href":"https:\/\/www.hardwarehacker.co.uk\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions\/310"}],"wp:attachment":[{"href":"https:\/\/www.hardwarehacker.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hardwarehacker.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hardwarehacker.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}