Jump to content
Electronics-Lab.com Community

WiFi MCU deepsleep mode after uploading data to cloud - Ameba Arduino


MENG XI

Recommended Posts

WiFi microcontroller usually consume a lot more power than ones without WiFi connection. Even in sleep mode, 2 AA batteries would only last a week, but RTL8722 from Realtek has 2 cores, a cortex M4 core handling user application and a cortex M0 core that help to conserve power by entering the deep sleep mode to extend battery life to few months, here is an example of it,

 

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.

Link to comment
Share on other sites


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...