433 HZ Receiver blocking 5v relay

I have a project split between two Arduino boards (One MEGA 2560), the other being a Flora). The goal is for the Mega to receive a 433Mhz signal on it's receiver. If the message is received, and matches a pattern, send HIGH voltage to the relay turning it on.

In isolation I've been able to get the components to work. I'm able to receive a message on the Mega, AND I've been able to toggle the 5v relay on a scheduled timer in different code. My problem arises when I attempt to combine the two processes. Below I have isolated the code to where my problem arises.

#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile

RH_ASK driver;
int relayPin = 10;

void setup()
{
  Serial.begin(9600);	// Debugging only
  if (!driver.init())
        Serial.println("init failed");
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, HIGH);
}

void loop()
{
  uint8_t buf[5];
  uint8_t buflen = sizeof(buf);
  driver.recv(buf, &buflen);
}

If I comment out driver.recv, my relay works and I receive power. If I include driver.recv in my code, my relay does not power on. Even if I send it HIGH in the setUp, the relay remains unpowered.

My initial assumption was that the power draw from the receiver was too much and superseding the relay, but the Mega board has multiple 5v ports and each component is plugged into their own port.

I've tried creating a diagram but as I'm new to this, I couldn't find the right tool. I've got my relay on it's own 5v port, own ground port and getting data from port 10. I've got the receiver on the same board, also it's own 5v port, own ground port and sending data to port 11.

I hope I gave enough info. Any assistance is greatly appreciated.

That can't be a true comment. My guess is that your receiver board does use SPI and the SPI select pin happens to be pin 10. Move your relay to a different pin (not any of the SPI pins). Try pin 4 or 5

2 Likes

Comment came from the tutorial I was following. I'm still at that stage of the process.

That appeared to work. Sincerely appreciate the help. Time to go read about SPI I guess. Thanks a bunch.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.