Talk about the mental journey of being an embedded IoT device~

Preface

The reason I think of this topic is because at the beginning of 2021, a friend found me on WeChat and asked me about what I have done recently and helping to debug some equipment problems. I have not done this for a long time. . However, I have been paying attention to the dynamics of the Internet of Things industry and stick to my hobbies. I also hope that in the next year, I can develop my hands-on skills and take the time to gradually try to make small modules of the Internet of Things. The overall plan, and picked up the drawing PCB, 3D printing molds, in-depth understanding of the Internet of Things equipment, try to design an overall plan of the Internet of Things smart home.

origin

The reason is that the topic of smart home in 16 years is very lively. After waves of waves on the Internet, the wind slowly began to turn to physical things. That year VR became popular, and Google Glass became popular. All kinds of smart hardware seem to make people instantly feel that technology is about to bring a very cool experience to people's lives. I also bought an 8266 wifi module that year, which was so cheap, and it was able to connect to the wifi internet, and control the light off and the action of the device through the mobile phone. I thought it was very interesting, so I firmly wanted to do such a cool thing. So I bought some development boards to play by myself, and I had a good time, but when I was really looking for a job, I found that no company did this. Everyone was still doing industrial control, consumer electronics, and non-networked things. For work, I can only keep this love in my heart. But during that period of time, I kept paying attention to WiFi, zigbee, nbiot modules, etc., and I would buy some and play by myself. But it is hardly used in actual work.

Later, the thing that really came into contact with the Internet of Things in my work was around 18 years. The zigbee module was needed to make smart locks. So in the process of debugging the use of zigbee, I gradually developed a basic understanding of the Internet of Things products. The understanding of the framework, including the processing of data, the flow of data, and the processing flow of various low-power modes, the collaboration flow between the module and the master, the communication between the module and the gateway, and the gateway and the server The interaction between mobile apps and devices, etc. Through this debugging experience, I learned the business logic, interaction logic and effect optimization design method of an actual IoT product. At the same time, it also made me more interested in IoT devices.

Because it mainly does zigbee device end, data flow sequence, complete implementation details of interface, and data distribution and interface display of server business. These are not completely transparent to me. I have established a certain connection between the zigbee device and the gateway. So I also think this is my hobby, and it is also something I have always wanted to figure out.

Smart water meter project

Due to some unpredictable factors and coincidences, I went to do a smart water meter project. This project is actually a smart operation and maintenance friend who asked me to do this project. And the server and protocol are actually protocols and servers consistent with smart operation and maintenance. At the beginning, I was doing smart operation and maintenance. Operation and maintenance was about monitoring environmental protection projects and uploading some data indicators to the server, and the APP could be used to open valves or pumps, etc.

At that time, I remember that when I took over this project, there were a lot of bugs, various control failures, crashes, and timing control could not be done. I took a look at the code and proposed to change the framework of the protocol layer, because I found that drivers and services are mixed together. All system services are pieced together for the purpose of implementing functions. I think this is a program for IoT devices. Big bogey, because networking modules will change at any time. Now we use gsm, maybe 4g modules or nbiot, etc. will be used later. In this way, module replacement and code refactoring require a lot of work and low efficiency. I started with the protocol framework first. According to the black box model, only input and output are concerned. What is exposed is the function callback interface. In this way, when I need to use the protocol, I can implement this callback function. In this way, the agreement was reconstructed.

Then I started working on the smart water meter project. The smart water meter project is a new requirement. From the determination to do, the selection, the program evaluation, the software evaluation, the coding, the test, the delivery, and the middle is actually one month time. What I did at that time was to connect a remote bc26 module to the stm8l main control chip, to connect the reed switch and drive motor. The requirement at that time was to be less than 1ua, powered by dry batteries. At the beginning, the proofing of the board had not come out, so I used the development board to do prototype verification, write various drivers, do low power consumption, do debugging of the bc26 nbiot program, query signals, networking, data transmission, power off, and low power wake-up. The prototype verification in the early stage is almost done, and the integration of the business is started. In fact, only the protocol control needs to be done well. The business logic actually follows the protocol interface. Some experience has been accumulated in this part, and all can be considered handy. The most difficult part of this project is low power consumption and server joint debugging. The difficulty of low power consumption is how to find a way to reduce the power consumption of the board to the minimum. During that time, if the current in the low power mode is found to be too high, you need to remove the capacitor or resistor of the hardware, do a test, and take a test. How much to reduce, keep trying gpio mode, so as to reduce the low power consumption to the best mode. The joint debugging of the server is impossible to communicate. Every time you have to say a lot, the server does not understand what the embedded side does, let him see if the connection is connected, and the server focuses on whether there is data . This is very troublesome and the communication cost is too high. So simply set up a test environment locally and send test data to test the networking, disconnection, and reconnection mechanisms. Connect the server and port after no problem.

Until the device is online and the app can be controlled to complete the project, after the smart water meter is finished, it is actually put on the water meter for testing, and the water flows through the rotating gear, so that the reed switch is close to the magnet, which triggers the counting operation. Then the app can control the opening and closing of the water valve. Although this project only performed the functional evaluation phase of the first phase, I did not pay attention to later promotion and sales, so I went on vacation. But from the overall project, the biggest experience for me is that there are actually some obstacles to the communication between the device and the server. The business logic of the IoT device should mainly be done on the server, and the response from the device is actually large. Some of them are operated according to specific instructions given by the server, or actively report data. My feeling is that the server business volume of the Internet of Things project is much more complicated than the embedded end, and the concurrent volume of multiple devices must be able to handle It's OK.

Smart Identity Project

In 19 years, it can be said that I was almost at the stage of trying various things, and I thought I could try everything I thought. So I tried to join a company that is engaged in the Internet of Things. I remember asking a question during an interview at that time, I said whether the company can really make a profit for this Internet of Things project. Of course, the conclusions obtained are similar to what I predicted. In fact, it is not profitable, just stick to the day when IoT devices are up.

I remember that I went to Beijing the day after I joined the company because there was a smart sign project for Daxing Airport at that time, and the destination was Beijing Daxing Airport. I was a little excited to work on such a high-end project. For smart signs, it is actually a very typical application scenario in the Internet of Things project, through remote monitoring, remote control, timing control, data statistics to quantify and control current, voltage and fault alarms. On the one hand, this can solve the problem of unattended operation, and on the other hand, it can also quantify the data of electricity consumption, thereby saving power consumption and use.

The process of debugging the program is mainly to do the protocol control of the device, and the other is to upload the sensor data. Since it uses three-phase power, there is no need to pay attention to low power consumption. In addition, the focus and difficulty of this project is the expansion of the ota program and agreement. At that time, there were a lot of people who worked on the project, including equipment-side, server, app, front-end, and operation and maintenance. Everyone or two or three people are responsible for a piece of business. Because everyone has just graduated, so when they are resting, they will go out together to go shopping in Beijing. Although the work is hard, it is enough to have fun.

Business coordination and debugging is a continuous process. After the data from the device is sent, the server needs to process the data, and then hand it to another server. At this time, the app and the front-end use the port given by the server to obtain the data in the specified format. , Parse and display after getting it. This part is easy to lose the chain. The front end says that there is no data, and the server may say that the device is not uploaded. As a result, the device is uploaded. The server checks that the data is blocked. Anyway, this kind of problem happens every day. Fortunately, the working atmosphere is very good and everyone is very cooperative. In fact, I am responsible for the cloud, terminal, tube, platform, and the device side among these, focusing on the acquisition and upload of specific sensor parameters, as well as the processing of instructions issued by the server, and the ota solution, and The disconnected reconnection mechanism, this part consumes a lot of time and energy to design. Then there is a more stable program output.

to sum up

Writing this article is mainly to review my mental journey when I did the Internet of Things. In fact, the technical difficulty of the Internet of Things equipment is lower than that of some projects I have done, but I still think this is a very interesting thing. The level of technology is not the only criterion for measuring the quality of a thing. In fact, it is the convenience that a thing brings to people and its cultural value and social attributes. Although technology is important, I think programmers should also pay attention to their own vision and ability to handle things, and they also need to cultivate their own hands-on skills at all times.

I have done a few Internet of Things projects, and I feel more profound about the following points: The first is that the networking module on the device side must be handled well, and the disconnection reconnection mechanism must be perfect. The second is that the protocol layer framework must be very clear, one protocol does one thing, and don't couple too many businesses. The third is that the equipment must be absolutely stable and reliable for long-term operation. Fourth, the connection with the server must have a response mechanism. Fifth, the business on the device side of the Internet of Things is as refined and simple as possible.

The development of Internet of Things devices today is not as popular as imagined, nor has it spread to thousands of households, but you can slowly see it gradually appearing in life. Internet of Vehicles, Internet of Things, smart homes, etc., the Internet of Everything is actually not a difficult task. Things have their own attributes, sensors are used to detect and quantify data, and the laws of things are analyzed through data.

1. The domestically-made alternatives are intangible? Come back to the Zhaoyi Innovation Live Class!

2. Can the open source RISC-V be the antidote to China's "core shortage"?

3. Raspberry Pi Pico: MCU for only $4

4. There are many reasons why MCU supports AI function~

5. In 2020, 20 software engineering principles I learned~

6. The application of state machine ideas in embedded development~

Disclaimer: This article is reproduced online, and the copyright belongs to the original author. If you are involved in copyright issues, please contact us, we will confirm the copyright based on the copyright certification materials you provide and pay the author's remuneration or delete the content.

Guess you like

Origin blog.csdn.net/DP29syM41zyGndVF/article/details/113361515