[riot-notifications] [RIOT-OS/RIOT] feather-m0: add BAT voltage ADC line (A7) (#10938)

Martine Lenders notifications at github.com
Thu Jun 6 15:56:49 CEST 2019


miri64 commented on this pull request.



> @@ -24,7 +24,20 @@ SAMD21 mcu.
 ### Pinout
 
 <img src="https://cdn-learn.adafruit.com/assets/assets/000/030/921/original/adafruit_products_2772_pinout_v1_0.png"
-     alt="Adafruit Feather M0 proto pinout" style="width:800px;"/>
+     alt="Adafruit Feather M0 proto pinout" style="width:800px;"/><br/>
+
+`AIN7` can be used to [measure the voltage of a connected Lipoly battery][battery].
+It is mapped to ADC_LINE(6) in RIOT.
+
+~~~~~~~~~~~~~~~~ {.c}
+int vbat = adc_sample(ADC_LINE(6), ADC_RES_10BIT);
+vbat *= 2;      /* voltage was divided by 2, so multiply it back */
+vbat *= 33;     /* reference voltage 3.3V * 10 */
+vbat /= 10240;  /* resolution * 10 (because we multiplied 3.3V by 10) */
+printf("Bat: %dV", vbat);

Done

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10938#discussion_r291195153
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190606/45c93ed5/attachment.html>


More information about the notifications mailing list