In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to achieve the caller ID function in Micropython". In the daily operation, I believe many people have doubts about how to achieve the caller ID function in Micropython. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to achieve caller ID function in Micropython". Next, please follow the editor to study!
1. Introduction of TPYBoardV702
TPYBoardV702 is the only MicroPython development board on the market that supports communication functions: it supports Python3.0 and above versions to run directly. Support GPS+ Beidou dual-mode communication, GPRS communication, SMS function, phone function; board temperature and humidity, photosensitive, three-axis accelerometer, buzzer, LCD5110 display screen. Communication test service platform is provided free of charge.
Second, use TPYBoardV702 to receive the prompt call, and display the incoming call number and the caller's name on the display screen.
1. Specific requirements
Use TPYBoardV702 to receive the prompt call, and display the incoming call number and caller's name on the display screen.
2. Required devices
TPYBoardV702 development board
5110 display screen
One Gsm mobile phone card
TPYBoardV702 develops board GSM communication function without external connection.
3. Introduction to the function and use of onboard communication
The overall highlight of the V702 development board is the on-board communication function, which can be used as long as a usable mobile phone card is inserted into the card slot of the development board (does not support telecommunications).
The communication functions on the development board include phone, SMS, GPRS and other functions. In this experiment, we only use the phone function.
The communication function on the development board has been well designed. When receiving an incoming call, we will actively send the information of the incoming call through serial port 4. In this way, as users, we just need to process and display the data accordingly.
Third, the main process of production
Let's start with the previous picture, and then we'll talk about the code.
1. Production process
(1) the first thing we need to do is to plug the 5100 display screen into the 5110 display interface of the 702 development board.
(2) after the above work is completed, we need to use the main class library, 5110 class library, and we need to copy the .py file of this class library to the drive letter of the development board.
(3) after completing the above work, we begin to edit the main (). Py file code
(4) declare and define the class libraries that need to be used
(5) define the variables we need to use.
(6) declare and define the interfaces we need to use. Here we mainly use spi1 and serial port 4. When declaring serial port 4, we need to set the serial port baud rate to 115200.
(7) Let's start the writing of the main function. In this experiment, we use the display. We initialize the display at the beginning of the program.
(8) after completing the initialization of the display part, the most important thing we need to do is to define the "Y6" pin as the output, then pull the "Y6" pin down for more than two seconds, and then pull the pin up. Because the "Y6" pin is a switch that controls the opening of the entire on-board communication system, if we do not use the communication system at ordinary times, in order to save power consumption, the on-board communication system is turned off and only need to lower the "Y6" pin for more than two seconds.
(9) when the red inline LED light on the development board is flashing quickly, it means that the onboard communication system is starting, and when the red inline indicator light ends the flash (if the mobile phone plugged into the development board slot is available, the indicator is in slow flash state), it means that the onboard communication system has been activated.
(10) after the above work is completed, the preparation work has been completed, and all that needs to be done is to monitor whether data is sent from serial port 4. When it is detected that data is sent from serial port 4, the data is judged and processed accordingly. And display it on the display screen.
2. Specific code:
The above content of import pybimport upcd8544from machine import SPI,Pinfrom pybimport UARTfrom ubinascii import hexlifyfrom ubinascii import * # is the class library used in the declaration leds = [pyb.LED (I) for i in range (1Mague 5)]. MOSI 'X8' data flow (Master out). Slave in) # CLK = > SPI (1). SCK 'X6' SPI clockRST = pyb.Pin (' X20') CE = pyb.Pin ('X19') DC = pyb.Pin (' X18') LIGHT = pyb.Pin ('X17') lcd_5110 = upcd8544.PCD8544 (SPI, RST, CE, DC, LIGHT) # the above is declared and initialized the display count_=0N2 = Pin (' Y3, Pin.OUT_PP) # defines "Y3" as the output mode This pin controls the buzzer, incoming call # need to ring N1 = Pin ('Y6, Pin.OUT_PP) # define "Y6" bit output mode "Y6" pin is the switch control of onboard communication system # pin N1.low () pyb.delay (2000) N1.high () pyb.delay (10000) # start the communication system U2 = UART (4, 115200) # set serial port 4 and set serial baud rate to 115200i='0'w=0d=0q=0G=0j=0while 00): # detect whether serial port 4 has data by pulling low and high open light control pin If there is any data, execute the following _ dataRead=u2.readall () if _ dataReadworthy NoneRose # to determine whether the data of serial port 4 is empty or not Do not execute the following code print ('raw data =', _ dataRead) print ('raw data length:', len (_ dataRead)) print ('123 raw data Read [2:6]) RING=_dataRead [2:6] # intercept the header This packet header is important to judge whether the data is correct. According to print ('111century recording journal [18:29]) HM=_dataRead [18:29] # the 18 to 29 digits of the data are the mobile phone numbers carried in the data. We save it out and WD='No such person'# sets a variable, which we can call the phonebook comparison # quantity, mainly as a display of who calls, such as showing Zhang San. # or Li Si if (RING==b'RING'): # determine that the packet header is correct, execute the following code if (HM==b'18654868920'): # determine whether the incoming call is a stored number WD='TPYBoard_GPS'# if it is Display the storage name, if no storage shows'No # such person'#** time * N2.high () # pull up the buzzer control pin Make the buzzer ring lcd_5110.lcd_write_string ('Phone Number:',0,0) lcd_5110.lcd_write_string (HM.decode ("utf8"), 2 The contact:',0,2 1) lcd_5110.lcd_write_string (' The contact:',0,2) lcd_5110.lcd_write_string (str (WD), 0Jing 3) # display the corresponding incoming call number Caller title # and other pyb.delay (1000) so far, the study on "how to achieve the caller ID function in Micropython" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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: 266
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
The Now Platform supports programmatic retrieval of PDF data through an HTTP GET request.The request
© 2024 shulou.com SLNews company. All rights reserved.