mBuino program that shows how to read VCC using the blink of a LED

Dependencies:   USBDevice mbed

mBuino PowerMeter

This program shows how to read the current voltage on the 3V3 (VCC) pin of mBuino using the blink of a LED.

Since mBuino uses the VCC voltage as reference for analog reads, all readings are relative. To get an absolute reading an external reference voltage is needed. An easy way to get an external reference is by using a zener-diode with proper characteristics.

Not having such a zener around made me look for alternatives. I found some on this page: http://www.talkingelectronics.com/projects/200TrCcts/200TrCcts.html#52

/media/uploads/maxint/reference_voltage_using_diode.jpg

Use a LED!

The most interesting method I found was to use the LEDs on mBuino! All needed to use this is an extra connection. I used a 100R resistor as connection between pin 14 and LED6. Pin 14 is the small dot right above the one of the version number. Alternatively you can also use an external LED or (zener)-diode. The picture below shows both the added resistor as well as an external LED/resistor circuit. /media/uploads/maxint/mbuino_powermeter.jpg

Serial USB

The picture above shows a USB cable connected to mBuino. When mBuino is powered via USB and nothing else is connected to VCC, power comes from the 3v3 regulator. The VCC reading will then be around its maximum. USB is used to display the readings on the USB serial console. Note that for this the USB serial driver and a terminal application such as Putty is required. When using the console the spacebar can be hit to switch between pin14+LED6 and pin15 with an external LED/resistor via pin4.

See the code comments for more information.

Download repository: zip gz

Files at revision 4:853634e0d433

Name Size Actions
[up]
USBDevice.lib 65 Revisions Annotate
main.cpp 8517 Revisions Annotate
mbed.bld 65 Revisions Annotate