In this project, we will learn how to reduce the Lora sensor power consumption, we aimed to make the Lora soil moisture sensor can be long-term operated.


Last time, I shared the basic operation of the Lora communication soil sensor from Makerfabs and confirmed the transmission distance is 300 meters or more. Check my previous post here: Get started with Lora soil moisture sensor.

This soil sensor can be operated with two AAA batteries.

Here, we are trying to reduce the Lora soil moisture sensor's power consumption by observing different modes' consumption, with the aim of long-term operation of the Lora sensor.

1. Standby Current
We measured the standby power supply current when not communicating.

The power supply voltage was 3.3V.

①Default
This is the standby current when the sample code LoraTransmitterADCAHT10.ino is written as it is.
16.5 mA

②Sensor Power Off
Uncomment L. 149 of the sample code LoraTransmitterADCAHT10.ino and turn off the Lora temperature / humidity sensor AHT10 after the measurement.
15.5 mA
 
The current has dropped slightly.

③Microcontroller Sleep
Furthermore, the sensor microcontroller ATmega328P was put to sleep during standby. I used a library that controls sleep with Adafruit's Sleepdog: https://github.com/adafruit/Adafruit_SleepyDog 
11.2 mA

④Lora Module Reset
Furthermore, I reset the Lora module and turned it off before the microcontroller sleep.
0.1 mA or less

As a result, the standby current can be significantly reduced.

 

2. Power Consumption per Communication

Transmission power 23dBm: Approximately 12.0 μW

Transmission power 5dBm: Approximately 1.2 μW

Communication consumption was very small. As expected!

You can expect lower power consumption by lowering the transmission power or limiting the number of communications according to the transmission distance (naturally).

3. Power Consumption
I measured the power consumption for 1 minute.

I set it to send sensor values every 9 seconds.

① Default
When the sample code LoraTransmitterADCAHT10.ino is written as it is
1.1 mW consumption per minute

④ Lora Module Reset
Added sensor OFF, microcontroller sleep, and Lora module reset to the sample code.
Consume 0.3 mW per minute

We have succeeded in reducing power consumption by less than 1/3!

4. Arduino Code ④ Lora Module Reset
Here is the Arduino code for low power consumption version.

Based on sample code LoraTransmitterADCAHT10.ino
Introduced and coded Adafruit's sleep dog library: https://github.com/adafruit/Adafruit_SleepyDog

#include <SPI.h>
#include "RH_RF95.h"
#include <Adafruit_SleepyDog.h>
 
#include "I2C_AHT10.h"
#include <Wire.h>
AHT10 humiditySensor;
 
 
int sensorPin = A2;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor
int sensorPowerCtrlPin = 5;
 
void sensorPowerOn(void){
  digitalWrite(sensorPowerCtrlPin, HIGH);//Sensor power on
}
 
void sensorPowerOff(void){
  digitalWrite(sensorPowerCtrlPin, LOW);//Sensor power on
}
 
#define RFM95_CS 10
#define RFM95_RST 4
#define RFM95_INT 2
 
// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 915.0
 
// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);
 
void setup() {
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, LOW);
  delay(100);
  digitalWrite(RFM95_RST, HIGH);
 
  pinMode(sensorPowerCtrlPin, OUTPUT);
  sensorPowerOn();
  
  //while (!Serial);
  Serial.begin(115200);
  delay(100);
 
  Wire.begin(); //Join I2C bus
  //Check if the AHT10 will acknowledge
  if (humiditySensor.begin() == false){
    Serial.println("AHT10 not detected. Please check wiring. Freezing.");
    //while (1);
  }
  else
    Serial.println("AHT10 acknowledged.");
    
  Serial.println("Marduino LoRa TX Test!");
 
}
 
int16_t packetnum = 0;  // packet counter, we increment per xmission
float temperature=0.0;//
float humidity=0.0;
 
void loop(){
  setModule();
  
  sensorPowerOn();
  delay(100);
  sensorValue = analogRead(sensorPin);
  delay(200);
 
  if (humiditySensor.available() == true){
    //Get the new temperature and humidity value
    temperature = humiditySensor.getTemperature();
    humidity = humiditySensor.getHumidity();
 
    //Print the results
    Serial.print("Temperature: ");
    Serial.print(temperature, 2);
    Serial.print(" C\t");
    Serial.print("Humidity: ");
    Serial.print(humidity, 2);
    Serial.println("% RH");
 
    //sensor off
    sensorPowerOff();
 
    Serial.print(F("Moisture ADC : "));
    Serial.println(sensorValue);
  
    
    //Serial.print(F("Humidity: "));
    //Serial.print(humidity);
    //Serial.print(F("%  Temperature: "));
    //Serial.print(temperature);
    //Serial.println("Humidity is " + (String)humidity);
    //Serial.println("Temperature is " + (String)temperature);
  
    String message = "#"+(String)packetnum+" Humidity:"+(String)humidity+"% Temperature:"+(String)temperature+"C"+" ADC:"+(String)sensorValue;
    Serial.println(message);
    packetnum++;
    Serial.println("Transmit: Sending to rf95_server");
    
    // Send a message to rf95_server
  
    uint8_t radioPacket[message.length()+1];
    message.toCharArray(radioPacket, message.length()+1);
    
    radioPacket[message.length()+1]= '\0';
  
    Serial.println("Sending..."); delay(10);
    rf95.send((uint8_t *)radioPacket, message.length()+1);
    Serial.println("Waiting for packet to complete..."); delay(10);
    rf95.waitPacketSent();
    // Now wait for a reply
    uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
  
    Serial.println("Waiting for reply..."); delay(10);
    if(rf95.waitAvailableTimeout(8000)){
      // Should be a reply message for us now  
      if (rf95.recv(buf, &len)){
        Serial.print("Got reply: ");
        Serial.println((char*)buf);
        Serial.print("RSSI: ");
        Serial.println(rf95.lastRssi(), DEC);  
      }
      else{
        Serial.println("Receive failed");
      }
    }
    else{
      Serial.println("No reply, is there a listener around?");
    }
 
    Serial.print("Sleep!!");
        
    // Lora module reset
    digitalWrite(RFM95_RST, LOW);
    delay(10);
    digitalWrite(RFM95_RST, HIGH);
    delay(10);
      
    //8sec sleep
    int sleepMS = Watchdog.sleep();
  }
}
 
void setModule(void){
  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);
 
  while(!rf95.init()) {
    Serial.println("LoRa radio init failed");
    while (1);
  }
  Serial.println("LoRa radio init OK!");
 
  //rf95.setModemConfig(Bw125Cr48Sf4096);
 
  //Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1);
  }
  Serial.print("Set Freq to: ");
  Serial.println(RF95_FREQ);

  // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on

  // The default transmitter power is 13dBm, using PA_BOOST.
  // If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
  // you can set transmitter powers from 5 to 23 dBm:
  rf95.setTxPower(23, false);
}

 

After measuring the sensor, turn off the Lora temperature / humidity sensor at L.84.

After sending the measurement data, reset the Lora module at L. 137-140.

After resetting the Lora module, sleep the microcomputer with L.143.
Sleep is released after 8 seconds (maximum watchdog timer).

After canceling Sleep, initialize the Lora module with L. 63
Turn on the Lora temperature / humidity sensor at L. 65.

The above is repeated and sensor data is transmitted approximately every 9 seconds.

5. Conclusion
Since the Lora communication power consumption of the soil sensor has been reduced, how long will it last with AAA batteries?
I would like to experiment.

The deadline for notification of special cases such as experiments using equipment that has not acquired technical suitability in January next year. I'm looking forward to seeing which one will expire first.

 


This is a project shared by HomeMadeGarbge, under his authorization, we translate it into English and share here. If you can read Japanese, Pls check the original article.