Hey people,
im trying to make a raspberry and an arduino communicate over 433 mhz modules.
the arduino will use the receiver while the raspberry will use the transmitter.
the transmitter is definately working because i can control a remote outlet.
the problem is the receiver. it doesnt receive anything. i use the rcswitch library.
i checked whether the module is broken by using another one but it doesnt work either.
i check its functionality by making output onto the serial monitor.
i also used a tv remote but there is no output.
here is my code for the receiver part:
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
}
void loop() {
if (mySwitch.available()) {
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();
}
}
i did exactly the same pin connection like in this tutorial:
https://funduino.de/nr-03-433mhz-funkverbindung
i know its german but you can see pictures.
any guesses why this is not working?
eniddelemaj:
i did exactly the same pin connection like in this tutorial:
Nr.03 - Funkverbindung über 433mhz mit dem Arduino - Funduino - Kits und Anleitungen für Arduino
It is always better to post a picture of your actual setup.
How exact do you mean? I don't know your level of experience, but if you are using a full sized breadboard similar to the one shown in the Fritzing, then you need to be aware that some breadboards have a split in the long power rails, right in the middle. In other words, you need to check that power is actually being delivered to your receiver module.
Are you using an Arduino UNO? Different Arduino models have Interrupt 0 on different pins.
arduarn:
It is always better to post a picture of your actual setup.
How exact do you mean? I don't know your level of experience, but if you are using a full sized breadboard similar to the one shown in the Fritzing, then you need to be aware that some breadboards have a split in the long power rails, right in the middle. In other words, you need to check that power is actually being delivered to your receiver module.
okay im sorry. i forgot to mention which picture i mean.
this is the way i did the connection.
link to picture:
johnwasser:
Are you using an Arduino UNO? Different Arduino models have Interrupt 0 on different pins.
im using a genuino uno.
eniddelemaj:
im using a genuino uno.
That looks more like an Elegoo Uno R3, not a Genuino/Arduino...
Your wiring looks reasonable wrt to the instructions you have been using.
A quick internet search tells me that those modules are bargain bucket modules with corresponding quality. This blog suggests that the TX modules are normally usable, but the RX are trash. I notice that the modules are often sold as multipacks, which suggest that you might need all six receivers to find one that works.
I suggest doing a few internet searches yourself to see if you have any of the common problems associated with the receivers and if there are any solutions, other than buying a different module. I noticed Amazon reviews indicating bad solder joints on multiple modules (solder bridges) which would be repairable. Someone also suggested that some modules have some incorrect spec resistors that make them useless.
You could also try a simpler sketch, one that just reads the data pin with an analogue input to see if there is any life at all in the module.
arduarn:
That looks more like an Elegoo Uno R3, not a Genuino/Arduino...
Your wiring looks reasonable wrt to the instructions you have been using.
A quick internet search tells me that those modules are bargain bucket modules with corresponding quality. This blog suggests that the TX modules are normally usable, but the RX are trash. I notice that the modules are often sold as multipacks, which suggest that you might need all six receivers to find one that works.
I suggest doing a few internet searches yourself to see if you have any of the common problems associated with the receivers and if there are any solutions, other than buying a different module. I noticed Amazon reviews indicating bad solder joints on multiple modules (solder bridges) which would be repairable. Someone also suggested that some modules have some incorrect spec resistors that make them useless.
You could also try a simpler sketch, one that just reads the data pin with an analogue input to see if there is any life at all in the module.
okay that sound like this is the problem. i didnt even think about that those receivers may be broken because the transmitter is working fine. But yes i also found same feedbacks.
You could also try a simpler sketch, one that just reads the data pin with an analogue input to see if there is any life at all in the module.
what exactly should i do? if i understood that correctly i have to connect the data pin of the module to an
analog input of the arduino. Then i just check if there comes input from the module. is that right?
eniddelemaj:
what exactly should i do? if i understood that correctly i have to connect the data pin of the module to an
analog input of the arduino. Then i just check if there comes input from the module. is that right?
Stick something like Serial.println(analogRead(A0)); inside an otherwise empty loop() and open up Tools->Serial_Plotter in the IDE menu. See if there is any action whizzing past in the graphic. See if anything changes when you transmit.
(Choosing a high baud rate for the Serial.begin() would also be advantageous.)
if i understood that correctly i have to connect the data pin of the module to an
analog input of the arduino.
No, connect to a digital input (or use an analog input as digital).
You need antennas on those radio modules. Most people use 17 cm of straight wire.
Hey sry for responding this late.
So i checkd if there is any life in that module by looking onto the serial plotter.
It shows that its working.
But i found a strange problem.
I tried it again with rcswitch and i thought that it might be the range thats too short.
i started to send codes via the raspberry continiously with a while loop.
In the Arduino sketch i wrote that the LED_BUILTIN has to light for 1 second every time the arduino
received a signal. if not, the LED_BUILTIN dont have to light.
I connected the arduino with a battery and went near the raspberry. It worked!
The led lighted for one second after every signal that it received.
Well, i thought this cant be true so i walked out of range till the led didnt light anymore. it worked too.
I went into the range again and it lighted again. Still i couldn believe this so i stopped the sending loop.
The led went out. i started the loop and the led lighted.
So the range is very wide. It worked for about 3-5 meters.
The strange thing is that it is only working when im connecting the arduino to battery. it is not working when it is connected to computer. But this is kind of essential for my project because i want to read the values that were received.
Does anyone know what to do here?
Here is my code for receiving:
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN,OUTPUT);
mySwitch.enableReceive(0);// Receiver on interrupt 0 => that is pin #2
for(int i = 0; i < 3; i++)
{
digitalWrite(LED_BUILTIN,HIGH);
delay(750);
digitalWrite(LED_BUILTIN,LOW);
delay(750);
}
Serial.println("Ready");
}
void loop() {
if (mySwitch.available()) {
digitalWrite(LED_BUILTIN,HIGH);
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();
delay(1000);
}
digitalWrite(LED_BUILTIN,LOW);
}
That's good progress and good news. If it works on a battery but not USB, then I would assume that the problem is either too little power (USB port a bit weak maybe) or interference on the USB supply.
As a next test I would suggest testing your new sketch with the hardware powered from a phone charger.
arduarn:
That's good progress and good news. If it works on a battery but not USB, then I would assume that the problem is either too little power (USB port a bit weak maybe) or interference on the USB supply.
As a next test I would suggest testing your new sketch with the hardware powered from a phone charger.
Youre a hero
Ive never thought that the usb port gives too less power but that was the problem!
i connected arduino with the 9v battery and the usb port. Now the sensor is working
normally and i can read the signals! Thanks to everyone that helped!