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 MicroPython displays the current latitude and longitude

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Most people do not understand the knowledge points of this article "how MicroPython displays the current latitude and longitude", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how MicroPython displays the current latitude and longitude" article.

1. About TPYBoardV702

TPYBoardV702 is the only MicroPython development board on the market that supports communication and location functions: it supports Python3.0 and above versions to run directly. Support GPS+ Beidou dual-mode positioning, GPRS communication, SMS function, phone function; on-board temperature and humidity, photosensitive, three-axis accelerometer, buzzer, LCD5110 display screen. Provide location testing service platform free of charge. The physical object is as follows:

Second, using TPYBoardV702 to complete the local temperature, humidity and luminance data collection.

1. Specific requirements

Collect the latitude and longitude of the place by using TPYBoardV702 and display it on the 5110 display screen.

2. Required devices

TPYBoardV702 development board

5110 display screen

TPYBoardV702 develops board positioning function without external connection.

3. Introduction to the function and use of onboard positioning

The overall highlight of the V702 development board is that it can locate and obtain some information about the longitude, latitude, height, time and so on of the current location. In this experiment, we will use the function of obtaining latitude and longitude.

The main hardware functions on this development board have been embedded in the development board, and it is very convenient to use. We only need to make a simple setting operation to obtain the longitude and latitude, and then carry out data analysis, segmentation, data conversion and other processing, we can get the longitude and latitude we want, and then we have finished displaying the longitude and latitude on the development board by using the display screen to display the longitude and latitude. Let's talk about the production process in detail.

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 that 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 positioning system, if we do not use the positioning system at ordinary times, in order to save power consumption, the on-board positioning system is turned off and you 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 positioning system is starting, and when the red inline indicator light ends the flash (the indicator light is in slow flashing or off state), the onboard positioning system has been activated.

(10) after completing the above work, our quasi-work has been completed, and all we need to do is to send the corresponding instructions through serial port 4, obtain the corresponding data, and then convert the corresponding data into data and display it on the display screen.

2. Specific code:

Import pybimport upcd8544from machine import SPI,Pinfrom pybimport UARTfrom ubinascii import hexlifyfrom ubinascii import * leds = [pyb.LED (I) for i in range (1pime5)] P 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) count_=0N2 = Pin (' Y3mm, Pin.OUT_PP) N1 = Pin ('Y6') Pin.OUT_PP) # defines the on-board positioning system switch pin as the output N1.low () pyb.delay (2000) N1.high () pyb.delay (10000) # by lowering and increasing the level of the switch pin Start the onboard positioning system U2 = UART (4, 115200) # define serial port 4, set baud rate to 115200i='0'w=0d=0q=0G=0j=0def DataConver (str_,flag): # prewrite data processing functions to facilitate later data processing wei_=float (str_) / 100wei_arr=str (wei_). Split ('.') Val_=100000 if flag==0:# latitude val_=10000 wei_arr [1] = str (float (wei_arr [1]) / 60 weidu=wei_arr _). Replace ('.',') weidu=wei_arr [0] +. + wei_arr [1] return weiduwhile True: pyb.LED (2). On () G=G+1 u2.write ('AT+GPSLOC=1\ r\ n') # sends instructions through serial port Command the onboard positioning system to carry out the star search operation pyb.delay (3000) _ dataRead=u2.readall () print ('search =', _ dataRead) # delay, give the system star search reaction time, improve the star search efficiency, and print the star search results pyb.delay (1000) u2.write ('AT+GPSLOC=0\ r\ n') # send instructions to obtain longitude and latitude through serial port Command the on-board positioning system to obtain pyb.delay (200) print ('BEIDOU') _ dataRead=u2.readall () # save the longitude and latitude data obtained by the serial port, if the positioning signal is not good, the returned data can be # can all be zero This situation will result in an extension of the positioning cycle if _ dataReaderreadingNone: print ('raw data =', _ dataRead) print ('raw data length:', len (_ dataRead)) if 60

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