Hello,
I have the following situation:
I have a project in which I have an Arduino Mega controlling a 16Channel-Relay-Module. I have an external 5VDC power supply powering the relays as well as a Raspberry Pi which in turn powers the Arduino through an USB-connection.
I have connected all the GNDs together (RPi, Arduino, relay, ext. power supply).
The relay module is something like this and is active low:
The idea is to use the relays to power 15 door openers. The openers also have limt switches which are also connected to the Arduino.
I then have the Raspberry Pi run a GUI I wrote through witch you can activate the door openers by sending a serial message to the Arduino. There are 15 differnt limit switches connected to the RPi for other purposes.
The problem is this:
When I power the Arduino through my computer everything works as intended.
But when I power the Arduino through the RPi USB connection as soon as the power is turned on, the relays switch on and off like crazy.
Here is an example how I control the relays (note, that the RPi isn´t sending anything to the Arduino as of now, so I didn´t include the code here):
int nb1 = 23;
void setup() {
// put your setup code here, to run once:
digitalWrite(nb1, HIGH);
pinMode(nb1, OUTPUT);
digitalWrite(nb1, HIGH);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available() > 0){
int com = Serial.read();
if (com == '1'){
digitalWrite(nb1, LOW);
delay(100);
digitalWrite(nb1, HIGH);
}
}
}
I also tried disabling the serial Connection (commenting out serial.begin and basically everything in the loop so only the setup remains) to make sure, that the RPi wasn´t sending anything on its own, but no luck.
This is my second thread I think, so please be gentle
Thank you for any help you might provide
konni941