Interfacing between arduino uno and Raspberry pi

Interfacing between arduino uno and Raspberry pi

 

Python setup tools installation

     1. First of all we need to install python setup tools in raspberry pi

     2.Go to this link https://pypi.python.org/pypi/setuptools/0.6c11

     3.Select the setuptools-0.6c11-py2.7.egg(md5) click on it and save file.

     4.Open to the LxTerminal go to the exact saved location of your setuptools-0.6c11-py2.7.egg and type the following command

      5.sudo sh setuptools-0.6c11-py2.7.egg and press enter Python setup tools are installed very quickly

 Pyserial installation

  1. To do serial communication you need to install pyserial-2.6.tar.gz

  2. Go to link https://pypi.python.org/pypi/pyserial/2.6

  3. Select Pyserial-2.6.tar.gz and select save file and ok.

  4. Now the compressed folder is automatically saved in downloads of pi.

  5. Select to Extract to and make a temp folder to save extracted folder in the archive manager

  6. Go to location of extracted folder in LxTerminal and do the following steps

  7. Open the pyserial-2.6 folder by cd pyserial-2.6

  8. Type sudo python setup.py install

  9. Now your pi can use serial communication

 Arduino IDE installation

  1. We can program our arduino via Arduino IDE also

  2. To install Arduino IDE type the following commands in Lxterminal

      • sudo apt-get update

      • sudo apt-get install arduino

  1. Finally answer Yes (Y) to allow installation

  2. Now connect your arduino uno board with raspberry pi using usb cable adapter

 Nanpy Installation

       1.Nanpy is a firmware which is used to allow communication with Raspberry pi with Arduino via serial(Uart communication).

       2.Go to the below link

        https://pypi.python.org/packages/source/n/nanpy/ and select nanpy-v0.8.tar.gz

        3.Click to save file and make a temp folder and select to extract it in archive manager

        4.Open nanpy folder by this command in Lxterminal cd nanpy -0.4

        5.Under that open cd firmware

        6.Then type make boards command in LxTerminal(you can see a list of boards)

        7.Type export BOARD=uno(Because we are connecting arduino uno)

        8.Then type make command to make the hex file to upload

        9.Finally type make upload to upload the appropriate hex file to arduino

        10.Move back to nanpy folder by cd command

        11.To install type sudo python setup.py install

 To test the connection

  1. Open the Lxterminal and type sudo idle and select File->New window-> Type the given code and save it with .py extension

  2. Connect a 470 ohm resistance in series with LED +ve and LED-ve is connected to ground.

  3. Select Run->Run module F5 to run the module

  4. You see the LED which is Blinking “5” times

 Module to Blink the LED

 #!/usr/bin/env python

 from nanpy import Arduino

from nanpy import serial_manager

serial_manager.connect('/dev/ttyACM0')

 # serial connection to Arduino

 from time import sleep

 LED =10

# LED on Arduino Pin 10 (with PWM)

Arduino.pinMode(LED, Arduino.OUTPUT)

print"Starting"

print"5 blinks"

 for i in range(0,5):

 Arduino.digitalWrite(LED, Arduino.HIGH)

 sleep(0.5)

 Arduino.digitalWrite(LED, Arduino.LOW)

 sleep(0.5)

 Summary

Python setuptools

Pyserial 2.6

 Nanpy 0.8

 Arduino1.0.1

 Note:

  • Please install the specified version

  • Donot install the latest version to avoid malfunction of interfacing

  • Install nanpy when ever the arduino firmware is corrupted

  • Now you can program your arduino board from arduino IDE itself

 

 

 

You are here: Home Document Embedded Systems Interfacing between arduino uno and Raspberry pi