---

Sunday, April 29, 2012

Raspberry Pi and Arduino

The Raspberry Pi is creating quite a storm of interest. I have just got mine and one of the first things that I wanted to try was to get it talking to an Arduino over USB using Python.

.. and you know what? It proved to be a lot easier than I expected. This is mainly because, after all, despite its diminutive price tag, the Pi is just a Linux box. I got communication working both ways, with the Arduino sending 'Hello Pi' to the Pi and at the same time, testing for a digit coming in. When it receives a digit, it flashes the number of times indicated by the digit.

Arduino

Let's start with the Arduino end. I used an Arduino Uno and Arduino software version 1.0. I haven't tried an older board, but I suspect the FTDI generation Arduinos before the Uno may have trouble with USB.

Here is the sketch - paste it into a new Arduino IDE window and load it up onto your Arduino using your regular computer.

Step 3. This is a gziped tar file. Which needs unzipping and untaring. To unzip it open a Terminal, which you will find from the 'start menu' under 'accessories'. Now paste the following commands into it.cd /home/pi/Desktop/othergunzip pyserial-2.5.tar.gztar - xvf pyserial-2.5.tar

I found the article really interesting. I was wondering whether you could use the same/similar commands to read an analogue input off the arduino from the pi? Esentially what i would lke to do is use the pi for back end data logging/processing.

I found the article really interesting. I was wondering whether you could use the same/similar commands to read an analogue input off the arduino from the pi? Esentially what i would lke to do is use the pi for back end data logging/processing.

run step 1 and then my browser (midori),crashes when I visit this page from my raspi.Raspberry with debian and midori as a browser, the log says "out of memory", I have also installed apache, php, Mysql.

Thank you for this article! It inspired me to try and connect the Raspberry Pi and Arduino using the GPIO UART on the Raspberry Pi and SoftSerial on two other pins on the Arduino. This way you still have the USB available for your serial monitor to do debugging with.

I can open the USB port apparently, but when I get to the read or write, it complains than the module (serial???) doesn't have an attirbute -- doesn't apparently know how to read or write. I'm following your example, but something seems to be haywire. Thanks! /paul W3FIS

My Raspberry PI Doorbell server written with Python, activates randomly - the detection of the button press makes the voltage on the switch go from 1 down to 0 in small increments - the code looks for change rather than either 1 or 0 - is the code at fault or do you think I need a shield - or go for something like This

Your article was just what I was looking for: I have mounted my Arduino to a 4-wheel chassis, connected my Pi to the Arduino and am now able to control the motors via SSH in a python shell.

Now the next step for me is to make a python script that I can call with an argument so that the argument is sent to the Arduino, so that I do not have to go into a python shell to control it but I have encountered a problem:

When I execute the script, the return value of ser.write() is 1, but the Arduino does not react (although the RX LED blinks).

Your article was just what I was looking for: I have mounted my Arduino to a 4-wheel chassis, connected my Pi to the Arduino and am now able to control the motors via SSH and a python shell.

Now the next step for me is to make a python script that I can call with an argument so that the argument is sent to the Arduino, so that I do not have to go into a python shell to control it but I have encountered a problem:

When I execute the script, the return value of ser.write() is 1, but the Arduino does not react (although the RX LED blinks).

Hi. I should remind myself every time I have a problem that I actually know very little.

This article is now in the "Programming the Raspberry Pi" book by Dr. Monk and that book is what I am using to get going with the RPi. I had the following error message when I tried to execute everything in the IDLE editor:************************8>>> import serial>>> ser = serial.Serial('dev/ttyACM0', 9600)

Traceback (most recent call last): File "", line 1, in ser = serial.Serial('dev/ttyACM0', 9600) File "/usr/local/lib/python2.7/dist-packages/serial/serialutil.py", line 260, in __init__ self.open() File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 276, in open raise SerialException("could not open port %s: %s" % (self._port, msg))SerialException: could not open port dev/ttyACM0: [Errno 2] No such file or directory: 'dev/ttyACM0'***************************I searched the RPi forums with nothing useful to me as I still know little about using Linux. Then I searched Yahoo! using the full error message and came across the following link:http://www.tracemyworld.com/site/en/support/documentation.html?start=7

I found that using the ls /dev/ACM0 command did not give me what I wanted but then later tried just this:ls /dev/which showed me that there was a USB device present where there was none when the Arduino was not plugged in.

At this point, it is helpful to know I am using and Arduino Duemilanove and a Freeduino SB, V 2.l which is pretty much the same thing as the Duemilanove. Once I figured the new USB device listing out, I started experimenting with the code and using two Arduino's. The LEDs blink so quickly so I slowed down the blinking. When I started to enter in numbers with more than 1 digit, I found out the Arduino sketch will blink each digit in series - fun!

Dr. Monk, if you have a forum or other venue for posting the differences that people have with hardware and software, it would be appreciated if you posted a link. I have not found it yet. The RPi forum would be a good place to search for that - I might start a thread.

hi mr.simoni have a issue with my arduino basically i use a arduino NG with atmega8 controller and for a few months i was able to upload programs but this week it shows soe errors likeArduino: 1.5.6-r2 (Windows 8), Board: "Arduino NG or older, ATmega8"

In file included from C:\Users\Aditya\arduino1.6\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp:32:C:\Users\Aditya\arduino1.6\Arduino\hardware\arduino\avr\cores\arduino\/HardwareSerial_private.h: In member function 'void HardwareSerial::_rx_complete_irq()':C:\Users\Aditya\arduino1.6\Arduino\hardware\arduino\avr\cores\arduino\/HardwareSerial_private.h:98: error: 'UPE' was not declared in this scope

This report would have more information with "Show verbose output during compilation" enabled in File > Preferences.even if i just hit complie without any program it shows the error could you please elp me ......my email id is adithyaad96@gmail.com

hi simon i was using my arduino NG with atmega 8 for two months but for a week shows some errors likeArduino: 1.5.6-r2 (Windows 8), Board: "Arduino NG or older, ATmega8"

In file included from C:\Users\Aditya\arduino1.6\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp:32:C:\Users\Aditya\arduino1.6\Arduino\hardware\arduino\avr\cores\arduino\/HardwareSerial_private.h: In member function 'void HardwareSerial::_rx_complete_irq()':C:\Users\Aditya\arduino1.6\Arduino\hardware\arduino\avr\cores\arduino\/HardwareSerial_private.h:98: error: 'UPE' was not declared in this scope

This report would have more information with "Show verbose output during compilation" enabled in File > Preferences.