Friday, March 25, 2016

Pi / Aurduino Master/Slave relationship

Today we install Raspberry Pi to Arduino software that lets you turn you add more functionality to your Raspberry Pi by adding all the functionality of the Arduino to your platform. We can do this by utilizing the Raspberry Pi as the master communicator and the Arduino as the slave handler. This would take along time for anyone to do accurately. Thankfully there is already a library that was developed and is kept up on github. It is known as Nanpy. Nanpy makes it easy to write code in python on your raspberry pi using the same library's already developed for the Arduino. It converts your code so that you can easily incorporate pre-writen library's for sensors and actuators on the Arduino so you don't have to write and c++ code.
It can be found at https://pypi.python.org/pypi/nanpy

All I did to install is follow the instructions on this page.
Only difference is that since I am programming my project in python3 rather than python2, I need to point my interpreter to the right install package.
Instead of using: sudo pip install nanpy
I had to use: sudo pip3 install nanpy
sudo is required because some packages in nanpy need root permissions of they will not install properly.

here is all the directions I followed:

sudo apt-get update && sudo apt-get upgrade

sudo apt-get install arduino

sudo apt-get install python3-serial

git clone http://github.com/nanpy/nanpy.git

git clone http://github.com/nanpy/nanpy-firmware.git

pip3 install nanpy

----

Connect your arduino to your pi via usb
open up the arduino ide
in the ide, select file, select open,
open your nanpy-firmware folder
open the Nanpy folder
and select the Nanpy.ino file
now select your port in the arduino ide that the arduino you are using is connected
and upload the sketch.

now from nannpy you import the Arduino library,
and any other library's you intend to use, such as: servo, eeprom, tone, ect.
easy as Pi....pun intended.



No comments:

Post a Comment