M5Stack Atom Liteのスリープ時の消費電力を測ってみた

今年はM5Stack Atom Liteで給水ポンプを制御する水やり装置を作ってみようとしましたが、7日経たずに電池が切れたのでどこで電力を消費しているのかと調べてみたところ、M5Stack系はスリープ時も10mA前後消費するという記事をいくつか見つけました。

ちなみに昨年のobniz版の記事はこちらです。
obniz Board 1Yで自動水やりの屋外対応版を工作してみた

そこで自分も、実際に1.2vのニッケル水素電池 3本、おおよび3.7vくらいの電源をAtom Liteにつなぎ、スリープ時に流れている電流を測ってみたので記録しておきます。

こちら、起動時に計測した電流です。44mAほど流れています。

次に、スリープ(Hibernate)時に計測した電流は、6mA強です。こちらは、電源電圧が大きいともう少し大きくなります。

計測した際に使ったスケッチはこちら、一応Hibernateするようにしていますが、とくにオプション有効のままのディープスリープでも流れている電流は同程度でした。

#define TIME_TO_SLEEP 6 * 60 * 60
#define TIME_TO_WATERING 20 * 1000

void setup() {
  unsigned long starttime = millis();

  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_MAX, ESP_PD_OPTION_OFF); 

  // long long型を指定する
  uint64_t sleeptime = TIME_TO_SLEEP * 1000000ULL - (millis() - starttime) * 1000;
  esp_sleep_enable_timer_wakeup(sleeptime);
  esp_deep_sleep_start();
}

void loop() {
}

ところで、esp_sleep_enable_timer_wakeup関数の引数は、マイクロ秒を型uint64_t(64bit符号なし整数)で指定しますが、はじめ以下のように「1000000」のままにしていたところ計算結果が32bit整数になってしまいどんなに長い時間を指定しても2分程度で復帰するというミスに少々ハマってしまいました。。

uint64_t sleeptime = TIME_TO_SLEEP * 1000000 - (millis() - starttime) * 1000;

正しくは、以下のようにULLをつけて符号なし64bit整数を式に含めることで長い時刻をちゃんと計算できるようになります。

uint64_t sleeptime = TIME_TO_SLEEP * 1000000ULL - (millis() - starttime) * 1000;

参考: ESP32 – Deep Sleep for over 3 hours

IoTデータ 可視化サービスAmbientにENV III UNITのデータを送る

以前から触ってみようと思ってやっていなかったIoTデータを可視化するサービスAmbientを試してみました。

https://ambidata.io/

使い方は、書籍「IoT開発スタートブック ── ESP32でクラウドにつなげる電子工作をはじめよう!」やAmbientの公式ドキュメントに詳しく書かれていますが、試した内容をメモとして残しておきます。

Githubリポジトリ ESP8266/ESP32用Arduino・Ambientライブラリー にもサンプルが掲載されているのでこちらも参考になります。

センサーは、M5Stick-C ENV III Unitを使います。

ENV III Unit with Temperature Humidity Air Pressure Sensor (SHT30+QMP6988)
ENV III SKU:U001-C Description ENV III is an environmental sensor that integrates SHT30 and QMP6988 internally to detect temperature, humidity, and atmospheric pressure data. SHT30 is a high-precision and low-power digital temperature and humidity sensor, and supports I2C interface (SHT30:0x44 , QMP6988:0x70).QMP6988 is an absolute air pressure sensor specially designed for mobile applications, with high accuracy and stability, suitable for environmental data collection and detection types of projects.Product Features Simple and easy to use High accuracy I2C communication interface HY2.0-4P interface, support platform UIFlow , Arduino 2x LEGO compatible holes Include 1x ENV-III Unit 1x HY2.0-4P Cable Applications Weather station Storage barn environment monitoring Specification Resources Parameter Maximum temperature measurement range -40 ~ 120 ℃ Highest measurement accuracy 0 ~ 60 ℃/±0.2℃ Humidity measurement range/error 10 ~ 90 %RH / ±2% Maximum measured value of air pressure/resolution/error 300 ~ 1100hPa / 0.06Pa / ±3.9Pa Communication protocol I2C: SHT30(0x44), QMP6988(0x70) Working temperature 32°F to 104°F (0°C to 40°C ) Net weight 5g Gross weight 17g Product Size 24.2*32.2*8.1mm Package Size 67*53*12mm Case Material Plastic ( PC ) ENV version scheme comparison ENV I ENV II ENV III DHT12+BMP280 SHT30+BMP280 SHT30+QMP6988 PinMap M5Core(PORT A) GPIO22 GPIO21 5V GND ENV III Unit SCL SDA 5V GND Schematic Related Link Datasheet QMP6988 SHT30 Learn M5stack based PFD (Primary Flight Display) An attempt to create a realtime “Artificial Horizon” on the M5. Matrix Shelly Thermostat: A Serverless Approach A modular WiFi smart thermostat that doesn’t need you to maintain any infrastructure: deploy it everywhere, integrate with everything. M5Stack COM. LoRaWAN Using Arduino IDE M5Stack recently released an updated LoRaWAN module. This tutorial teaches you how to connect it to The Things Network using Arduino IDE. Smart Plant with M5Stack Make your plants smart and monitor water, temperature and humidity! M5StickC with HomeKit Automation Used StickC with ESPHap library to connect to HomeKit Smart Planting System Building a smart planting system using M5Stack to monitor the lights, humidity, temperature, watering your plant automatically. 3 in 1 Sanitiser Dispenser We have devised with an innovation that dispenses hand sanitiser, measures the temperature of user, shows the count of people in vicinity. CovidStop A technology which increases efficiency in signing in or out during peak hour areas when entering the campus while the SafeEntry implies. SEAM [Safe-Entry Access Machine] An automatic system to perform the tasks of Safe Entry. It consist an adjustable Thermometer, RFID / QR Code Check in and Counting. Example Arduino ENV III Unit Test

shop.m5stack.com

No Image


“IoTデータ 可視化サービスAmbientにENV III UNITのデータを送る” の続きを読む

M5Stack ENV III Unit 温湿度気圧センサ (SHT30+QMP6988) の使い方

M5StickC ENV-HAT IIが壊れてしまい[ENV III Unit 温湿度気圧センサー (SHT30+QMP6988)]を買ったので使い方をメモしておきます。

ENV III Unit with Temperature Humidity Air Pressure Sensor (SHT30+QMP6988)
ENV III SKU:U001-C Description ENV III is an environmental sensor that integrates SHT30 and QMP6988 internally to detect temperature, humidity, and atmospheric pressure data. SHT30 is a high-precision and low-power digital temperature and humidity sensor, and supports I2C interface (SHT30:0x44 , QMP6988:0x70).QMP6988 is an absolute air pressure sensor specially designed for mobile applications, with high accuracy and stability, suitable for environmental data collection and detection types of projects.Product Features Simple and easy to use High accuracy I2C communication interface HY2.0-4P interface, support platform UIFlow , Arduino 2x LEGO compatible holes Include 1x ENV-III Unit 1x HY2.0-4P Cable Applications Weather station Storage barn environment monitoring Specification Resources Parameter Maximum temperature measurement range -40 ~ 120 ℃ Highest measurement accuracy 0 ~ 60 ℃/±0.2℃ Humidity measurement range/error 10 ~ 90 %RH / ±2% Maximum measured value of air pressure/resolution/error 300 ~ 1100hPa / 0.06Pa / ±3.9Pa Communication protocol I2C: SHT30(0x44), QMP6988(0x70) Working temperature 32°F to 104°F (0°C to 40°C ) Net weight 5g Gross weight 17g Product Size 24.2*32.2*8.1mm Package Size 67*53*12mm Case Material Plastic ( PC ) ENV version scheme comparison ENV I ENV II ENV III DHT12+BMP280 SHT30+BMP280 SHT30+QMP6988 PinMap M5Core(PORT A) GPIO22 GPIO21 5V GND ENV III Unit SCL SDA 5V GND Schematic Related Link Datasheet QMP6988 SHT30 Learn M5stack based PFD (Primary Flight Display) An attempt to create a realtime “Artificial Horizon” on the M5. Matrix Shelly Thermostat: A Serverless Approach A modular WiFi smart thermostat that doesn’t need you to maintain any infrastructure: deploy it everywhere, integrate with everything. M5Stack COM. LoRaWAN Using Arduino IDE M5Stack recently released an updated LoRaWAN module. This tutorial teaches you how to connect it to The Things Network using Arduino IDE. Smart Plant with M5Stack Make your plants smart and monitor water, temperature and humidity! M5StickC with HomeKit Automation Used StickC with ESPHap library to connect to HomeKit Smart Planting System Building a smart planting system using M5Stack to monitor the lights, humidity, temperature, watering your plant automatically. 3 in 1 Sanitiser Dispenser We have devised with an innovation that dispenses hand sanitiser, measures the temperature of user, shows the count of people in vicinity. CovidStop A technology which increases efficiency in signing in or out during peak hour areas when entering the campus while the SafeEntry implies. SEAM [Safe-Entry Access Machine] An automatic system to perform the tasks of Safe Entry. It consist an adjustable Thermometer, RFID / QR Code Check in and Counting. Example Arduino ENV III Unit Test

shop.m5stack.com

No Image

今回HATじゃなくてUNITの方にした理由としては、M5StackやATOMなどでも使い回したいという理由でUTNIにしてみました。
“M5Stack ENV III Unit 温湿度気圧センサ (SHT30+QMP6988) の使い方” の続きを読む

M5Stick-Cで光センサユニット(LIGHT UNIT)を試す

M5Stack-Cで、光センサーのユニットLIGHTを試してみました。

LIGHT UNITの光センサは、フォトレジスタ(CdSセル)が組み込まれているモジュールで、光の強さをアナログおよびデジタルで読み取れます。

公式リファレンスのページ: Light – M5Stack Docs

プログラムは、上記の公式リファレンスのページで紹介されているサンプルを修正してみました。

Github: M5Stack/examples/Unit/LIGHT/LIGHT.ino

公式リファレンスのM5Stack Coreを利用した例と同じ様に、LIGHT UNITから読み取ったアナログとデジタルの値をLCDに表示します。


“M5Stick-Cで光センサユニット(LIGHT UNIT)を試す” の続きを読む