Thanks to everyone who went out of their way to help me !!!
After reading everything and testing it several times, I managed to make it work!
Using CE 9 and CSN 10 - that really wasn't the problem!
And what did I do to work? I just took the Arduino I was using as TX and switch to the RX. Why did it work just by changing the Arduinos? I have no idea, but it worked.
The TX sketch in the OP should have a delay(1000) (or better equivalent) in the loop() at least for testing.
Yes! I added that later, with the function that groundFungus commented
This is a red herring. It's a result of all the registers returning zero, and a zero flag indicating a successful Tx.
After many tests I understood!
Well, I'll leave here the two code that I managed to make it work, who knows, maybe it will help someone in the future!
TX:
#include <Wire.h>
#include <Adafruit_BMP085.h>
#include "dht.h"
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
Adafruit_BMP085 bmp;
const int pinoDHT11 = A2;
const int pinLDR = A3;
const int pinoSensorChuva = A0;
struct sensores {
int valorLDR;
float valorBMP;
int valorDHTT;
int valorDHTH;
int valorCHUVA;
};
sensores mySensores;
dht DHT; //VARIÁVEL DO TIPO DHT
const byte endereco[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN);
void setup(){
Serial.begin(9600);
pinMode(pinLDR, INPUT_PULLUP);
if (!bmp.begin()){
Serial.println("Error");
while(1){}
}
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.setRetries(3,5);
radio.openWritingPipe(endereco);
radio.stopListening();
}
void loop(){
static unsigned long timer = 0;
unsigned long interval = 5000;
if (millis() - timer >= interval)
{
timer = millis();
bool aux = false;
mySensores.valorLDR = map(analogRead(pinLDR), 1023, 0, 0, 100);
Serial.print("LDR:");
Serial.println(mySensores.valorLDR);
mySensores.valorBMP = ((bmp.readPressure())/100);
Serial.print("BMP:");
Serial.println(mySensores.valorBMP);
DHT.read11(pinoDHT11);
mySensores.valorDHTT = DHT.temperature;
Serial.print("DHTT:");
Serial.println(mySensores.valorDHTT);
mySensores.valorDHTH = DHT.humidity;
Serial.print("DHTH:");
Serial.println(mySensores.valorDHTH);
mySensores.valorCHUVA = map(analogRead(pinoSensorChuva), 1023, 0, 0, 100);
Serial.print("CHUVA:");
Serial.println(mySensores.valorCHUVA);
aux = radio.write( &mySensores, sizeof(mySensores) );
if (!aux)
{
Serial.println("ENVIADO");
Serial.println("-------------------------------------------");
}
}
}
RX:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
struct sensores {
int valorLDR;
int valorBMP;
int valorDHTT;
int valorDHTH;
int valorCHUVA;
};
sensores mySensores;
bool newData = false;
#define CE_PIN 9
#define CSN_PIN 10
const byte endereco[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN);
void setup(){
Serial.begin(9600);
Serial.println("Receptor Inicializado");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.openReadingPipe(1, endereco);
radio.startListening();
}
void loop(){
getData();
showData();
}
void getData() {
if ( radio.available() ){
radio.read( &mySensores, sizeof(mySensores) );
newData = true;
}
}
void showData() {
if (newData == true) {
Serial.print("Luz Ambiente: ");
Serial.print(mySensores.valorLDR);
Serial.println("%");
Serial.print("Pressão: ");
Serial.print(mySensores.valorBMP);
Serial.println(" hPa");
Serial.print("Umidade: ");
Serial.print(mySensores.valorDHTH);
Serial.print("%");
Serial.print(" / Temperatura: ");
Serial.print(mySensores.valorDHTT);
Serial.println("*C");
Serial.print("Chuva: ");
Serial.print(mySensores.valorCHUVA);
Serial.println("%");
Serial.println("-----------------------------------");
newData = false;
}
}
Some parts are in Portuguese, but I don't think it will hinder understanding!
Thank you all!