当前位置:网站首页>K210 learning notes (II) serial communication between k210 and stm32
K210 learning notes (II) serial communication between k210 and stm32
2022-04-23 08:40:00 【PI Zhi of Engineering^_^】
List of articles
Preface
Want to use STM32 Give to through a serial port K210 Sending data , And show on the screen , Read several blogs , It's finally worked out , You can have a look if you are interested .
K210 Learning notes ( One ) K210 And STM32 Serial communication related
connection ,STM32 The serial port pin of is relatively fixed , and K210 It's like a cow , Arbitrary mapping , Good news for the lazy . Here I found two that have not been reused IO,IO9 and IO10
STM32 | K210 |
---|---|
GND | GND |
PA10(RXD) | IO10(TXD) |
PA9(TXD) | IO9(RXD) |
One 、STM32 End
I use punctual atoms STM32F103ZET6 Elite board
This serial port routine needless to say , Almost all routines are self-contained serial ports 1, Don't talk much , After the main function is initialized, it can be used directly printf Print
printf("%.2f",temp_wendu);// Print
Two 、K210
k210 The end is simpler , Than 32 It's simple . It's using microPython, Grammar is Python.
After introducing the corresponding module , To initialize . One of the most important is codec ,32 The serial port over there sends byte data , In order to UTF-8 Coded , therefore K210 The end needs to be UTF-8 Decoding can display normally .
import sensor
import image
import lcd
import time
import utime
from machine import UART
from fpioa_manager import fm
fm.register(10, fm.fpioa.UART1_TX, force=True)# Mapping serial port pin
fm.register(9, fm.fpioa.UART1_RX, force=True)# Mapping serial port pin
uart = UART(UART.UART1, 115200, 8, 1, 0, timeout=1000, read_buf_len=4096)
clock = time.clock()
lcd.init()
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.run(1)
sensor.skip_frames(30)# Skip just started 30 Frame photo
lcd.rotation(2)#LCD Screen flip , The scope is 0~3
sensor.set_hmirror(True)# Camera image
while True:
img = sensor.snapshot()# Get a picture from the camera
read_data = uart.read(5)# Read serial data , Read 5 Bytes
read_data=read_data.decode('utf-8')# Conduct utf-8 decode
if uart.read()!=None:
img.draw_string(2,2, ("temp=%s" %(read_data)), color=(0, 176, 80), scale=2)
lcd.display(img)
test result
Now we can see , Successfully received serial port data , And in LCD Displayed on the . from K210 Send out STM32 It's the same . Add one \r\n That's it . Next time we can talk about .
版权声明
本文为[PI Zhi of Engineering^_^]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230759143617.html
边栏推荐
猜你喜欢
随机推荐
DJ音乐管理软件Pioneer DJ rekordbox
Kubernetes如何使用harbor拉去私有镜像
LINQ Learning Series ----- 1.4 anonymous objects
2022-04-22 OpenEBS云原生存储
虚拟线上展会-线上vr展馆实现24h沉浸式看展
swagger文档导出自定义v2/api-docs拦截
Idea is configured to connect to the remote database mysql, or Navicat fails to connect to the remote database (solved)
Detailed description of self feeling of auricular point weight loss 0422
Overview of bus structure
Ajax cache prevention method
洋桃电子STM32物联网入门30步笔记四、工程编译和下载
Introduction to protobuf
Go语言自学系列 | golang方法
'bully' Oracle enlarged its move again, and major enterprises deleted JDK overnight...
正点原子携手OneOS直播 OneOS系统教程全面上线
word加水印
【IndexOf】【lastIndexOf】【split】【substring】用法详解
vmware 搭建ES8的常见错误
Go语言自学系列 | golang结构体作为函数参数
Shell脚本进阶