I’ve been looking for ways to control my Service droid robot, my Service droid robot has an ATmega2560 (with Arduino bootloader) and a Raspberry Pi. My goal is to control it over wifi. But I wanted to start with some more simpler things first. I’ve recently found some python code on letsmakerobots.com that lets me sent data over I2C from a Raspberry Pi to a micro controller.
Before getting this to work you need to configure I2C on the Raspberry Pi. Adafruit has written a nice guide how to do this. I also installed the python-SMBus package: sudo apt-get install python-smbus.
The Raspberry Pi’s gpio pins are 3.3V and my ATmega runs at 5V so I used a logic level converter to connect both. I connected my Bajduino Mega 3A board to the Raspberry Pi. My big Bajduino has an I2C logic level converter on board so I didn’t need to connect any extra electronics.
To test the Raspberry Pi I2C to Arduino connection I found some useful information on Oscar Liangs blog.
I then started modifying the code I found on letsmakerobots so the small webserver serves a webpage with 4 buttons. By pressing a button the python code will sent a command over I2C to the ATmega. By pressing the buttons I can control 4 leds connected to the ATmega. The webserver runs on port 888, I tried running it on the default webserver port 80 but couldn’t get it to work. I also have to run it as root, else I couldn’t access the I2C pins. This is a security issue, not something you want to try running on the internet.
I’m not sure if I will use this code to control my service droid robot. I’ve also been looking at using Apache with cgi to run python code. This is a bit harder to setup and write code for. So I’m still a long way of to control my robot over wifi with my Raspberry Pi