hansltel
Posts: 5
Joined: Tue Mar 17, 2015 10:40 pm

Re: Using an Arduino as a slave I/O board

Tue Mar 24, 2015 4:35 pm

Hi Rich,

I coupled my RPI and Ardiona directly via wires. This works!

I will try nanpy again the coming weeks. For the moment now I'm using the wired way of working.

Regards,
Hans

richrarobi
Posts: 271
Joined: Sun Feb 08, 2015 1:13 pm

Re: Using an Arduino as a slave I/O board

Tue Mar 24, 2015 11:38 pm

Hans,
I hope you are taking care of those voltage differences?
blog.oscarliang.net/raspberry-pi-and-ar ... rial-gpio/
Rich

hansltel
Posts: 5
Joined: Tue Mar 17, 2015 10:40 pm

Re: Using an Arduino as a slave I/O board

Wed Mar 25, 2015 4:14 pm

Hi Rich,

Thanks for your warning. I'm aware of the different voltages. I use the GPIO pins only as 3.3V output and the Arduino pins only as input.

Regards,
Hans

audaybasheer
Posts: 8
Joined: Mon Aug 03, 2015 10:10 pm

Re: Using an Arduino as a slave I/O board

Sat Aug 29, 2015 5:32 pm

Dear all

I have been working on connecting Raspberry pi with Arduino. I have done the steps mentioned here until:
This creates 2 new folders called nanpy-0.9 and nanpy-firmware-v0.9.
Make a new directory with:
mkdir sketchbook

after that I when I run for example cd nanpy , it showed me no such file or directory. Please if anyone has the right steps to make it work could email me on audaybasheer@yahoo.com

Many thanks in advance

User avatar
B.Goode
Posts: 8049
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Using an Arduino as a slave I/O board

Sat Aug 29, 2015 6:37 pm

audaybasheer wrote:Dear all

I have been working on connecting Raspberry pi with Arduino. I have done the steps mentioned here until:
This creates 2 new folders called nanpy-0.9 and nanpy-firmware-v0.9.
Make a new directory with:
mkdir sketchbook

after that I when I run for example cd nanpy , it showed me no such file or directory. Please if anyone has the right steps to make it work could email me on audaybasheer@yahoo.com

Many thanks in advance
If you have created a folder nanpy-0.9, maybe you need to cd to that folder?

Code: Select all

cd nanpy-0.9
(These forums are a community resource, so my reply is available here, not privately.)

audaybasheer
Posts: 8
Joined: Mon Aug 03, 2015 10:10 pm

Re: Using an Arduino as a slave I/O board

Sat Aug 29, 2015 6:53 pm

Hi Goode,

I have changed the names and the arranged all other files such as firmeware, finally I opend the file called Nanp.ino using /home/pi/sketchbook/nanpy-firmware-0.9.4/Nanpy/Nanpy.ino which is a bit different from what was menstioned on the main post. Anyway, then I compiled this file with Arduino Uno. Later on I tried to run the following code:

from nanpy import (ArduinoApi, SerialManager)
connection = SerialManager()
a = ArduinoApi(connection=connection)
from time import sleep
a.pinMode(10, a.OUTPUT)
print"Starting"
while 1:
a.digitalWrite(10, a.HIGH)
print"ON"
sleep(0.5)
a.digitalWrite(10, a.LOW)
sleep(0.5)
print"OFF"

But I got an error from the command "a = ArduinoApi(connection=connection)". Any advice please!

User avatar
B.Goode
Posts: 8049
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Using an Arduino as a slave I/O board

Sun Aug 30, 2015 5:53 am

audaybasheer wrote: I got an error from the command "a = ArduinoApi(connection=connection)". Any advice please!
Error messages sometimes - but not always - contain useful information about what error condition the program has encountered. It would be useful to post the text of the error message here, instead of simply saying "I got an error... "

If I had to take a guess without seeing the error message, I think it is possible that you do not have rights or permissions to access the serial port that has been assigned by SerialManager. Do you have any more success if you invoke the script via

Code: Select all

sudo python my_nanpy_script.py
Finally: to retain the indentation that is a critical part of the syntax of a python script, python code should be posted in these forums by 'wrapping' it in a pair of [ CODE ] tags, by using the [[ Code ]] button at the top of the message editting screen.

audaybasheer
Posts: 8
Joined: Mon Aug 03, 2015 10:10 pm

Re: Using an Arduino as a slave I/O board

Sun Aug 30, 2015 12:21 pm

When I write: from nanpy import ArduinoApi
it showed Traceback (most recent last call): cannot import name ArduinoApi

my installation is now based on the following website which is very clear. However, I have only the error above.

http://projectpi.org.uk/experiment-use- ... pberry-pi/

User avatar
B.Goode
Posts: 8049
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Using an Arduino as a slave I/O board

Sun Aug 30, 2015 2:46 pm

audaybasheer wrote:When I write: from nanpy import ArduinoApi
it showed Traceback (most recent last call): cannot import name ArduinoApi
That initial step was apparently working at the time of your previous post, or you would presumably have mentioned it. So what have you changed since...

If you have made a fresh start and installed an earlier version of nanpy you will need to use the examples relevant to that version.

Note that at Step 7 of the ProjectPi example the first statement is

Code: Select all

from nanpy import Arduino

audaybasheer
Posts: 8
Joined: Mon Aug 03, 2015 10:10 pm

Re: Using an Arduino as a slave I/O board

Sun Aug 30, 2015 3:17 pm

Yes you are right,
in my first installation when I write the command "from nanpy import Arduino", it doesn't work with me with similar error mentioned earlier. However, the command "from nanpy import ArduinoApi" it was work properly.

When I went to the older version I got the opposite. I went the older version because I believe it well organised and the steps are all clear. The one mentioned in this post, there are serveral steps aren't correct.

tonygo2
Posts: 86
Joined: Sun Aug 28, 2011 2:50 pm
Location: Leicester, UK

Re: Using an Arduino as a slave I/O board

Sun Aug 30, 2015 4:57 pm

I'm still using version 0.8 and it does all I want. I have all the necessary files, some of which are no longer on the Internet. IM me and I will send you the files tomorrow.

audaybasheer
Posts: 8
Joined: Mon Aug 03, 2015 10:10 pm

Re: Using an Arduino as a slave I/O board

Sun Aug 30, 2015 4:59 pm

Many thanks. This is my email "audaybasheer@yahoo.com".

TickTock
Posts: 1
Joined: Mon Oct 05, 2015 5:53 am

Re: Using an Arduino as a slave I/O board

Mon Oct 05, 2015 6:00 am

Hi,
I've successfully used nanpy.v0.9.2 to run my Arduino UNO board with a Raspberry Pi and then with Ubuntu for almost a year. This morning, I updated with sudo apt-get update, and now there is some issue with connecting with the Arduino:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
A.pinMode(3, A.OUTPUT)
File "build/bdist.linux-i686/egg/nanpy/arduinoboard.py", line 110, in wrapper
return _call(cls_name, 0, call_pars, connection=None)
File "build/bdist.linux-i686/egg/nanpy/arduinoboard.py", line 46, in _call
ret = return_value(connection)
File "build/bdist.linux-i686/egg/nanpy/arduinoboard.py", line 18, in return_value
return serial_manager.readline().replace('\r\n', '')
File "build/bdist.linux-i686/egg/nanpy/serialmanager.py", line 92, in readline
s = self._serial.readline()
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 460, in read
raise SerialException('device reports readiness to read but returned no data (device disconnected?)')
SerialException: device reports readiness to read but returned no data (device disconnected?)

Things I've tried that did not change things:
Replacing the USB cord
Another USB port
Reinstalling the firmware on the Arduino
Reinstalling nanpy on the laptop
Using nanpy v0.9.5.1

Interestingly, the Arduino board and nanpy works on another Raspberry Pi just fine. I suspect there's some device error. PySerial communicates with the Arduino board just fine. I just wonder why nanpy no longer works.

richrarobi
Posts: 271
Joined: Sun Feb 08, 2015 1:13 pm

Re: Using an Arduino as a slave I/O board

Thu Nov 05, 2015 8:28 pm

They did change the interface around .9...

I managed to get my program working as posted on 28th Feb - using Jessie..and Nanpy 0.9.5.1 .. took a while as in Jessie they have changed the way to free up the UART port (Note: I am using UART serial, NOT USB).
section pf the code :

Code: Select all

from nanpy import ArduinoApi, SerialManager
from nanpy import Servo
from nanpy.arduinotree import ArduinoTree

try:
   conn = SerialManager(device='/dev/ttyAMA0', timeout= 2 )
   a = ArduinoApi(connection=conn)
except:
   print "failed to connect to Arduino"
   sys.exit(0)
It seems with Jessie (as well as removing from /boot/cmdline.txt) you have to stop the service for ttyAMA0 ->
sudo systemctl stop serial-getty@ttyAMA0.service
sudo systemctl disable serial-getty@ttyAMA0.service
those are NOT links....
The raspisetup doesn't do this stuff for you, although you easily get the impression it does.

Hope this helps...RichR

User avatar
bonzadog
Posts: 235
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: Using an Arduino as a slave I/O board

Sun Dec 20, 2015 4:40 pm

I am going to try this using Jessie and an USB connection.

But why does one need a class 4 SD card? I do not see any reason for that.

I have never used an Arduino, which one is recommended - the Mega, perhaps?
I want extra GPIO and ,very importantly, PWM and ADC.

Many thanks
BD

asandford
Posts: 1997
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: Using an Arduino as a slave I/O board

Mon Dec 21, 2015 11:47 pm

bonzadog wrote:I am going to try this using Jessie and an USB connection.

But why does one need a class 4 SD card? I do not see any reason for that.

I have never used an Arduino, which one is recommended - the Mega, perhaps?
I want extra GPIO and ,very importantly, PWM and ADC.

Many thanks
BD
I think class 10 is recommended for performance. I'd start with an Uno clone.

User avatar
bonzadog
Posts: 235
Joined: Wed Apr 25, 2012 9:40 am
Location: Rietberg/Germany

Re: Using an Arduino as a slave I/O board

Tue Dec 22, 2015 7:21 am

22.12.2015

Thank you for the reply.
Perhaps for the start an "offical" Arduino from a good supplier may be better for
for me . The Due seems to be to top end and offers speed so this is the one I am thinking of.

I'll also want some shields for it and now need to ask if I can access the schields from RPi2.
I think I need then a transfer programmes for the RPi and Arduino to hande request for
GPIO, ADC,PWM and shield access. This must be easily possible, I think I'll need a few Duckduckgo (a Google alternative that doesn't save my data) on this theme.

rpi2<-> Arduino USB or serial?

I had thought of getting the Gerd board, but the Due offers a lot of flexibilty.

Any comments/pointers on this, it may avoid me getting the wrong devices,

Many thanks

BD

gordon77
Posts: 4077
Joined: Sun Aug 05, 2012 3:12 pm

Re: Using an Arduino as a slave I/O board

Tue Dec 22, 2015 7:56 am

I have only used the Uno.

Do all Shields work on the Due, or Zero, which operate at 3.3v? Worth checking.

asandford
Posts: 1997
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: Using an Arduino as a slave I/O board

Tue Dec 22, 2015 10:00 pm

bonzadog wrote:22.12.2015

Thank you for the reply.
Perhaps for the start an "offical" Arduino from a good supplier may be better for
for me . The Due seems to be to top end and offers speed so this is the one I am thinking of.

I'll also want some shields for it and now need to ask if I can access the schields from RPi2.
I think I need then a transfer programmes for the RPi and Arduino to hande request for
GPIO, ADC,PWM and shield access. This must be easily possible, I think I'll need a few Duckduckgo (a Google alternative that doesn't save my data) on this theme.

rpi2<-> Arduino USB or serial?

I had thought of getting the Gerd board, but the Due offers a lot of flexibilty.

Any comments/pointers on this, it may avoid me getting the wrong devices,

Many thanks

BD
I've used both clone and official, and I can't see any differance apart from the price, but at least you'll be safe that everything should work.

There are several ways to have the devices talk, personally I use a modified version of LLAP with Node Red (which also uses Firmata).

rpi2<-> Arduino USB is certainly one of the easiest ways to connect them and has several advantage over pure serial (no level shifting, foolproof connection, and the Pi can also power the Arduino).

The RasWIK is also a something to consider (basically a radio connected Uno + radio for the PI) - and allows the possiblilty of one-to-one, one-to-many, and mesh arrangements (these are available in Maplin without an enormous mark-up as well).

I've found that the Pi+Arduino combination really compliments eachother; the Arduino having more flexible I/O, and the Pi is able to do the processing 'heavy lifting'.

alphaTheta
Posts: 2
Joined: Sat Nov 12, 2016 5:09 am

Re: Using an Arduino as a slave I/O board

Sat Nov 12, 2016 9:22 pm

How would do we read voltages using nanpy?

richrarobi
Posts: 271
Joined: Sun Feb 08, 2015 1:13 pm

Re: Using an Arduino as a slave I/O board

Sun Nov 13, 2016 12:33 am

I haven't looked at nanpy (or arduino) for a while - they aren't very good at documenting their interface (API) - They seem to think we are telepathic - Anyway after half an hour I found this - https://github.com/nanpy/nanpy/blob/mas ... uinoapi.py
line 29 hints at the answer - analogRead - you basically have to read their code (go up a level from that link) to figure it all out. Sorry if that is a bit daunting, but I think that's about the best - Firmata seemed about the same level of cryptic. The alternative I guess is to write your own dedicated sketch for the arduino.

richrarobi
Posts: 271
Joined: Sun Feb 08, 2015 1:13 pm

Re: Using an Arduino as a slave I/O board

Mon Nov 21, 2016 4:10 pm

Quite by chance, I found this:-
http://projectpi.org.uk/tag/nanpy/
There is an example of analogue write in the first section of code. NB, though, that this all uses an old version of Nanpy.
RichR

asandford
Posts: 1997
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: Using an Arduino as a slave I/O board

Wed Nov 23, 2016 12:22 am

The Ciseco LLAP code is still available here

Return to “Interfacing (DSI, CSI, I2C, etc.)”