I have been playing with my self built Arduino’s the last weeks. One of my designs is a small (5x5cm) board with an ATmega328P-PU and a header for a nRF24L01 wireless module. I named it the Bajduino 328RF24 š
Since the nRF24L01 modules work at 3,3V I decided to let the ATmega run @ 3,3V. I used a 16MHz resonator, this is just out of spec according to the Atmel datasheet but it seems to work. I designed the board to use in a robot, the board just needs to do the wireless communication. It must then sent the data it receives over the I2C bus to another Arduino fitted to the robot. The other Arduino runs at 5V, this causes a small problem. You can not connect 3V3 and 5V I2C signals together. You must use a logic level converter to change the signal to the correct voltage. I2C is bidirectional so it must work both ways, the 3V3 signals must be converted to 5V and the 5V signals to 3V3. The easy way to solve this is to buy this board from Sparkfun. It even costs less then 2$, unfortunately I live in the EU and the shipping would cost a lot more then the board itself. I also found it at a German web shop that sells Sparkfun stuff but the shipping alone was 9ā¬.
So I decided to heat up my solder iron and make it my self. I2C is an invention of Philips, they originally came up with it to connect various sensors in VCR’s. I2C only uses 2 pins, SDA and SCL. These are pin A4 and A5 on an Arduino Duemilanove/Uno, you also have to connect the grounds of the 2 Arduinos together. Philips have published an application note (nĀ°97055) for a bi-directional level shifter for the I2C-bus and other systems. You can download it here. On page 10 there is an example schematic for a 3V3 – 5V bidirectional level shifter. You only need 4 resistors and 2 small logic level mosfets to make it work.
I made a schematic and board in Eagle and then soldered the components to a small piece of perfboard. I used 2N7000 mosfets as I had a dozen of these lying around, for the resistors I chose a value of 2K2. I added a couple of male pins to connect it to my Bajduinos. I then put the example sketches of the wire library in the 2 Bajduinos to test the my logic level converter and it works š
[…] I connected the sensor to my Bajduino Mega 3A board, it has an ATmega1284P-PU running at 5V and a logic level converter for the I2C bus. The logic level converter shifts the 5V I2C bus of the ATmega to 3.3V. Do not […]