3795 views|6 replies

5

Posts

0

Resources
The OP
 

【RT-Thread software package application works】Multi-function weather clock [Copy link]

 

Multifunctional Weather Clock-WeChat Mini Program

1. Project Background
One morning not long ago, I was woken up by an alarm and went to work as usual. When I arrived at the company, I found that many colleagues brought umbrellas, so I opened the brick ( mobile phone ) in my pocket . When I went back at night, I was drenched. Although the rain was not heavy, it was always unpleasant to be drenched. So I began to think about whether I could make a weather clock to save me and my friends who go out without checking the weather like me, blah blah ... 2.

Project Skills
This project is developed using the RT_Thread domestic operating system. Its rich software packages greatly shorten the development cycle. This project mainly uses the following software packages :
1.onenet: The device
connects to onenet through mqtt 2.webClient: Get weather 3.ntp: Synchronize network time 4.cJSON: Parse the data sent by the applet 3. Project Framework 1. The overall interaction logic diagram is as follows:






2. The device block diagram is as follows:

2.1.LCD display

LCD displays the temperature, humidity and current time collected by DHT11

2.2.Buzzer

When the timer is up, the buzzer will keep sounding until the user presses the K0 button to stop the sounding.



4. Core technical points of the project
1. MQTT connects to OneNet

Theoretically, connecting MQTT to OneNet should be a challenging part of this project. Fortunately, rt_thread officially provides a software package, which can be used directly after configuration using the env tool .

2. Timing logic processing

This project creates a time processing thread. After the thread starts, it first waits for the network connection to succeed, then calls the ntp interface to synchronize the network time. Next, it enters the while(1) loop to obtain the current time every 500ms and compare it with the locally stored timer. If the current time is equal to the saved time, the alarm action is executed and the buzzer sounds.

3. Weather acquisition logic processing

Create a weather processing thread. After the thread starts, it first waits for the network to be successfully connected, then obtains the weather conditions and sends them to onenet. The applet obtains and displays them. Then it obtains the weather conditions and synchronizes the ntp network time every hour.

void weather_task_thread(void* arg)
{
    int a =0;
	uint8_t *p = &a;
	USER_TIME_S current_time = { 0x00 };

    // user_dev_time_flash_read();
    while (4 != user_get_connect_status()->connect_status)
    {
        rt_thread_delay(1);
    }
    
    rt_thread_delay(3);
    rt_kprintf("################################### start to get weather");
    weather();

	while ( 1 )
	{
		user_get_time(¤t_time);
        if ((0 == current_time.hour)  && (0 == current_time.minute) && (0 == current_time.second) )
        {
            rt_kprintf("########################## sync weather and ntp time #####################\r\n");
            weather();
            user_sntp_time_synced();
        }

        rt_thread_mdelay(1000);
	}
}

4. Mini Program access to OneNet

The applet uses http to access onenet, obtains onenet data every 3 seconds, updates the device status, and directly operates the following onenet API interface to control and obtain the device status:

5. Project effect demonstration

6. Program source code

Mini program:

链接已隐藏,如需查看请登录或者注册

Device side:

链接已隐藏,如需查看请登录或者注册


This content is originally created by EEWORLD forum user Yiye Gusha . If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

Latest reply

Hihi Your work won the third prize. Please remember tonight's RTT official account.   Details Published on 2020-1-6 16:36
 

1025

Posts

1

Resources
2
 

8266 is widely used for weather forecast

 
 
 

5791

Posts

44

Resources
3
 

Awesome

 
Personal signature

射频【放大器】

 
 

5

Posts

0

Resources
4
 
wudianjun2001 posted on 2019-12-11 14:31 8266 is used more for weather forecast

Yes, that's right. Actually, you can do it with any WIFI connection.

 
 
 

46

Posts

0

Resources
5
 

Looks really awesome, not bad!

 
 
 

80

Posts

1

Resources
6
 

Hihi Your work won the third prize. Please remember tonight's RTT official account.

 
 
 

5

Posts

0

Resources
7
 
Fillmore posted on 2020-1-6 16:36 hihi Your work won the third prize, remember the audience tonight RTT's public account

Thank you~

 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list