Analog Pi – Interfacing Atmega8 with Raspberry Pi
|Raspberry has everything that you need except ADC and one more problem with the Pi is 3.3V. One other hand we have Atmega8 which is 5v level and has ADC. We can play with Atmega8, even if you burn the microcontroller you can just replace it easily. If we can interface both of them we can get good of the both worlds. There are many ways you can interface them, like you can develop some sort interface which suits your application. When your developing some thing, having a generic driver that can talk with IO and ADC will be very helpful. with that in mind I developed small driver AnalogPi to this task. Using AnalogPi you can control IO’s and get the readings of ADC from Atmega8.
AnalogPi uses serial port to communicate with hosts. you can also use this with your home computer/laptop but you need a USB-UART converter.
The microcontroller side code is developed in C and host side interface is developed in python.
The python library provides the following methods
analogRead(pin) # This function takes pin number as input and returns you the analog values on that pin
digitalRead(pin) # This function takes pin number as input and returns the status of pin (0 or 1)
digitalWrite(pin,bit) #This function takes pin number and bit that need to written to that pin (0 0r 1) and returns bit
How to use:
You need to prepare both your host(Pi/Laptop) and the microcontroller(Atmega8)
download AnalogPi folder from here.
Usage Instructions(Raspberry Pi):
1. By default kernel uses the serial port to print boot-up information. You need to disable this, you can use raspi-config for this
run the following command
> sudo raspi-config
download the AnalopPi client
wget https://raw.githubusercontent.com/sankarcheppali/Atmega8/master/AnalogPi/analogPi.py
Usage Instructions(Atmega 8):
All the required files are available here . You can create a Atmel Studio project and burn the HEX code to Atmega8.
Any Atmega8 development board will work with the code,only requirement to interface with the Raspberry PI is 3v3 converter at UART(you can use this program with any computer with a Serial bridge).