LoRa Temperature/Humidity Sensor by TvE build log

[Yup, I’m determined to find out what the quota for concurrent build logs is :grinning:]

I’ve been using my own little wireless room sensors for many years, here’s a somewhat beaten-up and hacked-up one:

These use an STM32L072 and a RFM69 FSK radio. They work well after I spent a lot of time tuning the radio parameters, but they have a pretty short range, at least at the 50kbps modulation I use. I made some with sx1276 LoRa modules as well, but never managed to get over the hump to actually switch everything over. The LoRa modules also aren’t/weren’t that cheap…

Since I want to get familiar with the STM32WLE5 series I figured I’d create a fresh design so I learn the RF design part and also to get some real-world experience with LoRa.

My first step was to acquire some stm32wle5 parts, which hasn’t been easy. Now that I have them, I started to plop down stuff onto a schematic until I hit a roadblock: do I need a power switch to turn the temperature/humidity sensor on/off or is their sleep mode low enough?

There’s only one way to answer that (other than building and measuring), which is to create a spreadsheet and total up the mAh’s (milliampere-hours). For this design I’d like to power everything straight from CR2032 cells without voltage regulator and I find that totaling up mAh is easier than to total up Wh or Joules because I mostly get to ignore the varying voltage (from ~3V down to ~1.8V). The switch mode power supply in the stm32wle5 throws a bit of a monkey wrench into that, but it should be close enough.

So here’s my spreadsheet, which assumes that the device collects a measurement once a minute (green columns) or once every 5 minutes (blue columns) and sends it off plus gets an ACK (this is not LoRaWAN).

I divided the scenarios further into 14dBm TX power at 125-10-5 modulation (bandwidth - spreading fct - redundancy) in the upper rows and 0dBm TX power at 125-7-5 in the bottom rows. So this represents distant devices vs nearby devices.

For each scenario I took the major components: stm32 cpu, lora radio, bme280 sensor, and sht31 sensor. Then broke out the major phases, such as sleep and measuring and finally poured through the datasheets to see how much current each phase consumes and how long it would take.

The avg[uA] columns shows the average consumption over the whole period and the avg[%] shows it relative to the total consumption. The red cells show the bottom line, which is expected run-time on a (good quality) CR2032 with 30mA current pulses.

What jumps out from all this is what I’ve already experienced with my RFM69 FSK sensors, which is that TX power is almost all that matters! The low bit rates of LoRa compared to the 50kbps FSK I use make that even worse. I wonder how the trade-off between the better margin of LoRa vs. the longer TX times will play out in real life.

Here’s a screen shot of the TX power over the past 24 hours for a collection of current FSK sensors. These sensors adjust their TX power based on the ACKs they receive from the gateway in order to hit a pre-determined SNR.

Clearly the sensors at the bottom will loose from using LoRa 'cause they can’t go lower power so they will just suffer from longer TX times (at least that’s what I expect). But the ones at the top, i.e., the ones that annoy me by having to swap out batteries every couple of months, hopefully will gain ! ? ! ? ?

[Side project: why do the TX levels of some sensors swing so much?]

Back to my original question: do I need a power switch to fully turn the sensors off when idle? It’s pretty clear that I don’t!
(Note that I expect to only use one of the two sensors, I haven’t made up my mind yet and the easiest thing was to pretend I’d use both.)

Comments, suggestions, or questions appreciated!

Apart from their position in space, they will each fall somewhere in a range of values for RF link budget; and many should exceed their specifications. So in any random collection of devices, some will perform well.

For the device shown in purple, I’d guess either a fault, a local noise source, or it is positioned in a null; a volume of space where reflections and attenuation yield a local low.

Oh, I didn’t mean why some sensors require more TX power than others. That I know, they’re further away or behind more walls, rocks, or trees. What I was wondering is why the TX power required by some sensors to achieve a given SNR at the gateway varies so much through the day. Look at the red one, at some points it’s OK at 0dBm at others it’s maxed out at 13dBm. But take the one in orange, it’s quite steady around -3dBm.

So I understand this could be due to RF noise that changes through the day, it could be due to temperature changes causing freq drift (the code does compensate for that using info in the ACKs from the GW the same way it adjusts TX power), it could be due to humidity changes (e.g. tree leaf water content), and more. But so far I haven’t been able to come up with any anything specific that I find believable by staring at the data.

Yeah, I know what you mean. I’ve an irrigation system that I built with 151 MHz Radiometrix modules and atmega328’s. I sample RSSI at the end of every transmission from a node about 400m away in a dry-land forest. My plots of RSSI do show some variation with respect to something; temperature, humidity, rainfall, or wind direction. There’s also a dip every day at about five minutes past midnight.


Isn’t 5 minutes past midnight when cron jobs on all the linux boxes in the time zone go off? :rofl:
What is the unit for the Y axis? (Haven’t seen an rrdtool graph in years, nice! It’s still alive!?)

Good question, I can’t remember, it was 2014. I’ve uncovered my design docs … Radiometrix BiM1 pin 11 RSSI is a DC level between 0.5V and 2V, 60 dB dynamic range, tied to atmega328 pin A1, and my code samples this repeatedly and captures the maximum value seen since the previous message. Analog reference voltage is 5V, but not calibrated. Full scale would be 1024 decimal. Datasheet has a transfer function. 350 would be 1.71V or -55 dBm, 330 would be 1.61V or -80 dBm.

I can see now why I didn’t bother to convert the value. :grin:

1 Like

After another day of reading datasheets and reference designs I have a preliminary schematic together. This design is fully focused on low power coming out of a CR2032. Some of the trade-offs made:

  • only the low-power RF output is supported: 14dBm max, the high power output would kill the battery in no time
  • 32Mhz crystal instead of TCXO, may limit high spreading factor long transmissions due to temperature drift (the battery doesn’t like these either, so this seems appropriate)
  • no Vreg, run straight off the battery, won’t work with a Li-Ion

I still haven’t decided between BME280 and SHT31, and the antenna topic is also still looming. I first want to do a layout to get a feel for everything…

wle5-temp.pdf (77.4 KB)