2

Have a set of Arduinos that need to swap data--for a model rocket launch controller!

How to send 24 bits of info (launch commands) from a "master" Arduino, 12 bits each to two "slave" Arduinos that are 15' to 150' away from the "master.

Each "slave" needs to send 12 bits of info (continuity statii) to the "master."

"Master" <--- 15' to 115' ---> "Slave 1" <--- 10' to 35' --> "Slave 2"

Seems too long for I2C?

5
  • 2
    This can be improved by getting rid of "TiA..." I don't know what "RSO Boxes" and "Pad Boxes" are. I suspect that, if described differently, you'd be drawing answers from a large(r) group of people. If the question comes down to conveying 16 bits worth of information between two Arduinos at low frequency, over a distance of 100 feet, probably a lot of people here can answer that.
    – timemage
    Apr 27 at 2:45
  • do some research about fireworks fire control systems .... perhaps you should be thinking of using multiple pins for issuing a launch command to one launch platform
    – jsotola
    Apr 27 at 3:46
  • 1
    This sounds like a job for DMX512...
    – Majenko
    Apr 27 at 14:50
  • 1
    Hmmm. Had thought about using DMX cabling. But yes, if one has to add a sub-PCB, DMX signaling might be as valid yet simpler than 802.{whatever} networking. Has anyone tied DMX signals to Arduino?
    – LydaRA
    Apr 27 at 16:28
  • Check this link about DMX512 on Arduino: playground.arduino.cc/Learning/DMX
    – Fahad
    Apr 28 at 22:25
1

The best solution would be to use an RS485 adapter connected to each Arduino via serial port. This is a tried and true solution that is perfect for a setup like this and only costs a few bucks of extra hardware per node.

If you can't use additional hardware, you can also create a poor-man's current loop system like RS485 using normal Arduino pins since they are capable of sourcing and sinking 20mA.

With either of these solutions, you can send however much data as you want as long as you have some kind of minimal protocol to serialize it into a sequence of bits on the wire. To send 12 bits, you might just define a start condition as an idle "0" on the wire for a certain period of time, followed by a "1" start bit, followed by you 12 data bits, followed maybe a parity bit or a checksum, and completed by a "1" stop bit.

Check out how, say RS232 or RS485 serialize bits to get an idea of how this works. If you end up using hardware that only supports sending data in 8 bit chunks, then you could, say, send two bytes per data "packet" where each byte has 6 bits of your data, plus one bit that indicates if ths byte is the first group of 6 bits or the second group, and then one bit of parity for error checking.

1

I've got I2C to work reliability between Arduinos with different byte sizes. I have copied the test code below. Note that there is separate code for sending and receiving. It may need to be tweaked but contains the basic idea.

One (or more) Arduinos sends to main I2C controller:

Sender Code:

//sender test

#include <Wire.h>


#include <Wire.h>
#define NUMDATA 4 

byte byteData[2 * NUMDATA]; //= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

//test

void setup()
{
  Wire.begin(3);                // join i2c bus with address #3
  Wire.onRequest(requestEvent); // register event
}

void loop()
{
int aData;  
  for(int i = 0; i < NUMDATA; i++){
    aData = analogRead(i);
    
    byteData[i*2 + 1] = ((aData >> 8)  & 0xFF);
    byteData[i*2] = (aData & 0xFF);
    
   // memcpy((void *)byteData[i*2], (void *) analogRead(i), sizeof(int));
  }
  
}

void requestEvent()
{
  Wire.write(byteData, 2 * NUMDATA);
}

Receiving Code:

#include <Wire.h>

void setup()
{
  Wire.begin();        // join i2c bus (address optional for main controller)
  Serial.begin(9600);  // start Serial for output
}

void loop()
{


  getSenderData();
  
  Serial.println("Hello");
  delay(500);
}

void getSenderData() {
//Gets sensor data for one grid

    //Byte Array to get raw bytes
    byte ICdataAsBytes[8];
    int i = 0;
  
    Wire.requestFrom(3,8);    // request 6 bytes from sending device #2
    
    while(Wire.available())    // sender may send less than requested
        ICdataAsBytes[i++] = Wire.read();

    int *tempData =(int*)&ICdataAsBytes;
    
    for( i = 0; i < 4; i++)
        Serial.println(tempData[i]);
    
}

2
  • I2C at distances up to 115 ft (≈ 35 m) ? Really ? May 2 at 7:48
  • Ah I missed this important note, thanks. Yep, the distance seems way out of spec. May 2 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.