Go Down

Topic: RF relay from 2 places (Read 114 times) previous topic - next topic

christophe195

Hello guys,

i have a room with 2 doors but on one dore we have a light switch, the distence between the doors is 11 meter. Now i want to make 2 same arduino boords with:

1 arduino nano
1 push button
1 rf TX
1 rf RX
1 relay
1 RG led

the 2 boards are wired the same but i do not get the Radio Ferquentie working. The connections are


transmitter
data = D12

Receiver
data = D11

i use this code http://randomnerdtutorials.com/rf-433mhz-transmitter-receiver-module-with-arduino/ bit i do not get something on my terminal.

is it the nano?

Greathings

PaulS

Quote
is it the nano?
Or the code you didn't post or the fact that you do not have the radios connected correctly. You do have to connect more than just the data  pin.

You have not provided near enough information for us to determine what is wrong.
The art of getting good answers lies in asking good questions.

christophe195

Sorry, the RF vcc and ground pins are connected right that's the reason that i did not post them.

The code is:

Transmitter:
Code: [Select]
#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile

RH_ASK driver(2000,11,12,8,false);

void setup()
{
    Serial.begin(9600);   // Debugging only
      pinMode(6, OUTPUT);      // sets the digital pin as output
    if (!driver.init())
         Serial.print("init failed");
}

void loop()
{
    const char *msg = "Hello World!";
    driver.send((uint8_t *)msg, strlen(msg));
    driver.waitPacketSent();
    digitalWrite(6, HIGH);
    delay(1000);
        digitalWrite(6, LOW);

}


Recever:
Code: [Select]
#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile

RH_ASK driver(2000,11,12,8,false);

void setup()
{
    Serial.begin(9600); // Debugging only
    if (!driver.init())
         Serial.println("init failed");
}

void loop()
{
    uint8_t buf[12];
    uint8_t buflen = sizeof(buf);
    if (driver.recv(buf, &buflen)) // Non-blocking
    {
      int i;
      // Message with a good checksum received, dump it.
      Serial.print("Message: ");
      Serial.println((char*)buf);         
    } else {
      Serial.println("Message: No");
    }
}


Sorry for the incomplete post

PaulS

Code: [Select]
      Serial.print("Message: ");
      Serial.println((char*)buf);

buf is NOT a string. The println() function does not know how to print arrays except for NULL terminated arrays of chars. Your array is NOT NULL-terminated (and isn't big enough to be NULL-terminated).

Code: [Select]
RH_ASK driver(2000,11,12,8,false);
What do these magic numbers mean?

Code: [Select]
#include <SPI.h> // Not actualy used but needed to compile
Why? This suggests that you have some SPI device attached, and SPI uses pins 10, 11, 12, and 13, which includes the pins you have the radios attached to.
The art of getting good answers lies in asking good questions.

Go Up