Pages: [1]   Go Down
Author Topic: 2nd Arduino to handle some tasks - Serial communication?  (Read 268 times)
0 Members and 1 Guest are viewing this topic.
Newcastle, NSW, Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 33
Just a mechanic
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good morning all.

I currently have a project which is utilising a Mega, and it has all the PWM-capable pins in use. They are driving 12 sets of outputs and are written depending on 12 variables;
int circuit1 ~ int circuit12.

It also has 12 digital pins assigned to a relay used in conjunction with each PWM output, and a further 12 used to monitor switches.
It also is using I2C for a RTC module.

I would like to add ethernet so I can have a web interface, and an LCD for visual feedback to the project.
I can't use the ethernet shield directly, as the pins it uses are in use by PWM tasks.
Can the ethernet shield be used on pins other than the standard ones (i believe 10, 11, 12 ,13?)

I can add an I2C LCD so that shouldn't be an issue.

My question is, can I use, say an Arduino Uno, to handle the ethernet tasks, the web page, and the LCD, and use a serial link between the two Arduinos (Mega and Uno) to transfer the data? This would free up some resources on the Mega, and reduce the clutter in the code on the Mega a little.

The web interface ideally would display the values for circuit1 - circuit12, and be able to change them, or alternately run sub routines in the sketch on the Mega which would change them.

In this case, the Uno would have to be able to read the current state of the variables from the Mega, and then if requested, either change those values or run a sub routine based on input from the web page.
The LCD could also be moved over to the UNO, and this would just be displaying the values in a rolling loop kind of thing. .
i.e. Circuit 1 = 200, wait, then clear screen, Circuit 2 = 155, etc etc.

I can work out the display and the web interface on the Uno, but I've never tried to communicate between 2 Arduino's before so I'm not sure how to go about getting the values from the Mega, or sending back a request to change a value or run a routine. Or how to take an input from the webpage running on the Uno, and send that to the Mega.

The boards can be physically located near/next to each other so distance isn't a concern.

Thanks for any guidance.
Logged

Offline Offline
God Member
*****
Karma: 3
Posts: 716
a, b = b, a+b
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


I at one point set up 4 arduinos to talk with each other and had it running within a very short time. Sadly I no longer have the code, but you should be able to figure it out yourself: http://www.arduino.cc/en/Reference/Wire
Logged


Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can communicate between Arduino boards with Serial, I2C and SPI.

If you use the Uno with Ethernet Shield, and that Uno is doing a lot (like the SD card, and other libraries) you run out of memory very quick. So you could end up with two Mega boards. One for the Ethernet Shield and one for the PWM.

You can make you own serial protocol. I can be very simple.
There are also libraries, like Easy-Transfer, http://www.billporter.info/2011/05/30/easytransfer-arduino-library/
But I don't know if it is up to date. I have not use it.
Logged

Pages: [1]   Go Up
Jump to: