webbmoncure
Posts: 3
Joined: Thu Oct 04, 2012 12:43 am

Arduino Sensor Arrays - Serial Communication Method?

Thu Oct 04, 2012 1:03 am

Hello Rasperry Pi world! I have been working with Arduino and voraciously reading and attempting to code my own programs in C++ with a touch of QT. When the Raspberry Pi came along I was extremely excited because it presented a way for me to create a more enhanced GUI than is offered through programmable LCD's and such. While I am slightly comfortable navigating Debian, I was a non-GUI user on the C-64 as a child, and then a DOS user until the final Windows shell release). I'm comfortable cutting, pasting, and grabbing a reference book to solve most coding, config, and programming problems.

My issue is this - I understand the strengths and weaknesses of both the Arduino system and the RPi. I believe that could unload a lot of processing effort undertaken by the Pi by utilizing an Atmel / Arduino DIP to read from my various 5v and 3.3v sensors, both analog and digital. It would make sense to then transmit the data to the RPI for a graphical presentation and friendly user interface. But what protocol is best for my end use?

I have one component in my system that would require a real-time non-stop data transmission, and that would be my tachometer. The others could be polled every 1 to 1.5 seconds or so by a master device. I was thinking an I2C setup for the lion's share of my sensors attached to the Arduino being managed directly through one slave device - the Arduino.

So this is what I was thinking, to restate.

1-2 sensors directly wired to the PI
10 on the mega, these are not as time sensitive but have to be reliable.

What are anyone's ideas on the wiring? Even bluetooth for accessorial sensors? This is for a fantastic little vehicle I'm restoring - rather than pay for someone else's time in the form of marked-up, plastic-injection-mold-housed-sensors from automotive OEM's, I want to add all the accessories I need through an RPI / Arduino (and traditional relay wiring system for the main components) system.

Cheers,

Webb

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Arduino Sensor Arrays - Serial Communication Method?

Thu Oct 04, 2012 8:16 am

You have a variety of inputs (sensors). Each one will generate some number of bytes of data per second at the rate you wish to have the data refreshed. How many bytes of data per second do you expect to arrive at the Pi?

Real-time implies that at least some data must be processed in a timely fashion. How many updates of such data will happen per second and how quickly must that data be processed?

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Arduino Sensor Arrays - Serial Communication Method?

Thu Oct 04, 2012 9:37 am

Personally (but mostly because it's what I do!) I'd use serial. I write a really trivial protocol for my own stuff to simply extend the Pi's GPIO to Arduinos - the protocol jus allows remote control of the arduino by the Pi (or other Linux host).

I've also used the XRF/URF modules to communicate from a Linux host to a remote arduino too - and the URF module works OK on the Pi.

So if you can use serial, then it's somewhat easy. (even serial via USB - which is easier than serial via the Pi's on-board comms port as there is no votlage issues)

However you may want the ATmegas to do more than just be dumb terminals, but even then it's not hard to devise higher-level commands to send to the devices to get them to do something.

My (somewhat unfinished) stuff is here if you want to look: https://projects.drogon.net/drogon-remote-control/

-Gordon
--
Gordons projects: https://projects.drogon.net/

Azuria.dk
Posts: 8
Joined: Tue Jul 24, 2012 9:15 pm

Re: Arduino Sensor Arrays - Serial Communication Method?

Thu Oct 04, 2012 9:25 pm

gordon@drogon.net wrote:Personally (but mostly because it's what I do!) I'd use serial. I write a really trivial protocol for my own stuff to simply extend the Pi's GPIO to Arduinos - the protocol jus allows remote control of the arduino by the Pi (or other Linux host).

I've also used the XRF/URF modules to communicate from a Linux host to a remote arduino too - and the URF module works OK on the Pi.

So if you can use serial, then it's somewhat easy. (even serial via USB - which is easier than serial via the Pi's on-board comms port as there is no votlage issues)

However you may want the ATmegas to do more than just be dumb terminals, but even then it's not hard to devise higher-level commands to send to the devices to get them to do something.

My (somewhat unfinished) stuff is here if you want to look: https://projects.drogon.net/drogon-remote-control/

-Gordon
Hi Gordon.
Your blog seems broken, i tried posting this comment on it, but kept getting a javascript error.
Hi.
Just stumbled upon your Arduino sketch, from the RPi forum.
I can't seem to find how your sending the data to the Arduino.
I have seen another, who made a complete thing, which sends text via echo
E.g. echo -e "This is the text I want to display on my Arduino \r\n" > /dev/ttyAMA0
Is this the same way, yours is meant to be used?

Kind Regards
OP: Sorry for hijacking.

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Arduino Sensor Arrays - Serial Communication Method?

Fri Oct 05, 2012 5:15 am

Azuria.dk wrote:
gordon@drogon.net wrote:Personally (but mostly because it's what I do!) I'd use serial. I write a really trivial protocol for my own stuff to simply extend the Pi's GPIO to Arduinos - the protocol jus allows remote control of the arduino by the Pi (or other Linux host).

I've also used the XRF/URF modules to communicate from a Linux host to a remote arduino too - and the URF module works OK on the Pi.

So if you can use serial, then it's somewhat easy. (even serial via USB - which is easier than serial via the Pi's on-board comms port as there is no votlage issues)

However you may want the ATmegas to do more than just be dumb terminals, but even then it's not hard to devise higher-level commands to send to the devices to get them to do something.

My (somewhat unfinished) stuff is here if you want to look: https://projects.drogon.net/drogon-remote-control/

-Gordon
Hi Gordon.
Your blog seems broken, i tried posting this comment on it, but kept getting a javascript error.
Hi.
Just stumbled upon your Arduino sketch, from the RPi forum.
I can't seem to find how your sending the data to the Arduino.
I have seen another, who made a complete thing, which sends text via echo
E.g. echo -e "This is the text I want to display on my Arduino \r\n" > /dev/ttyAMA0
Is this the same way, yours is meant to be used?

Kind Regards
OP: Sorry for hijacking.
Hm. Blog seems fine to me, but I had to logout and clear all my cookies on it first before I could do a reply - can you email the error message?

To communicate with the sketch I write some software that runs on the Linux side that sends the commands to it - currently it's part of my BASIC interpreter, but I keep mening to strip it out as something a bit more general purpose.

-Gordon
--
Gordons projects: https://projects.drogon.net/

webbmoncure
Posts: 3
Joined: Thu Oct 04, 2012 12:43 am

Re: Arduino Sensor Arrays - Serial Communication Method?

Mon Oct 08, 2012 12:23 pm

Gordon,

Thanks for the feedback. I am probably going with some sort of slave serial communication - and I don't mind the Arduinos being a dumb terminal so to speak.

In my project I have a bootloaded custom pcb controlled by an ATmega 328, and I have an ATMega2560 Mega. I was just hoping that the 2560 could handle alternative communication methods - or those that wouldn't put it in slave mode, i.e. operating more like a DAQ than a microcontroller. The 2560 has so many inputs - like 50 or so - and the lions share of those are digital inputs. I have a number of digital switches as well as digital and analog sensors and digital outputs.

The issue is that some of the switches need real-time outputs (they drive power fet or relay arrays), and the tachometer also needs some sort of real-time visibility in the vehicle itself as well as speedometer. I'm putting together a list of I/O functions that need priority but I was hoping with the Mega i could feed real time data through a secondary serial output on the board directly to the Pi. The others can be a serial / I2C array.

Any thoughts?

User avatar
scruss
Posts: 3212
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Arduino Sensor Arrays - Serial Communication Method?

Mon Oct 08, 2012 1:00 pm

webbmoncure wrote:what protocol is best for my end use?
Have you looked at Firmata? It doesn't allow for much processing on the Arduino, but has some nice (if somewhat sparsely documented) support code for Processing and Python.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Arbitrader
Posts: 1
Joined: Sat Dec 15, 2012 10:16 am

Re: Arduino Sensor Arrays - Serial Communication Method?

Sat Dec 15, 2012 10:29 am

Is there now a concensus on the best/optimum board and components to use when building a tachometer for interfacing with my R-Pi? That is my next project and would like to get the 'bits' before Christmas if possible. Many thanks...

Return to “Automation, sensing and robotics”