查看Noduino OpenPlant的源代码
←
Noduino OpenPlant
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
== 低功耗优化 == === Base === * <s>Transfer to use raw sdk</s> done * <s>Disable Ping</s> done * <s>Change the mode of mcp342x to One-Shot Conversion with 1 SPS</s> done <br><br> === phy_get_vdd33() === Remove the mcp342x, use the internal phy_get_vdd33() system_get_vdd33 功能: 测量 VDD3P3 管脚 3 和 4 的电压值,单位:1/1024 V * system_get_vdd33 必须在 TOUT 管脚悬空的情况下使⽤,'''否则值不准''' * TOUT 管脚悬空的情况下,esp_init_data_default.bin(0~127byte)中的第 107 byte 为 "vdd33_const",必须设为 0xFF,即 255,'''否则总是返回 65535''' <br> === Deep Sleep === http://wiki.jackslab.org/ESP8266_Sleep#Deep_Sleep <source lang=cpp> #define __SET__DEEP_SLEEP__WAKEUP_NO_RF__ system_deep_sleep_set_option(4) #define __SET__DEEP_SLEEP__WAKEUP_NORMAL__ system_deep_sleep_set_option(1) system_deep_sleep(100000); During deep sleep, only RTC still working, so you can save some user data in RTC memory. Only "user data" area can be used by user #define RTC_RAM_BASE 0x60001000 // Size: 1024 bytes #define RTC_MEM_BASE 0x60001100 0x60001000 0x100 rtcb RTC backup memory, see rtc_mem_backup 0x60001100 0x300 rtcmem RTC semi-persistent memory, see system_rtc_mem_write |-------- system data --------|-------- user data --------| | 256 bytes | 512 bytes | | 256/4 = 64 block | 128 block | rtc time use the first 24 bytes of user data area void system_deep_sleep_instant(uint32 time_in_us); </source> '''Notice:''' Seems like the system timer of WiFi is working when chip is in deep sleep, so you need to disable the all timers ... <br> === Example === <source lang=cpp> #define SENSOR_DATA_NUM 20 #define SENSOR_DATA_MEM_ADDR 120 #define INIT_MAGIC 0x7e7e55aa typedef struct{ uint32 init_flg; uint16 cnt; uint16 wifi_config; uint16 data[SENSOR_DATA_NUM]; }SENSOR_DATA_RTC_MEM; SENSOR_DATA_RTC_MEM sensor_data; void ICACHE_FLASH_ATTR data_func() { // Read out the sensor data structure from RTC memory system_rtc_mem_read( SENSOR_DATA_MEM_ADDR, &sensor_data, sizeof(SENSOR_DATA_RTC_MEM) ); // When the system powers on for the first time, the data in the rtc memory is random. struct esp_platform_saved_param esp_param_t; user_esp_platform_load_param(&esp_param_t); // Stored in flash // Load user params to check if the device was successfully registered to the server // If it wasn't, it usually returns 255 (from the flash.) if(sensor_data.init_flg!=INIT_MAGIC || sensor_data.cnt>SENSOR_DATA_NUM ) { // This case runs when we first power on or when it time to flush the RTC memory of old data. if(esp_param_t.activeflag!=1) { // If registered & activated user_esp_platform_init(); // Router is not configured. Setup softAP. Wait for config. user_webserver_init(SERVER_PORT); } else { // was connected! So we set init magic to exit the setup loop sensor_data.init_flg = INIT_MAGIC; sensor_data.cnt = 0; system_rtc_mem_write(SENSOR_DATA_MEM_ADDR, &sensor_data, sizeof(SENSOR_DATA_RTC_MEM)); __SET__DEEP_SLEEP__WAKEUP_NO_RF__; system_deep_sleep(100000); } } else { // This is where the measurements are made uint16 vdd_val = 0; if(sensor_data.cnt<0 || sensor_data.cnt>=SENSOR_DATA_NUM) sensor_data.cnt=0; // range check and resets counter if needed /* Reads power supply voltage, byte 107 of init_data.bin should be set to 0xFF. * Replace with your own code.*/ sensor_data.data[sensor_data.cnt++] = (uint16)(phy_get_vdd33()); system_rtc_mem_write( SENSOR_DATA_MEM_ADDR, &sensor_data, sizeof(SENSOR_DATA_RTC_MEM) ); // Setup next sleep cycle if(sensor_data.cnt==SENSOR_DATA_NUM-1) { __SET__DEEP_SLEEP__WAKEUP_NORMAL__; } else { __SET__DEEP_SLEEP__WAKEUP_NO_RF__; } // Uploads or go to sleep if(sensor_data.cnt == SENSOR_DATA_NUM) { user_esp_platform_init(); } else { system_deep_sleep(SENSOR_DEEP_SLEEP_TIME); } } } </source> <br> === TX Power === <pre> 函数: void system_phy_set_max_tpw(uint8 max_tpw) 功能: 设置 RF TX Power 最大值,单位:0.25dBm 参数: uint8 max_tpw : RF Tx Power 的最大值,可参考 esp_init_data_default.bin(0 ~ 127byte)的第 34 byte (target_power_qdb_0) 设置,单位:0.25dBm,参数范围 [0, 82] </pre> <pre> 函数: void system_phy_set_tpw_via_vdd33(uint16 vdd33) 功能: 根据改变的 VDD33 电压值,重新调整 RF TX Power,单位:1/1024 V 注意: 在 TOUT 管脚悬空的情况下,VDD33 电压值可通过 system_get_vdd33 测量获得。 在 TOUT 管脚接外部电路情况下,不可使用 system_get_vdd33 测量 VDD33 电压值。 参数: uint16 vdd33 : 重新测量的 VDD33 值,单位:1/1024V,有效值范围:[1900, 3300] </pre> <br><br>
返回到
Noduino OpenPlant
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面