Hi everyone,
I'm trying to get one Arduino Uno to send a signal to another Arduino Uno as part of a parking sensor project.
To do this, I'm using two NRF24L01s with the standard RF42 Library.
Everything was working fine last night, but this morning they stopped working. I've narrowed the problem down to being that the available() method always returns true even when the module is completely disconnected from the arduino which wasn't happening last night.
I've seen a few ways to fix this including soldering a capacitor onto the GND and VCC pins of the RF24 module, which I've sort-of done by using an additional circuit board designed for the RF24 chip which regulates the power just like a capacitor would.
Even when there is a signal being transmitted, it still just captures this "blank" packet of information, so I can't even botch a fix by having it filter out the blank information.
I've tried getting this to work on two Arduino Unos and an Arduino Nano and get the same result. I think it's a software issue rather than a hardware issue since the RF24 doesn't even need to be plugged in.
I've reinstalled the library a few times but again, same result.
Here is the code for the receiving end:
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#define CE 7
#define CSN 8
RF24 radio (CE, CSN);
byte address[6] = "00001";
void setup() {
Serial.begin(9600);
radio.begin();
radio.setPALevel(RF24_PA_MIN);
radio.openReadingPipe(0, address);
radio.startListening();
}
void loop()
{
if (radio.available())
{
int Distance = 5;
radio.read(&Distance, sizeof(Distance));
Serial.println(Distance);
}
}
And here is the code for the transmitter, although I don't think this is relevant at all:
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#include <hcsr04.h>
#define TRIG 2
#define ECHO 3
#define CE 7
#define CSN 8
RF24 radio (CE, CSN);
byte address[6] = "00001";
HCSR04 sensor (TRIG, ECHO);
int Distance;
int delayTime;
void setup()
{
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_LOW);
radio.stopListening();
}
void loop()
{
Distance = sensor.distanceInMillimeters();
Serial.println("SENDING: " + (String)Distance);
radio.write(&Distance, sizeof(Distance));
delay(500);
}
Thanks in advance for any help I receive!