Sending Data from MINI to MEGA Relay Control

Hello,

First you should all know that I am new with programming arduino or any IC Boards

What I am trying to do is generate a different value on MINI OUTPUT it from D8 Pin to MEGA as INPUT to D8 Pin and base on the value (WORD or NUMBER)generated from MINI to turn ON and OFF Relay connected to MEGA

I am not sure if this even possible !!! I know I can connect them both with Serial and exchange data but I am planning to connect more then 1 MINI and as far as I know there are only 4xTX and RX Pins on MEGA and that won’t be enough for my project

Or might be an alternative way to this

Thank you

sounds like you want the Mega to power a relay based on the input from the Mini.

The Mini will set the output of a pin HIGH/LOW, the mega will monitor the pin connected to the Mini and power the relay accordingly.

the code on the Mega can use arrays to associate input pins with relay control pins allowing multiple Minis or any device that can toggle an input pin to control a relay vai the Mega

it would seem a serial connection would be overkill, unless there are other operations, but more that one pin can be connected between each Mini and Mega and the Mega has lots of I/O

Here is the simple code
I have connected both to D8 with Jumper wire

Schematic - see attached File

For MINI Sender

int Signal = 8;

void setup() {
  Serial.begin(9600);
  pinMode (Signal, OUTPUT);

}

void loop() {
  digitalWrite(Signal, HIGH);
  Serial.println("Signal On");
  delay (10000);
  digitalWrite(Signal, LOW);
  Serial.println("Signal Off");
  delay (10000);

}

For MEGA Receiver

int Signal = 8;
int R1 = 22;

void setup() {
  Serial.begin(9600);
  pinMode (Signal, INPUT);
  pinMode (R1, OUTPUT);

}

void loop() {
  if (digitalRead (Signal) == HIGH){
    digitalWrite (R1, HIGH);
    Serial.println("LIGHT ON");
  }
  else {
    digitalWrite (R1, LOW);
    Serial.println("LIGHT OFF");
  }
}

The Mini will set the output of a pin HIGH/LOW, the mega will monitor the pin connected to the Mini and power the relay accordingly.

Yes that’s what I did, but I need to be more then just HIGH/LOW I need to send different number or word and base on the that MEGA will turn ON/OFF different relay and I am not sure if the way I connected them MINI Pin D8 <-> MEGA Pin D8 that’s all I can do just HIGH/LOW

Thank you

sorry if this isn't helpful. not sure what "different number or word" implies.

since the Mega has many more I/O pins than a Mini, you could probably connect all the Mini pins from several Minis to one Mega. The Mega would need to monitor all the pins from each Mini to determine what to do.
If each pin from a Mini represents a relay that needs to be turned on/off, more than one Mini could control the same relay if you OR the corresponding pin from all Minis that can control a specific relay. In other words, if any Mini set the corresponding pin HIGH the relay is turned on.
~~if this won't work, you could use multiple bits from a Mini to send a command. 4 pins could be used to send one of 16 commands. ~~

Hello

Let say I have connected on MINI humidity sensor and I want on 40% to turn on relay1 and when get to 80% to turn off relay1 and turn on relay 5 and 6, but relays are controlled by MEGA and I have connected

MINI Pin D8 to MEGA Pin D8 only

Is this possible with this connection ???

Thank you

Just quick question :

If I connect MINI to MEGA with Serial RX/TX What is the max wire length possible ???

xlameee:
I have connected both to D8 with Jumper wire

You also need a GND connection between the two boards.

...R

Robin2:
You also need a GND connection between the two boards.

...R

Yes of course sorry