433Mhz problems (rc-switch) on Leonardo

Hello, i am developing a full home automation using separate devices connected via 433Mhz antennas (see link for exact antenna devices)

I already tested a set of antennas using an Orange PI hardware and (GitHub - apiel/rcswitch: Port of RCswitch for any kind of GPIO module (without WiringPi).) software and works great!

But the problem comes when i try to use my Arduino Leonardo device, thus it receives the signal from the PI device, it does not send the signal correctly.

Symptoms:
-The receiver receives the codes sent from the 'PI' but as a different protocol (sent prot. 1 received prot. 5)
-At (GitHub - ninjablocks/433Utils: 433Kit is a collection of code and documentation designed to assist you in the connection and usage of RF 433MHz transmit and receive modules to/with your Arduino and Rapberry Pi.) receive demo example says interrupt 0 => that is pin #2, but instead it only works at pin #3
-If i put a led at the transmitting pin, i can see the pulses lighting up.

Already tried:
-Modifying the transmit pulse delay similar to received values.
-Different pins.

So, i cannot receive data. :cry:

Antenna devices: Pagina non trovata - Università degli Studi di Trieste

Any ideas? :confused:

At (GitHub - ninjablocks/433Utils: 433Kit is a collection of code and documentation designed to assist you in the connection and usage of RF 433MHz transmit and receive modules to/with your Arduino and Rapberry Pi.) receive demo example says interrupt 0 => that is pin #2, but instead it only works at pin #3

That example simply calls the device "Arduino". Without a specific type that usually means "Arduino UNO" and on that type interrupt #0 is on pin 2 but on the Leonardo interrupt #0 is on pin 3.

Is it possible that you assumed some other stuff from a description meant for the UNO and therefor did it wrong for the Leonardo?

Post the code you actually use (don't forget the code tags!) and provide a wiring diagram of your setup.

Sorry i didn't answer earlier, I was really busy.

The wiring is as follows at the attachment (the power is set to bath using an Y).

Working receive code:

#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #3
  Serial.print("Boot ok ");
}
void loop() {
  Serial.println("Listen ok ");
  delay(500);
  if (mySwitch.available()) {
    int value = mySwitch.getReceivedValue();
    if (value == 0) {
    Serial.print("Unknown encoding");
  } else {
    Serial.print("Received ");
    Serial.print( mySwitch.getReceivedValue() );
    Serial.print(" / ");
    Serial.print( mySwitch.getReceivedBitlength() );
    Serial.print("bit ");
    Serial.print("Protocol: ");
    Serial.println( mySwitch.getReceivedProtocol() );
    mySwitch.resetAvailable();
  }
  }
}

Sample output (transmitted from pi 1 time protol 1 :confused: ):
Listen ok
Received 123 / 24bit Protocol: 5
Listen ok
Received 123 / 24bit Protocol: 5
Listen ok
Received 123 / 24bit Protocol: 5
Listen ok

Non working transmit code:

#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();

void setup() {
Serial.begin(9600);
 
  Serial.print("Boot ok ");
  
  mySwitch.enableTransmit(10);

}

void loop() {
  Serial.println("Send ok ");
  delay(500);
  mySwitch.send(1234,24);
}

I see both (arduino and pi) using same library, it seems it must work... but don't :sweat_smile:

Any idea?

It works at <10cm range...

Do I interpret your wiring diagrams correctly? You want to establish a two-way communication using these 433MHz modules? These are thought for a strict one way communication where the code is repeated as long as some remote control button is pressed. I don't know if you get this reliable enough to be used as as serial radio communication device.

If you look at the code it explicitly depends on getting the code repeatedly. Only under perfect circumstances where no noise is on the air you get each transmitted byte correctly.