Power Management - Enter deepsleep after uploading DHT data to LASS

Preparation

  • Ameba x 1
  • DHT11/DHT22/DHT21 x 1
Example
In this example, we will get the humidity and temperature data from DHT, connect to AP, retrieve NTP time, upload the data to LASS MQTT server, then enter deepsleep mode every 10 minutes.

Open “File” -> “Examples” -> “AmebaPowerSave” -> “DeepSleepWithDHTLass”
Modify detailed settings in the sample code:
– Model of DHT sensor: DHT11/DHT22/DHT21
– Connection to WiFi AP: ssid, password
– GPS position: latitude & longitude

Compile and upload to Ameba. The actual power cosumption depends on many factors such as network condition, the time it takes for the server to respond. In our case, the program completes in 13 seconds, the power consumption of the Ameba Module is 1.3mA.
This number is larger than the one we get in the “DeepSleepWithDHT” example. This is because the power consumption of Ameba in operation is usually larger than 29mA, and when Ameba is using wifi connection the power consumption is larger than 68 mA, which are considerably larger than the 0.018 mA power consumption in deepsleep mode. Therefore, we should keep Ameba in the deepsleep mode as far as possible to save energy.

To compare the result with the case without entering power-saving mode, we modify the sample code as below. We keep the network connection and get the data from DHC sensor every 10 minutes, then upload the MQTT server.

void setup()
{
  dht.begin();

  reconnectWiFi();
  retrieveNtpTime();
  initializeMQTT();
}

void loop()
{
  if (gatherHumidityAndTemperature() == DATA_CNT_FOR_UPLOAD) {
    reconnectWiFi();
    while(!sendMQTT()) {
      delay(1000);
    }
    mqttClient.loop();

    pDhtData->dataCount = 0;
  }

  // store data back to flash memory
  FlashMemory.update();
  delay(measureInterval * 1000);
}

As a result, the average power consumption is 67 mA.
Use 2 AA batteries to compare the results: (We use the Keysight 34465A multimeter in the experiment)
1

According to the result, the energy of 2 AA batteries can only last for about 1 day without power-saving, and it can last about 2.8 months with power-saving.

NOTE: In reality, due to the energy loss in the voltage conversion and operation, the actual usage time may be different.

Please confirm that QQ communication software is installed