Standard car batteries are usually 12V affairs with the voltage varying around this value depending on their level of charge. This variation in voltage can be monitored to give an indication of the charge-state of the battery. So how do we take this analogue battery voltage and put it on to a digital computer? We use an analogue-to-digital converter or ADC. Fortunately, the boys and girls at Atmel have incorporated several ADCs within their AVR microprocessors which we can make use of to do the conversion. So all that needs to be done to make the sensor is to hook up the battery to an AVR microprocessor with a RFM12B wireless module attached.
ADC on AVR
Using the ADC on the ATmega168 is relatively straightforward although there are a number of options to choose from which makes it quite intense. There are multiple resources on the web explaining how to use ADCs on AVRs, and the essential aspects of how I use the ADCs for my projects can be found here. For the car battery voltage sensor, the ADC specifics were as follows:
The device is programmed to wait for a wireless signal from the user prior to doing an analogue-to-digital conversion
The default ADC0 channel (port PC5) was used
10-bit resolution for maximum ADC accuracy on the AVR was used
RFM12B Wireless[easyazon_cta add_to_cart=”default” align=”right” asin=”B007XEX19I” cloaking=”default” height=”28″ key=”wide-light” localization=”default” locale=”UK” nofollow=”default” new_window=”default” tag=”tronic03-21″ width=”170″]
The standard method of using RFM12B wireless communication was used and is outlined here
Since the RFM12B module sends out a single 8-bit number at a time, the 10-bit voltage reading is sent as 2 consecutive bytes