Go Down

Topic: inter-arduino communication (Read 1 time) previous topic - next topic


Hi all, First post on the forum but been using it for info for a while. Brilliant!

Anyway, i'm starting to develop a simple home automation system. so far i've started to look at how i'm gonna send messages to the slave arduino's from the master. So obviously i'm gonna need addressing, and a protocol of some sort. this is what i've got so far, using the messenger library.


// This example sets all the values of the digital pins with a list through a callback function

#include <Messenger.h>
// Instantiate Messenger object with the default separator (the space character)
Messenger message = Messenger();
int LEDpin = 13;
// Create the callback function
void messageReady() {
   int i = 0;
   int tempstr = 0;
   int startBit = 9;
   int userInput[2];
      // Loop through all the available elements of the message
      while ( message.available() ) {
     for(i = 0; i<3; i++) {
           userInput = message.readInt();
       if (userInput[0] == startBit) {
         switch (userInput[1]) {
           case 1:
                 if(userInput[2] <2) {
           case 2:
               Serial.print("Not Understood");
       else {

void setup() {
 // Initiate Serial Communication
 // Attach the callback function to the Messenger

void loop() {
 // The following line is the most effective way of using Serial and Messenger's callback
 while ( Serial.available() )  message.process(Serial.read () );

What do you think? basically i send a "9" as a start bit, then it looks at the next bit to decide where the message is destined, i.e arduino 1 or 2. Then it looks at the last valule to decide what to do. adding another bit on the end could allow for more flexibility. Anyway, is there a better way to do this that using switch/case?

Any info or help will be very gratefully recieved!!!



I suggest using hex values for start bits and so on. Like 0xF0 (use the hex of a wierd ascii character u never use). Hex works faster in computer world. And easier to work with.


ok thanks, how do i send a hex code? is it just a case of sending:


or do i need to do something else?


both 9 and 0xFF are 1 byte of data so I don't agree that one is faster than the other. I do agree with the rest of what Intosia said.

int startBit=9;



Go Up