BV4205 ADC

The BV4205 is an I2C two wire compatible integrated circuit with a 10 channel 10 bit A to D converter. The IC works independently of the microcontroller and can acquire analogue signals continuously until required.

Resources

See this the downloads page at the Arduino section and download:

BV4205.zip for this libary
I2C_bv.zip for the common I2C methods

Connecting Up

+V    This should be connected to 5V on the Arduino ** The device will also work on the 3V3 supply
SDA (pin 13) This is the data line and should be connected to the Arduino Analogue input 4
G    Is the ground
SCK (pin 11) This is the clock line and should go to the Ardiono Analogue input 5 - sometimes designated SCL

Don't forget the pull up resistors on the SDA and SCL lines.

The Example

To make this as simple as possible only channel 0 has been connected to anything and that is an LDR (Light Dependant Resistor) that goes from ground to channel 0 and a 100k resistor that goes from channel 0 to +V. The darker it gets the higher the reading will be. Note also that pin 4 is connected to ground, this is essential for this device.

Single Channel Reading 

In the first example, reading a single channel the technique is to first select the channel, in this case 0, then wait a period of time so that the pin can acquire the voltage. This will depend on the external circuit but will normally be less than 1mS. The next thing is to convert the reading and then read the result. The conversion process is in the uS region.

The methods used are here:

adc.channel(0);
delay(1); // aquire voltage
adc.convert();
while(adc.done()); // not necessary
Serial.println(adc.result(), DEC);  

This procedure is required for each channel. The conversion time is much shorter than the I2C can read the result and so checking if the conversion has been done is not really necessary. Use the serial monitor to see the results. If you don't have an LDR then simply placing a finger on the pin will cause a change.

Using Autoscan

This method is much easier to use than the above and has the advantage that all the burden of acquiring and converting is removed from the host processor. Simply start the autoscan and read the result from any channel.:

adc.autoscan(1); // turn on autoscan
Serial.println(adc.autoread(0),DEC);
delay(2000);  

BV4205 Class

BV4205 The constructor will require the 7 bit I2C address, for this device it is 0x31, earlier versions may have an address of 0x21. 

BV4205 adc(0x31);

channel (char channel) Sets the channel to acquire data, the data begins to acquire as soon as this is set, example:

adc.channel();

convert() When sufficient time has elapsed for the channel to acquire its voltage  invoke this method and the coltage will be converted to a digital value, example:

adc.convert();

char done(); This will return 0 when the conversion is complete, however the process is so fast that the I2C channel will take longer to read this method than it will to convert the data. Example:

while(adc.done()); // wait here until done 

int result() This will return the result of the conversion, example:

r=adc.result();

autoscan(char on) This turns on or of the autoscan facility, when on, the chip will scan all of the channels in turn and store then for retreval. When using this method no other method can be used, example:

adc.autoscan(1); // turn on autoscan

int autoread(char channel) Reads one of the adc channels and returns the result, example:

adc.autoread(0);

The following methods are fully described in the data sheet. 

I2c Command        Method
8                            aqdelay(char delay)
9                            readdif(char channel)
10                          right(char on) // right justification
11                          vsource(char Vplus) // voltage reference source
12                          clock(char clk) // conversion clock