@user2684
Tried again with adafruits library and got it working changing the address.
But still can't get any useful data from it using NodeManager.
Did a bit of copy/paste and got this code working (with adafruit and the alternative library):
#define MY_RADIO_NRF24
#include <MySensors.h>
#include <SPI.h>
#include <BH1750.h>
#include <Wire.h>
#include <BME280I2C.h>
#define BARO_CHILD 0
#define TEMP_CHILD 1
#define HUM_CHILD 2
#define CHILD_ID_LIGHT 3
#define R1 687000
#define R2 222000
#define VMIN 3.30
#define VMAX 4.18
#define ADC_PRECISION 1023
#define VREF 1.107
unsigned long SLEEP_TIME = 300000;
const float ALTITUDE = 10;
BME280I2C bme;
BH1750 lightSensor;
MyMessage pressureMsg(BARO_CHILD, V_PRESSURE);
MyMessage tempMsg(TEMP_CHILD, V_TEMP);
MyMessage humMsg(HUM_CHILD, V_HUM);
MyMessage lightMsg(CHILD_ID_LIGHT, V_LEVEL);
float lastbaro = -1;
float lasttemp = -1;
float lasthum = -1;
float lastlux = -1;
float oldBatteryPcnt = -1;
int BATTERY_SENSE_PIN = A0;
void setup()
{
lightSensor.begin();
bme.begin();
analogReference(INTERNAL);
pinMode(BATTERY_SENSE_PIN, INPUT);
delay(100);
}
void presentation()
{
sendSketchInfo("BME280_BH1750", "1.1");
present(BARO_CHILD, S_BARO);
present(TEMP_CHILD, S_TEMP);
present(HUM_CHILD, S_HUM);
present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
}
void loop()
{
float baro_local = bme.pres() / 100.0;
float baro = ( baro_local / pow((1.0 - ( ALTITUDE / 44330.0 )), 5.255));
if (baro != lastbaro) {
send(pressureMsg.set(baro,2));
lastbaro = baro;
}
float temp = bme.temp();
if (temp != lasttemp) {
send(tempMsg.set(temp,1));
lasttemp = temp;
}
float hum = bme.hum();
if (hum != lasthum) {
send(humMsg.set(hum,1));
lasthum = hum;
}
float lux = lightSensor.readLightLevel();
if (lux != lastlux) {
send(lightMsg.set(lux,0));
lastlux = lux;
}
float batteryPcnt = getBatteryPercentage();
if (oldBatteryPcnt != batteryPcnt) {
// Power up radio after sleep
sendBatteryLevel(batteryPcnt);
oldBatteryPcnt = batteryPcnt;
}
sleep(SLEEP_TIME);
}
float getBatteryPercentage()
{
delay(500);
int inputValue = analogRead(BATTERY_SENSE_PIN);
float voltageDividerFactor = (R1 + R2) / R2;
float maxValue = voltageDividerFactor * VREF;
float voltsPerBit = maxValue / ADC_PRECISION;
float batteryVoltage = voltsPerBit * inputValue;
float batteryPercentage = ((batteryVoltage-VMIN)/(VMAX-VMIN))*100;
return batteryPercentage;
}