Firstly, thanks for a great forum! I’ve used Arduinos over the years for lots of little projects and this forum has regularly been a go-to for me! I really appreciate all the guidance and examples given by everyone on here.
Whilst being stuck at home, I’m trying to build a device to monitor 3 water butts that I have in the garden using and Arduino (currently Uno, probably later a Mini). I would like to know the water level in the butt and the temperature and humidity.
I thought an easy way to do this would be with a Dragino Lora shield, a matched gateway, a DHT11 module, a one-wire temp device, an RTC3231 and maybe a 4…20mA to 0…5V board for a pressure transducer. As I wanted the thing to last “forever” in the garden, I figured an appropriately IP rated enclosure, a small solar panel, a deep cycle battery and charge regulator might be useful too! So I ordered a host of bits and started tinkering!
My first few rounds of tests went well and I got to the point that I could receive data every minute through the Lora system. The data showed me external temperature, internal temperature and humidity, and depth as expected.
At that point I was just sleeping for 60 seconds which of course meant I would have been gobbling through batteries (I was still running on a PSU at the time). I next implemented the RTC using an interrupt to wake up every minute and do the same thing. Everything seemed to work! I was delighted! I popped a 6V sealed lead acid battery into the enclosure and stuck it outside to do some more tests! Again, everything worked! The thing woke up every minute and sent a load of data before sleeping again.
Then I noticed some quirky things had started happening. Sometimes, it sent data ever minute for a few hours, then stopped for a few mins, then started again. Sometimes it sent 3 messages then didn’t, then came back for a few hours, then went again. At first I thought it was a power issue - I appreciate I’m using a 6V battery and so perhaps I was suffering voltage drop that was causing instability, but even when running on the power supply (or just the power from the USB), the same problem occurred. I was using a 220R resister to measure my 4…20mA device at that point, so I disconnected that too - but still the same strange intermittent operation. Eventually, I tried substituting the line of code that put it to sleep, and instead just returned to sleep(60000) and it happily ran for hours, no problems.
So I can only assume I’m doing something wrong within my Going_To_Sleep code - but I can’t see what it is.
I’ve attached my code and hope it’s sufficiently documented to make some sense!
Any help would be very much appreciated!
Thank you all!
LoRa_Simple_Client_Arduino-V10a.ino (14.1 KB)