<p>&nbsp;</p>
<table id="printPost1" class="post-body" cellspacing="0" cellpadding="0" role="presentation" style="margin: 0px; padding: 0px; font-family: Helvetica-Light, 나눔고딕, nanumgothic, AppleSDGothicNeo, &quot;malgun gothic&quot;, &quot;맑은 고딕&quot;, sans-serif; table-layout: fixed; width: 772.997px; color: #000000; font-size: medium; background-color: #ffffff;">
   <tbody>
      <tr>
         <td class="bcc" style="margin: 0px; padding: 0px; background: transparent;">
            <table class="post-top" style="margin: 0px; padding: 0px; width: 742.997px; table-layout: fixed;">
               <tbody>
                  <tr>
                     <td valign="bottom" class="p12" style="margin: 0px; padding: 0px;">
                        <div class="htitle" id="title_1" style="padding: 3px 0px 5px 3px; font-family: 돋움; clear: both; overflow: hidden; word-break: break-all; overflow-wrap: break-word; zoom: 1;"><span class="pcol1 itemSubjectBoldfont" style="color: #e19c72; font-size: 18px; display: inline; letter-spacing: -1px; font-weight: bold;">[ESP32] ESP32로 배터리 전압 측정</span>&nbsp;<span class="cate pcol2" style="color: #615652; display: inline; padding-left: 3px;"><img src="https://blogimgs.pstatic.net/imgs/nblog/spc.gif" alt="" class="pcol2b fil3 egjs-visible" width="1" height="11" style="border: 0px; opacity: 0.3; background: rgb(97, 86, 82); margin: 0px 5px -1px 0px;" />&nbsp;<a href="https://blog.naver.com/PostList.naver?blogId=heennavi1004&amp;categoryNo=86&amp;from=postList" class="pcol2" style="text-decoration-line: none; color: #615652; cursor: pointer;" target="_blank">arduino</a>&nbsp;/&nbsp;<a href="https://blog.naver.com/PostList.naver?blogId=heennavi1004&amp;categoryNo=46&amp;parentCategoryNo=46&amp;from=postList" class="pcol2" style="text-decoration-line: none; color: #615652; cursor: pointer;" target="_blank">ESP32/ESP8266</a>&nbsp;<img src="https://blogimgs.pstatic.net/imgs/nblog/spc.gif" alt="" width="105" height="1" class="egjs-visible" style="border: 0px;" />&nbsp;&nbsp;</span></div>
                        <p class="date fil5 pcol2 _postAddDate" style="margin-top: -19px; padding: 0px 1px 0px 3px; opacity: 0.5; color: #615652; float: right; position: relative; font-family: dotum; font-size: 11px;">2021. 6. 16. 0:33</p>
                        <p class="fil3 dline" style="padding: 0px; opacity: 0.3; border-top: 1px dotted rgb(225, 156, 114); height: 7px; overflow: hidden; font-size: 0px;">&nbsp;</p>
                        <p class="url" id="url_heennavi1004_222399697927" style="padding: 0px 0px 0px 3px; height: 18px; text-align: right; float: right;"><img id="copyBtn_heennavi1004_222399697927" src="https://blogimgs.pstatic.net/nblog/btn_urlcopy.gif" width="21" title="https://blog.naver.com/heennavi1004/222399697927" height="13" alt="복사" class="btn_urlcopy _setClipboard egjs-visible" style="border: 0px; float: right; font-family: dotum; font-size: 11px; margin-left: 4px;" /><a href="https://blog.naver.com/heennavi1004/222399697927" target="_top" class="fil5 pcol2" style="text-decoration-line: none; color: #615652; cursor: pointer; opacity: 0.5; float: right; font-family: dotum; font-size: 11px;">https://blog.naver.com/heennavi1004/222399697927</a></p>
                        <div class="clear blank5" style="clear: both; height: 5px; overflow: hidden; font-size: 0px;">&nbsp;</div>
                        <p class="post_option" style="padding: 0px; height: 18px; text-align: right;">&nbsp;</p>
                        </td>
                     </tr>
                  </tbody>
               </table>
            <div id="postViewArea">
               <div id="post-view222399697927" class="post-view pcol2 _param(1) _postViewArea222399697927" style="color: #615652; font-family: 돋움; font-size: 12px; overflow: auto hidden; width: 742.997px; position: relative; padding: 15px 0px; margin: 0px 0px 15px; clear: both; text-align: justify; line-height: 1.5; overflow-wrap: break-word;">
                  <p style="padding: 0px; line-height: 1.5;">ESP32로 배터리 전압 측정</p>
                  <p style="padding: 0px; line-height: 1.5;"><br /></p>
                  <p style="padding: 0px; line-height: 1.5;">참고:&nbsp;<a href="https://blog.naver.com/twophase/220809096718" target="_blank" class="con_link" style="text-decoration-line: none; cursor: pointer; overflow-wrap: break-word;">https://blog.naver.com/twophase/220809096718</a></p>
                  <p style="padding: 0px; line-height: 1.5;"><br /></p>
                  <p style="padding: 0px; line-height: 1.5;"><img src="https://postfiles.pstatic.net/20160909_222/twophase_1473422240121QvlUU_JPEG/20160909_1.jpg?type=w2" id="20160909_222/twophase_1473422240121QvlUU_JPEG/20160909_1.jpg" alt="" class="egjs-visible" style="border: 0px; cursor: pointer;" /></p>
                  <p style="padding: 0px; line-height: 1.5;"><br /></p>
                  <p style="padding: 0px; line-height: 1.5;"><br /></p>
                  <p style="padding: 0px; line-height: 1.5;"><br /></p>
                  <p style="padding: 0px; line-height: 1.5;"><br /></p>
                  <div style="line-height: 19px; color: #d4d4d4; background-color: #1e1e1e; font-family: Consolas, &quot;Courier New&quot;, monospace; font-size: 14px; white-space: pre;">
                     <div style="line-height: 1.5;"><span style="color: #6a9955;">//&nbsp;전압&nbsp;측정</span></div>
                     <div style="line-height: 1.5;"><span style="color: #569cd6;">const</span>&nbsp;<span style="color: #569cd6;">float</span>&nbsp;loadR&nbsp;=&nbsp;<span style="color: #b5cea8;">4.7</span>;<span style="color: #6a9955;">&nbsp;&nbsp;//&nbsp;Load&nbsp;Resistor&nbsp;(Ohm)</span></div>
                     <div style="line-height: 1.5;"><span style="color: #569cd6;">const</span>&nbsp;<span style="color: #569cd6;">float</span>&nbsp;refV&nbsp;=&nbsp;<span style="color: #b5cea8;">3.8</span>;<span style="color: #6a9955;">&nbsp;&nbsp;&nbsp;//&nbsp;Reference&nbsp;(Rated)&nbsp;Voltage</span></div>
                     <div style="line-height: 1.5;"><span style="color: #569cd6;">float</span>&nbsp;Wh&nbsp;=&nbsp;<span style="color: #b5cea8;">0.0</span>;</div>
                     <div style="line-height: 1.5;"><span style="color: #569cd6;">const</span>&nbsp;<span style="color: #569cd6;">unsigned</span>&nbsp;<span style="color: #569cd6;">long</span>&nbsp;interval&nbsp;=&nbsp;<span style="color: #b5cea8;">3000</span>;<span style="color: #6a9955;">&nbsp;&nbsp;//30000;&nbsp;&nbsp;&nbsp;//&nbsp;Recording&nbsp;interval&nbsp;(&gt;&nbsp;15000ms)</span></div>
                     <div style="line-height: 1.5;"><span style="color: #569cd6;">unsigned</span>&nbsp;<span style="color: #569cd6;">long</span>&nbsp;logTime&nbsp;=&nbsp;<span style="color: #b5cea8;">0</span>;</div>
                     </div>
                  <p style="padding: 0px; line-height: 1.5;"><br /></p>
                  <p style="padding: 0px; line-height: 1.5;"><br /></p>
                  <div style="line-height: 19px; color: #d4d4d4; background-color: #1e1e1e; font-family: Consolas, &quot;Courier New&quot;, monospace; font-size: 14px; white-space: pre;">
                     <div style="line-height: 1.5;"><span style="color: #569cd6;">void</span>&nbsp;<span style="color: #dcdcaa;">getBatteryStatus</span>()&nbsp;{<span style="color: #6a9955;">&nbsp;//&nbsp;배터리&nbsp;상태&nbsp;가져오기</span></div>
                     <div style="line-height: 1.5;">&nbsp;<span style="color: #c586c0;">if</span>(<span style="color: #dcdcaa;">millis</span>()-logTime&nbsp;&gt;=&nbsp;interval)&nbsp;{</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;logTime&nbsp;=&nbsp;<span style="color: #dcdcaa;">millis</span>();</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #569cd6;">float</span>&nbsp;volt&nbsp;=&nbsp;(<span style="color: #569cd6;">float</span>)<span style="color: #dcdcaa;">analogRead</span>(BAT_ADC)&nbsp;*&nbsp;<span style="color: #b5cea8;">4.15</span>&nbsp;/&nbsp;<span style="color: #b5cea8;">607.0</span>&nbsp;*&nbsp;<span style="color: #b5cea8;">4.087</span>/<span style="color: #b5cea8;">15.9</span>;<span style="color: #6a9955;">&nbsp;//&nbsp;4.087V/15.9&nbsp;값</span></div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #569cd6;">float</span>&nbsp;ampere&nbsp;=&nbsp;volt&nbsp;/&nbsp;loadR;</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #569cd6;">float</span>&nbsp;watt&nbsp;=&nbsp;volt&nbsp;*&nbsp;ampere;</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;Wh&nbsp;+=&nbsp;watt&nbsp;*&nbsp;(<span style="color: #569cd6;">float</span>)interval&nbsp;/&nbsp;<span style="color: #b5cea8;">3600000.0</span>;</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #569cd6;">float</span>&nbsp;mAh&nbsp;=&nbsp;Wh&nbsp;/&nbsp;refV&nbsp;*&nbsp;<span style="color: #b5cea8;">1000.0</span>;</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;postStr&nbsp;=&nbsp;<span style="color: #ce9178;">"Bat.&nbsp;"</span>;</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;postStr&nbsp;+=<span style="color: #ce9178;">"Volt:&nbsp;"</span>;</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;postStr&nbsp;+=&nbsp;<span style="color: #dcdcaa;">String</span>(volt,&nbsp;<span style="color: #b5cea8;">3</span>);</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;postStr&nbsp;+=<span style="color: #ce9178;">"</span><span style="color: #d7ba7d;">\t</span><span style="color: #ce9178;">Amp:&nbsp;"</span>;</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;postStr&nbsp;+=&nbsp;<span style="color: #dcdcaa;">String</span>(ampere,&nbsp;<span style="color: #b5cea8;">3</span>);</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;postStr&nbsp;+=<span style="color: #ce9178;">"</span><span style="color: #d7ba7d;">\t</span><span style="color: #ce9178;">Watt:&nbsp;"</span>;</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;postStr&nbsp;+=&nbsp;<span style="color: #dcdcaa;">String</span>(watt,&nbsp;<span style="color: #b5cea8;">3</span>);</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;postStr&nbsp;+=<span style="color: #ce9178;">"</span><span style="color: #d7ba7d;">\t</span><span style="color: #ce9178;">mAh:&nbsp;"</span>;</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;postStr&nbsp;+=&nbsp;<span style="color: #dcdcaa;">String</span>(mAh,&nbsp;<span style="color: #b5cea8;">2</span>);</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;postStr&nbsp;+=<span style="color: #ce9178;">"</span><span style="color: #d7ba7d;">\t</span><span style="color: #ce9178;">Wh:&nbsp;"</span>;</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;postStr&nbsp;+=&nbsp;<span style="color: #dcdcaa;">String</span>(Wh,&nbsp;<span style="color: #b5cea8;">3</span>);</div>
                     <div style="line-height: 1.5;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #9cdcfe;">Serial</span>.<span style="color: #dcdcaa;">println</span>(postStr);</div>
                     <div style="line-height: 1.5;">&nbsp;}</div>
                     <div style="line-height: 1.5;">}</div>
                     </div>
                  <p style="padding: 0px; line-height: 1.5;"><br /></p>
                  <p style="padding: 0px; line-height: 1.5;">결과</p>
                  <p style="margin-left: 40px; padding: 0px; line-height: 1.5;">Bat. Volt: 4.088<span style="white-space: pre;"></span>Amp: 0.870<span style="white-space: pre;"></span>Watt: 3.555<span style="white-space: pre;"></span>mAh: 12.49<span style="white-space: pre;"></span>Wh: 0.047</p>
                  <p style="margin-left: 40px; padding: 0px; line-height: 1.5;">Bat. Volt: 4.088<span style="white-space: pre;"></span>Amp: 0.870<span style="white-space: pre;"></span>Watt: 3.555<span style="white-space: pre;"></span>mAh: 13.27<span style="white-space: pre;"></span>Wh: 0.050</p>
                  <p style="margin-left: 40px; padding: 0px; line-height: 1.5;">Bat. Volt: 4.093<span style="white-space: pre;"></span>Amp: 0.871<span style="white-space: pre;"></span>Watt: 3.564<span style="white-space: pre;"></span>mAh: 14.05<span style="white-space: pre;"></span>Wh: 0.053</p>
                  <p style="margin-left: 40px; padding: 0px; line-height: 1.5;">Bat. Volt: 4.091<span style="white-space: pre;"></span>Amp: 0.870<span style="white-space: pre;"></span>Watt: 3.561<span style="white-space: pre;"></span>mAh: 14.83<span style="white-space: pre;"></span>Wh: 0.056</p>
                  <p style="margin-left: 40px; padding: 0px; line-height: 1.5;">Bat. Volt: 4.089<span style="white-space: pre;"></span>Amp: 0.870<span style="white-space: pre;"></span>Watt: 3.558<span style="white-space: pre;"></span>mAh: 15.61<span style="white-space: pre;"></span>Wh: 0.059</p>
                  <p style="margin-left: 40px; padding: 0px; line-height: 1.5;">Bat. Volt: 4.093<span style="white-space: pre;"></span>Amp: 0.871<span style="white-space: pre;"></span>Watt: 3.564<span style="white-space: pre;"></span>mAh: 16.39<span style="white-space: pre;"></span>Wh: 0.062</p>
                  <div style="line-height: 1.5;">실제 Li ion 18650 전압</div>
                  <div style="line-height: 1.5; margin-left: 40px;"><span id="docs-internal-guid-e4cf380b-7fff-78c8-7c49-b882e4da55a0"><span style="font-size: 11pt; font-family: Arial; font-variant-numeric: normal; font-variant-east-asian: normal; vertical-align: baseline; white-space-collapse: preserve;">&nbsp;4.088 ~ 4.089 V   OK
                           <div class="autosourcing-stub-extra" style="line-height: 1.5; zoom: 1; opacity: 1;">
                              <p style="margin-top: 11px; margin-bottom: 7px; padding: 0px; line-height: 1.5; font-size: 12px; font-family: Dotum;"><strong style="padding: 0px 7px 0px 0px;">[출처]</strong><a href="https://blog.naver.com/heennavi1004/222399697927" target="_blank" style="text-decoration-line: none; cursor: pointer;">[ESP32] ESP32로 배터리 전압 측정</a><span style="padding: 0px 7px 0px 5px;">|</span><strong style="padding: 0px 7px 0px 0px;">작성자</strong><a href="https://blog.naver.com/heennavi1004" target="_blank" style="text-decoration-line: none; cursor: pointer;">초초</a></p>
                              </div>
                           </span></span></div>
                  </div>
               </div>
            </td>
         </tr>
      </tbody>
   </table>