Hello everyone
Im trying to build a mini weather station. I am using a Nano as a transmitter, with the BME280 sensor connectted and a NRF24L01.
The serial monitor of the transmitter shows me the right values of the 4 mesurements(temp, humidity, pressure and altitude) and it seems it works fine
The receiver works with a Nano too. It has connected a NRF24L01 and a LCD16*2. Although the 2 devices are communicating something is wrong.
The receiver is getting the right values for the temperature and the humidity but the pressure and the altitude are wrong . The transmitter is has for pressure 945.75hPa and 577.7m for altitude but the receiver gets 177hPa for pressure and 63m for altitude. Can anyone help?
I paste the code for the transmitter and receiver:
//TRANSMITTER
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
const uint64_t pipeOut = 0xE8E8F0F0E1LL;
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme;
RF24 radio(9, 10); // CN and CSN pins of nrf
struct MyData {
byte h;
byte t;
byte p;
byte a;
};
MyData data;
void setup()
{
Serial.begin(9600);
radio.begin();
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS);
radio.openWritingPipe(pipeOut);
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
void loop()
{
Serial.print("T = ");
Serial.print(bme.readTemperature());
Serial.println("*C");
Serial.print("P = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println("hPa");
Serial.print("A = ");
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial.println("m");
Serial.print("H = ");
Serial.print(bme.readHumidity());
Serial.println("%");
Serial.println();
data.h = bme.readHumidity();
data.t = bme.readTemperature();
data.p = bme.readPressure() / 100.0F;
data.a = bme.readAltitude(SEALEVELPRESSURE_HPA);
radio.write(&data, sizeof(MyData));
}
//RECEIVER
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 16, 2);
const uint64_t pipeIn = 0xE8E8F0F0E1LL;
RF24 radio(9, 10);
struct MyData {
byte h;
byte t;
byte p;
byte a;
};
MyData data;
void setup()
{
Serial.begin(9600);
radio.begin();
lcd.begin();
lcd.home();
lcd.backlight();
lcd.clear();
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS);
radio.openReadingPipe(1, pipeIn);
radio.startListening();
//lcd.println("Receiver ");
}
void loop()
{
if ( radio.available() ) {
radio.read(&data, sizeof(MyData));
}
Serial.print("H: ");
Serial.print(data.h);
lcd.setCursor(0,0);
lcd.print("H:");
lcd.print(data.h);
lcd.print("%");
Serial.print(" P: ");
Serial.print(data.p);
lcd.print(" P:");
lcd.print(data.p);
lcd.print("hPa");
lcd.setCursor(0,1);
Serial.print("T: ");
Serial.print(data.t);
lcd.print("T:");
lcd.print(data.t);
lcd.print("C");
Serial.print("A:");
Serial.print(data.a);
lcd.print(" A:");
lcd.print(data.a);
lcd.print("m");
//Serial.print("\n");
}
Thanks a lot for your time