Hi,
I have strange problem with my battery powered BME280 sensors. I use Easy/Newbie PCB for all my sensors (wall and battery powered). Hardware works fine I think because all my wall powered sensors works ok almost one year now.
Battery sensors works ok when I disconnect it from battery and charge before power loss. Every time when I let it power off itself my gateway hangs and all sensors data didn't show in Home Assistant. Also debug logs in HA didn't show any communication from gateway. I have 2 the same battery sensors powered by two 18650 cells (sketch is the same, difference is another node id). When this situation happens I have to restart all my network to get it working again. I have all my wall powered sensors on one circuit so I can easily reboot them. But without restarting battery sensor (this one still powered) network doesn't work.
I cannot do debug of powered off sensor. Debug logs in Home Assistant shows nothing (no log from gateway). I cannot reconnect serial console to gateway because it will reboot the gateway...
I upgraded my gateway and battery powered sensors to newest mysensors version, but I use old RMF69 driver - I don't know it it relevant or not.
Gateway sketch is the standard one - radio type, channels, encryption only
battery sensor and gateway sketch is below
Any ideas what is wrong?
#define MY_ENCRYPTION_SIMPLE_PASSWD "xxxxxxxxxxxxxxxxxx"
#define MY_NODE_ID 9
#define MY_RADIO_RFM69
#define MY_IS_RFM69HW
#define MY_RFM69_NETWORKID 101
#include <MySensors.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define SEALEVELPRESSURE_HPA (1013.25)
int BATTERY_SENSE_PIN = A0;
unsigned long SLEEP_TIME = 60000*5;
int oldBatteryPcnt = 0;
Adafruit_BME280 bme;
unsigned status;
MyMessage msg(1,V_TEMP);
MyMessage msg2(2,V_HUM);
MyMessage msg3(3,V_VAR1);
void before()
{
}
void setup()
{
status = bme.begin();
bme.setSampling(Adafruit_BME280::MODE_FORCED,
Adafruit_BME280::SAMPLING_X1, // temperature
Adafruit_BME280::SAMPLING_NONE, // pressure
Adafruit_BME280::SAMPLING_X1, // humidity
Adafruit_BME280::FILTER_OFF );
}
void presentation() {
sendSketchInfo("sensor_front", "1.0");
present(1, S_TEMP,"temp front");
present(2, S_HUM,"hum front");
present(3, S_CUSTOM,"bat raw");
}
void loop()
{
int sensorValue = analogRead(BATTERY_SENSE_PIN);
int batteryRaw = sensorValue;
int batteryPcnt = map (batteryRaw,335, 435, 0, 100);
if (batteryPcnt>100) batteryPcnt = 100;
Serial.print("Battery percent: ");
Serial.print(batteryPcnt);
Serial.println(" %");
sendBatteryLevel(batteryPcnt);
bme.takeForcedMeasurement();
wait(1000);
float hum = bme.readHumidity();
send(msg2.set(hum,0));
float temperature = bme.readTemperature();
send(msg.set(temperature,1));
send(msg3.set(batteryRaw,0));
sendHeartbeat();
sleep(SLEEP_TIME);
}
// Enable debug prints to serial monitor
#define MY_DEBUG
#define MY_ENCRYPTION_SIMPLE_PASSWD "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
// Enable and select radio type attached
#define MY_RADIO_RFM69
#define MY_IS_RFM69HW
#define MY_RFM69_NETWORKID 101
// Enable serial gateway
#define MY_GATEWAY_SERIAL
// Define a lower baud rate for Arduinos running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
#if F_CPU == 8000000L
#define MY_BAUD_RATE 38400
#endif
// Set blinking period
//#define MY_DEFAULT_LED_BLINK_PERIOD 300
// Inverses the behavior of leds
//#define MY_WITH_LEDS_BLINKING_INVERSE
// Flash leds on rx/tx/err
// Uncomment to override default HW configurations
//#define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin
//#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED
#include <MySensors.h>
void setup()
{
// Setup locally attached sensors
}
void presentation()
{
// Present locally attached sensors
}
void loop()
{
// Send locally attached sensor data here
}