After the beginning of summer, the temperature rises gradually. "Heat" is one of the key words of everyone in summer. How to have a cool summer?
"Turn on the air conditioner in summer!", It's cool, but it's cool! The elderly and children at home are more likely to have cold and dizziness symptoms!
"It's really embarrassing to change seasons. It's too cold to turn on the air conditioner and too hot to turn it off! Moreover, everyone has different tolerance for temperature. For example, I prefer natural wind fans."
Hearing the conversation between Lao Wang next door and Xiao Li opposite, Xiao Yang, the graffiti intelligent "siege lion", fell into meditation
In the face of hot summer, how can we cool down healthily and effectively? To benefit the old fellow of the office, Xiao Yang is brainwashed, and wants to DIY an intelligent DC inverter fan.
A meal is as fierce as a tiger. Xiao Yang's self-made version of Intelligent DC variable frequency fan has been highly praised. Everyone is scrambling to use it because of its high practical value, such as remote control and wind speed adjustment!
Such a charming electric fan, don't you want to find out?
Not much nonsense, go directly to the "smart strategy"!
First, I'd like to present the hardware design idea of breaking the scalp:
Circuit wiring reference
-
Wi Fi module and peripheral circuit wiring:
-
DC-DC conversion circuit wiring:
-
FU6832S motor control chip and peripheral circuit:
Equipment function design
functional design | detailed description |
Working mode | Normal wind Natural wind: big and small, with an interval of 15 seconds Sleep wind: automatically downshift every hour and finally downshift to the lowest gear |
Wind speed control | The encoder rotates the control fan to rotate the wind speed + clockwise and the wind speed counterclockwise- |
Mode switching | Press the encoder button briefly to switch the mode. |
Local timing | Automatic shutdown after timing, timing key: no timing - > 1 hour - > 2 hours - > 3 hours - > 4 hours - > no timing. |
Indicator display 1 | Four indicators show the wind speed, four indicators indicate the wind speed of gear 8, flashing represents gear 1, and constant light represents gear 2. The four indicators also multiplex the local timing indication. |
Indicator display 2 | There are 8 LEDs. In addition to 4 LEDs indicating wind speed, there are 4 indicators. A Wi Fi indicator light to indicate Wi Fi status; The other three indicate the current fan mode. |
Power Supply | The power button controls the start and power-off status of the fan |
Equipment distribution network | Long press the Wi Fi button, and the device enters the distribution network mode |
Indicator light adjustment
Power off memory | The brightness of LED indicator can be adjusted through App, normal brightness and darker brightness
Automatic recovery of equipment after power on |
Physical assembly
Motor drive board and voltage conversion board:
Wi Fi module control panel:
Create product
The following is Xiao Yang's graffiti IoT development platform to make the DC variable frequency fan truly networked and intelligent.
1. Enter the product creation page of doodle IoT platform.
2. Create a fan product. When creating a product, select "small appliances > fan", the development scheme is confirmed as a user-defined scheme, and the communication mode is Wi Fi.
3. When setting DP, you need to consider the fan function you want to add and map it one by one with the function setting of embedded development.
4. After selecting the panel, enter the hardware development stage. At this time, select the graffiti standard module SDK development as the cloud connection mode, and select the CBU module as the communication module.
Embedded function development
This software development is based on the graffiti IoT cloud platform and the current main CBU module. You can get the module by participating in the activity.
The SDK compilation of graffiti is generally compiled and developed under Linux, and the virtual machine needs to be installed. It should also be possible under Windows, but the compilation speed is a little slow. More detailed development information, Poke me
Problems in the development process
1. Restart when adjusting gear
In the case of testing after the completion of development, it is found that rotating the rotary encoder quickly on the board will cause the system to be uncontrolled and restart. After Xiao Yang's analysis, it is found that it is caused by the external interrupt mode used by the rotary encoder. Because the encoder has been rotating, the system is in the external interrupt state, and other tasks cannot be executed normally, resulting in system restart.
Solution: set the encoder trigger judgment to the form of task, and judge the level processing regularly. After the system is restarted, the problem will be basically solved.
void key_rotary_task(void){ INT8_T current_gear; while(1) { //Get current gear_ gear = get_ cur_ gear(); If ((tuya_gpio_read (key_rotary_a) = = false) & & (fan_state. On_off! = false)) {while (tuya_gpio_read (key_rotary_a) = = false); if (tuya_gpio_read (key_rotary_a)! = tuya_gpio_read (key_rotary_b)) {pr_notice ("a! = B"); / / clockwise current_gear + +; if (current_gear > (max_gear_number-1) ) { current_gear = (MAX_GEAR_NUMBER-1); } fan_ state. speed = g_ fan_ speed_ gear[current_gear]; } Else {pr_note ("a = = B"); / / counterclockwise current_gear --; if (current_gear < 0) {current_gear = 0;} fan_ state. speed = g_ fan_ speed_ gear[current_gear]; } /* Change fan status: wind speed, mode, led * / change_ fan_ state(); write_ flash_ fan_ state(); PR_NOTICE("fan current_gear is : %d", current_gear); } tuya_hal_system_sleep(50); }} / / create the task void in the initialization function_ T fan_ key_ init(VOID_T){ ...... tuya_hal_thread_create(NULL, "key_rotary_task", 512*4, TRD_PRIO_5, key_rotary_task, NULL);}
2. The device occasionally fails to distribute the network
Xiao Yang said: this problem usually occurs after the development is completed. After some analysis and confirmation, it is found that it is caused by the operation of the equipment during the distribution network and the equipment has to be reported to DP point.
Solution: add a little judgment to the report function and make it work immediately! (that is, the following five lines to determine whether to connect to the router)
/** * @Function: hw_report_all_dp_status * @Description: Report all dp points * @ Input: none * @Output: none * @Return: none * @Others: */VOID_T hw_report_all_dp_status(VOID_T){ OPERATE_RET op_ret = OPRT_OK; INT_T dp_cnt = 0; dp_cnt = 4; /* Not connected to router, exit */ GW_WIFI_NW_STAT_E wifi_state = STAT_LOW_POWER; get_wf_gw_nw_status(&wifi_state); if (wifi_state <= STAT_AP_STA_DISC || wifi_state == STAT_STA_DISC) { return; } TY_OBJ_DP_S *dp_arr = (TY_OBJ_DP_S *)Malloc(dp_cnt*SIZEOF(TY_OBJ_DP_S)); if(NULL == dp_arr) { PR_ERR("malloc failed"); return; } memset(dp_arr, 0, dp_cnt*SIZEOF(TY_OBJ_DP_S)); dp_arr[0].dpid = fan_state.dp_id_switch; dp_arr[0].type = PROP_BOOL; dp_arr[0].time_stamp = 0; dp_arr[0].value.dp_bool = fan_state.on_off; dp_arr[1].dpid = fan_state.dp_id_mode; dp_arr[1].type = PROP_ENUM; dp_arr[1].time_stamp = 0; dp_arr[1].value.dp_enum = fan_state.mode; dp_arr[2].dpid = fan_state.dp_id_speed; dp_arr[2].type = PROP_VALUE; dp_arr[2].time_stamp = 0; dp_arr[2].value.dp_value = fan_state.speed; dp_arr[3].dpid = fan_state.dp_id_bright; dp_arr[3].type = PROP_VALUE; dp_arr[3].time_stamp = 0; dp_arr[3].value.dp_value = fan_state.bright; op_ret = dev_report_dp_json_async(NULL ,dp_arr,dp_cnt); Free(dp_arr); if(OPRT_OK != op_ret) { PR_ERR("dev_report_dp_json_async relay_config data error,err_num",op_ret); } PR_DEBUG("dp_query report_all_dp_data");}
So far, our "siege lion" Xiao Yang has successfully completed the development of Intelligent DC variable frequency fan. Although he encountered some "difficult and miscellaneous problems", they have also been solved!
In hot summer, it's so simple to send soft and healthy "smart wind" to family and friends, and "blow away" the many troubles caused by air conditioning. Are you excited?
Note: This article comes from Yang Jie, an intelligent graffiti engineer. It has been reprinted with authorization. It cannot be reprinted without my consent and cannot be used for other purposes.
Poke me , DIY exclusive intelligent fan ~ heart is better than heart~