目次
チャージコントローラによる充電量の制限
M5Stackの充電制御IC IP5306のネット上に分散していたレジスタ情報をまとめる
様によると、「M5Stack BASICのボトム(LiPo:110mAh)を使うときは、スケッチのsetup()の最初に以下のように記載してやることで、充電電流オーバーによるLiPoの劣化をある程度防げるはず」との記載。
setup(){
M5.begin();
M5.Power.begin();
M5.Power.setVinMaxCurrent(CURRENT_100MA) ;
一つの可能性に行きついたが、太陽光パネルをM5Stackに接続した場合、チャージコントローラであるIP5306が過充電・放電を防いでくれるのではないか。
つまり、外部にチャージコントローラは不要になるのではないか
M5StickCのAXP192の電源周りを調べる | Lang-ship によると、M5StickCのチャージコントロータAXP192では、
低電力化
M5StickCでの省電力ノウハウ | Lang-ship によると、画面有り・WiFiありで消費電力を最小にするには、
- ESP32 80MHz(無線利用) で15.4mA
- 画面8以下で 1.0mA
の電流設定が良いと想定する。更にWiFiの消費電力を下げるには、下記が必要。
- 無線送信電力を100mW(20dBm)から50mW(17dBm)、10mW(10dBm)へ下げる
- APモードの場合、ビーコン間隔を最長
esp-idf/esp_wifi.h at 1c7a8b3b712c4020562551f692d0ced8f7470d2c · espressif/esp-idf · GitHubより、
ESP32のソースコードで電力や通信レート・距離、チャネルに関連する関数を抜粋しておく。
WiFiの場合
esp_err_t esp_wifi_set_ps(wifi_ps_type_t type);
esp_err_t esp_wifi_get_ps(wifi_ps_type_t *type);
//The default protocol is (WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N)
esp_err_t esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw);
//@attention 2. WIFI_BW_HT40 is supported only when the interface support 11N
esp_err_t esp_wifi_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx);
* Level0 represents highest transmiting power and level5 represents lowest
* transmiting power.
* levels as follows:
* - [78, 127]: level0 //20dBm??
* - [76, 77]: level1
* - [74, 75]: level2
* - [68, 73]: level3
* - [60, 67]: level4
* - [52, 59]: level5
* - [44, 51]: level5 - 2dBm
* - [34, 43]: level5 - 4.5dBm
* - [28, 33]: level5 - 6dBm
* - [20, 27]: level5 - 8dBm
* - [8, 19]: level5 - 11dBm
* - [-128, 7]: level5 - 14dBm
esp_err_t esp_wifi_set_ant_gpio(const wifi_ant_gpio_config_t *config);
/**
* @brief Set primary/secondary channel of ESP32
*
* @attention 1. This API should be called after esp_wifi_start()
* @attention 2. When ESP32 is in STA mode, this API should not be called when STA is scanning or connecting to an external AP
* @attention 3. When ESP32 is in softAP mode, this API should not be called when softAP has connected to external STAs
* @attention 4. When ESP32 is in STA+softAP mode, this API should not be called when in the scenarios described above
*
* @param primary for HT20, primary is the channel number, for HT40, primary is the primary channel
* @param second for HT20, second is ignored, for HT40, second is the second channel
*
* @return
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_IF: invalid interface
* - ESP_ERR_INVALID_ARG: invalid argument
*/
esp_err_t esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second);
/**
* @brief configure country info
*
* @attention 1. It is discouraged to call this API since this doesn't validate the per-country rules,
* it's up to the user to fill in all fields according to local regulations.
* Please use esp_wifi_set_country_code instead.
* @attention 2. The default country is CHINA {.cc="CN", .schan=1, .nchan=13, policy=WIFI_COUNTRY_POLICY_AUTO}
* @attention 3. When the country policy is WIFI_COUNTRY_POLICY_AUTO, the country info of the AP to which
* the station is connected is used. E.g. if the configured country info is {.cc="USA", .schan=1, .nchan=11}
* and the country info of the AP to which the station is connected is {.cc="JP", .schan=1, .nchan=14}
* then the country info that will be used is {.cc="JP", .schan=1, .nchan=14}. If the station disconnected
* from the AP the country info is set back to the country info of the station automatically,
* {.cc="US", .schan=1, .nchan=11} in the example.
* @attention 4. When the country policy is WIFI_COUNTRY_POLICY_MANUAL, then the configured country info is used always.
* @attention 5. When the country info is changed because of configuration or because the station connects to a different
* external AP, the country IE in probe response/beacon of the soft-AP is also changed.
* @attention 6. The country configuration is stored into flash.
* @attention 7. When this API is called, the PHY init data will switch to the PHY init data type corresponding to the
* country info.
*
* @param country the configured country info
*
* @return
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_INVALID_ARG: invalid argument
*/
esp_err_t esp_wifi_set_country(const wifi_country_t *country);
/**
* @brief Set maximum transmitting power after WiFi start.
*
* @attention 1. Maximum power before wifi startup is limited by PHY init data bin.
* @attention 2. The value set by this API will be mapped to the max_tx_power of the structure wifi_country_t variable.
* @attention 3. Mapping Table {Power, max_tx_power} = {{8, 2}, {20, 5}, {28, 7}, {34, 8}, {44, 11},
* {52, 13}, {56, 14}, {60, 15}, {66, 16}, {72, 18}, {80, 20}}.
* @attention 4. Param power unit is 0.25dBm, range is [8, 84] corresponding to 2dBm - 20dBm.
* @attention 5. Relationship between set value and actual value. As follows: {set value range, actual value} = {{[8, 19],8}, {[20, 27],20}, {[28, 33],28}, {[34, 43],34}, {[44, 51],44}, {[52, 55],52}, {[56, 59],56}, {[60, 65],60}, {[66, 71],66}, {[72, 79],72}, {[80, 84],80}}.
*
* @param power Maximum WiFi transmitting power.
*
* @return
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_START: WiFi is not started by esp_wifi_start
* - ESP_ERR_WIFI_ARG: invalid argument, e.g. parameter is out of range
*/
esp_err_t esp_wifi_set_max_tx_power(int8_t power);
/**
* @brief Get the TSF time
* In Station mode or SoftAP+Station mode if station is not connected or station doesn't receive at least
* one beacon after connected, will return 0
*
* @attention Enabling power save may cause the return value inaccurate, except WiFi modem sleep
*
* @param interface The interface whose tsf_time is to be retrieved.
*
* @return 0 or the TSF time
*/
int64_t esp_wifi_get_tsf_time(wifi_interface_t interface);
/**
* @brief Set the inactive time of the ESP32 STA or AP
*
* @attention 1. For Station, If the station does not receive a beacon frame from the connected SoftAP during the inactive time,
* disconnect from SoftAP. Default 6s.
* @attention 2. For SoftAP, If the softAP doesn't receive any data from the connected STA during inactive time,
* the softAP will force deauth the STA. Default is 300s.
* @attention 3. The inactive time configuration is not stored into flash
*
* @param ifx interface to be configured.
* @param sec Inactive time. Unit seconds.
*
* @return
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
* - ESP_ERR_WIFI_ARG: invalid argument, For Station, if sec is less than 3. For SoftAP, if sec is less than 10.
*/
esp_err_t esp_wifi_set_inactive_time(wifi_interface_t ifx, uint16_t sec);
/**
* @brief Enable or disable 11b rate of specified interface
*
* @attention 1. This API should be called after esp_wifi_init() and before esp_wifi_start().
* @attention 2. Only when really need to disable 11b rate call this API otherwise don't call this.
*
* @param ifx Interface to be configured.
* @param disable true means disable 11b rate while false means enable 11b rate.
*
* @return
* - ESP_OK: succeed
* - others: failed
*/
esp_err_t esp_wifi_config_11b_rate(wifi_interface_t ifx, bool disable);
/**
* @brief Config ESPNOW rate of specified interface
*
* @attention 1. This API should be called after esp_wifi_init() and before esp_wifi_start().
*
* @param ifx Interface to be configured.
* @param rate Phy rate to be configured.
*
* @return
* - ESP_OK: succeed
* - others: failed
*/
esp_err_t esp_wifi_config_espnow_rate(wifi_interface_t ifx, wifi_phy_rate_t rate);
/**
* @brief Set interval for station to wake up periodically at disconnected.
*
* @attention 1. Only when ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is enabled, this configuration could work
* @attention 2. This configuration only work for station mode and disconnected status
* @attention 3. This configuration would influence nothing until some module configure wake_window
* @attention 4. A sensible interval which is not too small is recommended (e.g. 100ms)
*
* @param interval how much micriosecond would the chip wake up, from 1 to 65535.
*/
esp_err_t esp_wifi_set_connectionless_wake_interval(uint16_t interval);
**
* @brief WiFi PHY rate encodings
*
*/
typedef enum {
WIFI_PHY_RATE_1M_L = 0x00, /**< 1 Mbps with long preamble */
WIFI_PHY_RATE_2M_L = 0x01, /**< 2 Mbps with long preamble */
WIFI_PHY_RATE_5M_L = 0x02, /**< 5.5 Mbps with long preamble */
WIFI_PHY_RATE_11M_L = 0x03, /**< 11 Mbps with long preamble */
WIFI_PHY_RATE_2M_S = 0x05, /**< 2 Mbps with short preamble */
WIFI_PHY_RATE_5M_S = 0x06, /**< 5.5 Mbps with short preamble */
WIFI_PHY_RATE_11M_S = 0x07, /**< 11 Mbps with short preamble */
WIFI_PHY_RATE_48M = 0x08, /**< 48 Mbps */
WIFI_PHY_RATE_24M = 0x09, /**< 24 Mbps */
WIFI_PHY_RATE_12M = 0x0A, /**< 12 Mbps */
WIFI_PHY_RATE_6M = 0x0B, /**< 6 Mbps */
WIFI_PHY_RATE_54M = 0x0C, /**< 54 Mbps */
WIFI_PHY_RATE_36M = 0x0D, /**< 36 Mbps */
WIFI_PHY_RATE_18M = 0x0E, /**< 18 Mbps */
WIFI_PHY_RATE_9M = 0x0F, /**< 9 Mbps */
WIFI_PHY_RATE_MCS0_LGI = 0x10, /**< MCS0 with long GI, 6.5 Mbps for 20MHz, 13.5 Mbps for 40MHz */
WIFI_PHY_RATE_MCS1_LGI = 0x11, /**< MCS1 with long GI, 13 Mbps for 20MHz, 27 Mbps for 40MHz */
WIFI_PHY_RATE_MCS2_LGI = 0x12, /**< MCS2 with long GI, 19.5 Mbps for 20MHz, 40.5 Mbps for 40MHz */
WIFI_PHY_RATE_MCS3_LGI = 0x13, /**< MCS3 with long GI, 26 Mbps for 20MHz, 54 Mbps for 40MHz */
WIFI_PHY_RATE_MCS4_LGI = 0x14, /**< MCS4 with long GI, 39 Mbps for 20MHz, 81 Mbps for 40MHz */
WIFI_PHY_RATE_MCS5_LGI = 0x15, /**< MCS5 with long GI, 52 Mbps for 20MHz, 108 Mbps for 40MHz */
WIFI_PHY_RATE_MCS6_LGI = 0x16, /**< MCS6 with long GI, 58.5 Mbps for 20MHz, 121.5 Mbps for 40MHz */
WIFI_PHY_RATE_MCS7_LGI = 0x17, /**< MCS7 with long GI, 65 Mbps for 20MHz, 135 Mbps for 40MHz */
WIFI_PHY_RATE_MCS0_SGI = 0x18, /**< MCS0 with short GI, 7.2 Mbps for 20MHz, 15 Mbps for 40MHz */
WIFI_PHY_RATE_MCS1_SGI = 0x19, /**< MCS1 with short GI, 14.4 Mbps for 20MHz, 30 Mbps for 40MHz */
WIFI_PHY_RATE_MCS2_SGI = 0x1A, /**< MCS2 with short GI, 21.7 Mbps for 20MHz, 45 Mbps for 40MHz */
WIFI_PHY_RATE_MCS3_SGI = 0x1B, /**< MCS3 with short GI, 28.9 Mbps for 20MHz, 60 Mbps for 40MHz */
WIFI_PHY_RATE_MCS4_SGI = 0x1C, /**< MCS4 with short GI, 43.3 Mbps for 20MHz, 90 Mbps for 40MHz */
WIFI_PHY_RATE_MCS5_SGI = 0x1D, /**< MCS5 with short GI, 57.8 Mbps for 20MHz, 120 Mbps for 40MHz */
WIFI_PHY_RATE_MCS6_SGI = 0x1E, /**< MCS6 with short GI, 65 Mbps for 20MHz, 135 Mbps for 40MHz */
WIFI_PHY_RATE_MCS7_SGI = 0x1F, /**< MCS7 with short GI, 72.2 Mbps for 20MHz, 150 Mbps for 40MHz */
WIFI_PHY_RATE_LORA_250K = 0x29, /**< 250 Kbps */
WIFI_PHY_RATE_LORA_500K = 0x2A, /**< 500 Kbps */
WIFI_PHY_RATE_MAX,
} wifi_phy_rate_t;
/** Argument structure for WIFI_EVENT_FTM_REPORT event */
typedef struct {
uint8_t peer_mac[6]; /**< MAC address of the FTM Peer */
wifi_ftm_status_t status; /**< Status of the FTM operation */
uint32_t rtt_raw; /**< Raw average Round-Trip-Time with peer in Nano-Seconds */
uint32_t rtt_est; /**< Estimated Round-Trip-Time with peer in Nano-Seconds */
uint32_t dist_est; /**< Estimated one-way distance in Centi-Meters */
wifi_ftm_report_entry_t *ftm_report_data; /**< Pointer to FTM Report with multiple entries, should be freed after use */
uint8_t ftm_report_num_entries; /**< Number of entries in the FTM Report data */
} wifi_event_ftm_report_t;
余談