BV4221 & BV4222

BV4221_V2 BV4222_a BV4222_b


This device is a low cost conversion tool that is ideal for either experimenting with SPI/I2C devices or using these devices via a USB port. It is easy to use and its unique text i/o is intuitive and simple.. It works with both SPI and I2C so it is really two tools in one. In addition it will work with and power 3V3 & 5V logic devices. There is a foundation user guide with projects that can be used for learning about either of these buses.

BV4221 & BV4222

The BV4222 introduced in January 2016 is fully firmware compatible with the BV4221_V2 and so any reference to software in this text to BV4221_V2 will also apply to the BV4222. A new PCB introduced in November 2016 (version_b) has a different USB connector and the USB to serial is provided by the CH340 chip rather then the CP2102. There are some minor differences.


  1. The BV4221_V2 used the FTDI chip for the USB connectivity, the BV4222 uses a CP2102 (Veeraion a) and CH340 (Version_b)
  2. Power. The BV4221_V2 has two regulators 5V and 3.3V, the BV4222 uses the CP2102 on board regulator to provide 3.3V and the USB supply for the 5V
  3. The BV4221_V2 has 3 Chip Select lines for SPI the BV4222 has one
  4. The BV4221_V2 is user, firmware upgradeable via a boot loader, the BV4222 is not.

Firmware Updates (BV4221 Only)


Version 2 of the BV4221 was released at the back end of 2010, the new version has on board 3.3V and 5V regulators, can find I2C addresses and also has SPI capability.


A very good way of using this device is a programmed way, i.e.for controlling I2C from windows is to use Python. This language is more popular on Linux boxes but does have the massive advantage that any work done with Windows can also be directly transferred to Linus without modification. The minor inconvenience for Windows user's is that it has to be installed.

Python Installation on Windows
In summary to install SWS the following is required:

  1. Python
  2. Install notsmb that will also install the serial software

The python release used is 2.7.5 do not get the latest version 3. This can be obtained from here and comes with an installer which is great. The best way to use Python is from the command line so you will need to open a command window.
Windows python command.jpg
Navigate to the directory to work in using cd and type python, you will get the >>> Python prompt if everything is okay. If not log in and then log out again to apply the path.


This will also need to be installed but is is self contained exe and so all that is needed is to download and double click it. Python MUST be installed before this.

BV4221 setup and Code
Make sure that the version 2.5 or above is running on the BV4221 by using the V command. Out of the box the BV4221is designed to be user friendly on a terminal so run the following commands so that it can be used with Python:

  • P0 // tuns off the prompt
  • D // sets decimal
  • F // fixes this behaviour
  • B115200 // fixes baud rate

How to Use
There is just one main function that is used in the form bus.i2c(<address>[list out bytes],<number of bytes to return)
read 4 bytes form an I2C device with address 0x90
l = bus.i2c(0x90,[],4)

write 4 bytes form an I2C device with address 0x90
l = bus.i2c(0x90,[1,2,3,4],0)

send a command byte 0x22 followed by another byte 6 then read 2 bytes
l = bus.i2c(0x90,[0x22,6],2)

Note that the output bytes are in a list and so that is why the [] are there.

Just for experimentation purposes, open a command window and run python as above, assume that a 24C32 EEPROM is connected
>>> from notsmb import notSMB
>>> bus = notSMB("COM21",115200) # put in the com port to match your system

>>> bus.detect() # will return a list of all i2c devices
>>> bus.i2c(0x28,[0,0],10) #Read the first 10 values:
>>> bus.i2c(0x28,[0,30],10) #Read bytes at address 30:
>>> bus.i2c(0x28,[0,45,7],0) #Write 7 & 8 to address 45,46:

FAQ BV4221

How do I read 16 bytes from an 24c128 EEPROM at its address 1E75?

The 24c128 in common with other EEPROM devices has two addresses, the I2C address and the internal address of where the data is stored. First use the 'A' command to set the I2C address, example Ac0. Next send the address before reading the byte:

s 1e 75 r g-2 p

The above sends 1E75 to the EEPROM, the 'r' sends the restart command and g-2 will read two bytes form the address.

When entering data such as s 2 0x55 p the results are not as expected?

The BV4221 works with either decimal or hex, you cannot mix hex and decimal together so the '0x' will not be recognised. In other words when entering hex, make sure you are in hex mode (the prompt will be 0xnn>) and enter the value without the '0x' like so:

s 2 55 p

On the BV4221-V2 I enter 'f' to discover the I2C devices on the bus but get an error?

On the later versions of the BV4221, the 'f' command was renamed to 'x', so use 'x' instead of 'f'

Reading and writing EEPROMS using Python and a GUI


Resource: Source code zip

Once Python is installed, to run the program simply unzip the above to a folder and double click on the file. The zip file contains all of the source code.

This article will describe how to implement this free software to read and write to serial EEPROMS using Python and a BV4221. The software can be used for Windows and Linux and is open source so any new EEPROMS can be created on the fly. It was written using Boa Constructor which is a graphical IDE much like Visual Basic and all of the other IDE's but this one is for Python and the Python GUI. The operating system used to write the software was Windows and so Python and wxPython was required.

To use this software on Windows you will need to install Python and wxPython. This is a downside to this development as the user also needs to install Python and its graphical code to get the application working. I was tempted to just code this in C++ using a Borland IDE, it would have been much easier (only because I know it) but most of all the user would simply need to click on an exe to get it working

The reason for choosing Python, despite this considerable drawback, is twofold:

  1. It works almost seamlessly on Windows and Linux
  2. The user has the opportunity to change the way it works, or even use it as the basis of something else. In this case it is necessary to have a modifiable platform as there are so many different types of EEPROM.

This is a screen shot of the window produced.

How it Works

The BV4221 us a USB device that presents itself as a COM port, this will be COMnn on Windows and omething like dev/ttyAMA0 on Linux. Commands to the BV4221 are very simple text strings that are easily interpreted. It can handle both SPI and I2C so is very versatile.

This is a class that connects the bV4221 to the serial device and has some very basic methods for connecting and setting the mode (SPI or I2C). A user should not need to modify this unless a bug is found. It provides a very convenient way of talkint to the BV4221 and thus the connected EEPROM.

There isn't a file with the name above but a few different files with the same names as the EEPROM, for example. These are classes that enable reading and writing to a specific type of EEPROM, to add a new EEPROM simply copy one of the classes and modify it. The AT93c46 is an SPI device and the M24c0nn are I2C devices and so both bases are covered in respect of examples.

This is the GUI application that Boa created (originally called and clicking on this in the correct environment (with the python GUI installed and on the path) will launch the applciation.

This is partly created by Boa and will need slight modification when adding a new EEPROM but the beauty of it is that really only a class needs to be added for it to work.

Adding an EEPROM

One of the main reasons for using Python is so that a user could potentially add a new EEPROM no matter how that EERPOM worked as the 'programmability' of the device is in the class itself and not in the main GUI. The upshot of this is only the new class needs creating and then adding to the GUI.

  1. Copy an existing class of the same type, SPI or I2C
  2. Rename and modify the class to suit the EERPOM
  3. Add the class to 'Frame1' by adding an extra import statement and also adding it to the DEVICES dictionary
DEVICES = {'AT93c46_16': AT93c46_16.at93c46_16(bv4), 'AT93c46_8':AT93c46_8.at93c46_8(bv4),

The dictionary consists of two parts, the first is the name that is presented to the user in the devices drop down combo box and the second part is the file name and class name. The convention i used was to give the file name an upper case starting letter(s0 and the class name lower case. Simply copy and existing statement and modify the contents.


I do not have any detailed instructions for this as it is already installed on my Windows system and it was done too long ago for me to rememberer the steps, I will update this if the situation changes but I think that the only action that is needed is to install wxPython as this will also probably install Python. The site given has the windows binaries. It is already installed as part of Linux so there should not be a problem there.