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
-
- Posts: 271
- Joined: Sun Feb 08, 2015 1:13 pm
Re: Using an Arduino as a slave I/O board
Hans,
I hope you are taking care of those voltage differences?
blog.oscarliang.net/raspberry-pi-and-ar ... rial-gpio/
Rich
I hope you are taking care of those voltage differences?
blog.oscarliang.net/raspberry-pi-and-ar ... rial-gpio/
Rich
Re: Using an Arduino as a slave I/O board
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
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
-
- Posts: 8
- Joined: Mon Aug 03, 2015 10:10 pm
Re: Using an Arduino as a slave I/O board
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
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
Re: Using an Arduino as a slave I/O board
If you have created a folder nanpy-0.9, maybe you need to cd to that folder?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
Code: Select all
cd nanpy-0.9
-
- Posts: 8
- Joined: Mon Aug 03, 2015 10:10 pm
Re: Using an Arduino as a slave I/O board
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!
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!
Re: Using an Arduino as a slave I/O board
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... "audaybasheer wrote: I got an error from the command "a = ArduinoApi(connection=connection)". Any advice please!
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
-
- Posts: 8
- Joined: Mon Aug 03, 2015 10:10 pm
Re: Using an Arduino as a slave I/O board
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/
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/
Re: Using an Arduino as a slave I/O board
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...audaybasheer wrote:When I write: from nanpy import ArduinoApi
it showed Traceback (most recent last call): cannot import name ArduinoApi
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
-
- Posts: 8
- Joined: Mon Aug 03, 2015 10:10 pm
Re: Using an Arduino as a slave I/O board
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.
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.
Re: Using an Arduino as a slave I/O board
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.
-
- Posts: 8
- Joined: Mon Aug 03, 2015 10:10 pm
Re: Using an Arduino as a slave I/O board
Many thanks. This is my email "audaybasheer@yahoo.com".
Re: Using an Arduino as a slave I/O board
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.
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.
-
- Posts: 271
- Joined: Sun Feb 08, 2015 1:13 pm
Re: Using an Arduino as a slave I/O board
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 :
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
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)
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
Re: Using an Arduino as a slave I/O board
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
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
Re: Using an Arduino as a slave I/O board
I think class 10 is recommended for performance. I'd start with an Uno clone.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
Re: Using an Arduino as a slave I/O board
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
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
Re: Using an Arduino as a slave I/O board
I have only used the Uno.
Do all Shields work on the Due, or Zero, which operate at 3.3v? Worth checking.
Do all Shields work on the Due, or Zero, which operate at 3.3v? Worth checking.
Re: Using an Arduino as a slave I/O board
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.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
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'.
-
- Posts: 2
- Joined: Sat Nov 12, 2016 5:09 am
Re: Using an Arduino as a slave I/O board
How would do we read voltages using nanpy?
-
- Posts: 271
- Joined: Sun Feb 08, 2015 1:13 pm
Re: Using an Arduino as a slave I/O board
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.
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.
-
- Posts: 271
- Joined: Sun Feb 08, 2015 1:13 pm
Re: Using an Arduino as a slave I/O board
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
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
Re: Using an Arduino as a slave I/O board
The Ciseco LLAP code is still available here