Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Intelligent temperature Control small Fan by Micropython

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces Micropython how to achieve intelligent temperature control small fan related knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe that after reading this Micropython how to achieve intelligent temperature control small fan article will have a harvest, let's take a look.

1. Experimental purpose

1. Learn the method of extending the simple Iripple O interface in the PC system.

two。 Further learn the design method of compiling data output program.

3. Learn the wiring method of DS18B20 and use DS18B20 to detect the current temperature.

4. Learn the use of Triode 9014.

5. DC motor is intelligently controlled by 18B20 to drive small fan.

two。 Required components

TPYBoard board

A DC motor

A piece of bread

A data line

Triode 9014 (NPN) one

Some DuPont lines

3. Learn the wiring method of DS18B20 and detect the current temperature

First, take a look at the meaning of DS18B20 pins, as shown in the figure above:

The corresponding relationship between the pins of TPYBoard and those of DS18B20 is as follows:

If you still don't understand, just put the pin number on it.

After connecting to ok, in the source directory of MicroPython, go to the drivers\ onewire\ directory, and then copy the files ds18x20.py and onewire.py in the directory to the root directory of the PYBFLASH disk. Copy the file to safely exit the disk, and then re-access, otherwise can not find the file, you can run the main.py file, print temperature, you can use Putty to see the current temperature.

Main.py source code:

# main.pyimport pybfrom pyb import Pinfrom ds18x20 import DS18X20Pin ("Y11", Pin.OUT_PP). Low () # GNDPin ("Y9", Pin.OUT_PP). High () # VCCpyb.delay (100) DQ=DS18X20 (Pin ('Y10')) # DQwhile True: tem = DQ.read_temp () print (tem) pyb.delay (1000)

4. The principle of Triode

Here we use the switching and amplification function of the transistor to control the current on and off of the DC motor at different levels of the base in order to control the rotation of the motor. according to the characteristics of the transistor, we connect the collector to the 3.3v of TPYBoard, the emitter to one pole of the motor, and the motor to the GND of TPYboard. The temperature is detected by the temperature sensor 18B20. When the temperature reaches the specified temperature, the level of the Triode base is controlled by TPYBoard. Drive DC motor to rotate.

source code

# main.pyimport pybfrom pyb import Pinfrom ds18x20 import DS18X20Pin ("Y9", Pin.OUT_PP). High () # VCCPin ("Y11", Pin.OUT_PP). Low () # GNDx1 = Pin ('X1, Pin.OUT_PP) pyb.delay (100) DQ=DS18X20 (Pin ('Y10')) # DQwhile 1: tem = DQ.read_temp () if tem > 18: x1.value (1) else: x1.value (0)

After we follow the above steps, then turn on the power and write the main.py file, we can control the rotation of the fan through the temperature.

This is the end of the article on "how to realize intelligent temperature control small fan in Micropython". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to achieve intelligent temperature control small fan in Micropython". If you want to learn more knowledge, welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report