ESP32C3 issues waking from deep sleep on battery.....but not consistently

Hi, I started off with a slightly different board using BLE through a gateway to the mqtt broker but the Bluetooth just wasn’t strong enough (these are going in fridges/freezers) so I moved to 2.4Ghz WiFi instead. Antenna wise I started with the one that comes with the board but the rssi was often -80 or worse so I thought that might be the issue and it was losing network connection so now have these 2.4GHz Rod Antenna for XIAO ESP32C3 | The Pi Hut and getting -30 to -50.

I think I had it working perfectly before powered solely from a usb power block but I’ll need to check as I’ve been at this a month or two and that was at the start so can’t remember if it was actually a different board I was using. It definitely didn’t have sleep involved though so that may have been the difference. And then I got possibly down the wrong road reading about esp32c3 and deep sleep issues on battery, a few of them turned out to be unrelated though but I was left with a feeling it may be the problem.

I need to log the temperatures every 15 minutes whether it’s changed or not so while I could try changing the code to only send when theres a change for testing I’d need to change it back for long term use

What I’ve got/want to work is esp32c3 battery powered without needing charged for a month or two at least. Wakes every 15 minutes sends temperature (have Mac, rssi etc just now as well for info) to mqtt broker over WiFi. Anytime I’d expect there to be a temperature from one of them and it isn’t there, if I check the broker logs it shows that it connected but timed out and was disconnected before the message was sent. Broker is mosquito running on a raspberry pi. There’s a python script also running on the raspberry pi that listens to the broker and dumps the message content into a SQL database on another machine on the network.

The broker on the pi is at site A the database is at site B and currently the sensors are at site C all connected by VPN.
I’ve got a new case printing for them with space to incorporate the cap added and will be taking one down to site A tomorrow as part of me also suspects the network but it works so well a lot of the time , just once or twice every few hours it “misses a check in” but I suppose it’s possible that those times there’s an issue with the internet/VPN. They’ve never tried to connect simultaneously yet as I reset them a minute or so apart when starting testing.

You can see in the screenshots above, sometimes it works perfectly then randomly it’ll timeout at the broker before being able to send the message. Rarely it’ll happen twice in a row and it won’t report in for 45 minutes, usually when it happens it’ll miss one 15 minute but be back the next and once in a blue moon I’ve had the same one report in twice within a minute :confused: