using single chip microcomputer to realize home intelligent control platform quickly

Posted by santillano at 2020-02-27

0 * 00 Preface

When it comes to smart homes, you may first think of the bull driven products, or innovative products, made by various big guy level companies. It's very complicated to think about. Some use industrial computer, some use raspberry pie, and some use Arduino. No matter what they use, they can't control around the server, such as yeelink platform, Tencent's intelligent hardware platform, etc. In fact, the real implementation, did not think so complex, we can even use a small single-chip microcomputer to achieve.

0 × 01 single chip microcomputer realizes web server

This paper discusses how to realize web server with single chip microcomputer. We can also find several articles through Baidu, but we haven't found a more detailed implementation method. There are two ways to accomplish this. One is a wired LAN module, such as w5500. This module has its own part of web service function, which is relatively simple to use, but can only be accessed based on LAN. The other is through STM32 and other single-chip computers, with the network module to complete. At present, the simplest way I can think of is to use STM32 + esp8266.

Based on the first method, I think it is greatly affected by the module performance, limited by the module, without a sense of development. So consider the second method. In this method, someone uses Arduino, which is based on C programming. In addition, it is considered to use micro python, which can be directly implemented in Python. Tpyboard v202 is still used here.

0 × 02 simulation realization of home intelligent home control platform

Because I didn't think about how complex an experiment would be, I just wanted to simulate the effect. In the whole process of the module, I chose tpyboard V202 development board is the main control board, which uses a led to simulate a lamp (in reality, a relay can be used to control the power on and off of other equipment), and a small DC motor and mini fan blade are used to represent the analog electric fan. A triode (s9014, NPN) is used to control the DC motor.

Construction and connection of 0 × 03 hardware

1. Use of LED

The LED is easy to use. Look at its two legs directly. The long one is the positive pole, and the other is the negative pole.

2. Usage of small DC motor


In the DC small motor shown in the figure above, two terminals a and B in the red frame can be connected to either the positive or negative pole, but the direction of rotation is different. This time, I connect the b-terminal to the positive pole, and it turns clockwise.

3. Usage of triode s9014 (NPN)

This time, we use the amplification and switching function of s9014. The collector is connected to the 3.3V pin of v202, and the emitter is connected to one end of the motor. We control whether the conduction between the emitter and collector is controlled by the high and low level of the base, so as to control the rotation or stop of the DC motor.

4. Wiring method

My physical connection diagram

0 × 04 implementing web server by using micro Python

First, edit a main. Py file. V202 startup file

Login.html login page

Device.html control page

Fail.html login error page (i.e. slightly changed login.html)

Info.txt here is the user name and password (separated by commas) stored in the file, with the user name in the front and the password in the back.

The user name and password here are used to log in to our smart home control platform.

0 × 05 program download test

Use the micropython file uploader tool to download the source code to v202. Tool download address:

1. Use USB data cable to connect v202 to the computer, open the device manager, and view the loaded port. My is com44

If the driver installation fails, you can download the ch340 driver and install it manually. Ch340 driver download address:

2. Open the micropython file uploader, select the port, and click [open].

3. Cancel the check of [autorun], click the folder icon in the red box, select the source code, and click [send] to wait for the sending to succeed.

4. Download the above source files to v202. After downloading, click [run / reset] to start executing the code

5. After running, the user name and password stored in info.txt will be printed in the red box, which can be customized.

6. The following is the IP address obtained by v202 from the router printed in the pink box. As long as the IP address is printed, it means that the network is successfully accessed. The IP address my v202 gets is

7. At this point, our web server is set up.

The use of 0 × 06 intelligent home network platform

1. In the home LAN, we can choose PC or mobile phone, through the browser, open to see the login interface.

2. The default user name is admin password 123456, which can be modified by modifying the info.txt file.

(1) Enter the wrong user name and password to enter the wrong interface

(2) Input correct, enter the control platform

3. Next, we can turn on the control lights and small fans through the web page to see my experimental renderings.

Here, I just made an example. Due to the time limit, I didn't do further development. You can combine your own creativity to do it in depth. If tpyboard v202 can be set up with an external IP through router, it can be accessed from the external network, so as to complete the control of the external network to the home devices.