当前位置:网站首页>ESP32 485光照度
ESP32 485光照度
2022-08-05 04:32:00 【咸鱼箘】
气象站基础呀
RS-485仅是一个电气标准,描述了接口的物理层,像协议、时序、串行或并行数据以及链路全部由设计者或更高层协议定义。
RS-485定义的是使用平衡(也称作差分)多点传输线的驱动器(driver)和接收器(receiver)的电气特性。
材料及接线
ESP32
单片机TTL转RS485模块
接线说明
开发板 | TTL转RS485模块 |
---|---|
22 | TXD |
23 | RXD |
5v | VCC |
GND | GND |
485光照度
采用工业级芯片,高精度进口光照传感器。采用RS485硬件接口,协议层兼容标准的工业Modbus-Rtu协议。
接线说明
TTL转RS485模块 | 485温湿度传感器 | 开发板 |
---|---|---|
A+ | TXD_A 黑线 | |
B- | RXD_B 黄线 | |
5v | 5V 红线 | |
GND | GND 绿线 |
PS:基本485的接线都一样了
示例程序
获取光照度
此485传感器范围0~200000Lux
勒克斯(lux,法定符号lx)照度单位,1 勒克斯等于 1流(lumen,lm)的光通量均匀分布于 1㎡ 面积上的光照度。
1 lx大约等于1烛光在1米距离的照度,我们在摄像机参数规格中常见的最低照度(MINIMUM.ILLUMINATION),表示该摄像机只需在所标示的LUX数值下,即能获取清晰的影像画面,此数值越小越好,说明CCD的灵敏度越高。同样条件下,黑白摄像机所需的照度远比尚须处理色彩浓度的彩色摄像机要低10倍。
一般情况:夏日阳光下为100,000 lx;阴天室外为10000 lx;室内日光灯为100 lx;距60W台灯60CM桌面为300lx;电视台演播室为1000 lx;黄昏室内为10 lx;夜间路灯为0.1 lx;烛光(20CM远处)10~15 lx。
PS:我买的485光照是可以测室外的毕竟范围有20Wlx 而夏日的阳光就有10Wlx。所以如果测的是室外,买的时候问清楚量程。 室内的是0~65535lx
from machine import UART
#ESP32可以映射引脚,初始化的时候设置就行,串口号一般设置成2(0和1尽量别用。)
import time
uart= UART(2, baudrate=9600, bits=8, parity=None, rx=22,tx=23, stop=1, timeout=100)
barray = bytearray([0x01,0x03,0x00,0x02,0x00, 0x02 ,0x65 ,0xcb]) #问询帧
while True:
uart.write(barray)
time.sleep(1)
if(uart.any()):
u2by=uart.read() # 返回的是答应帧的内容
aa=u2by
G10 = int.from_bytes(aa[3:5],'big') # 十位
G1= int.from_bytes(aa[5:7],'big') # 个位
GZ=G10*10+G1
print(GZ,"LUX")
串口输出光照值,我在室内测的哈
修改地址
除此之外我们同样可以配置地址。
如下地址配置成功,我现在的传感器地址就是00
>>> from machine import UART
>>> uart= UART(2, baudrate=9600, bits=8, parity=None, rx=22,tx=23, stop=1, timeout=100)
>>> barray = bytearray([0x00,0x06,0x00,0x20,0x00, 0x01 ,0x48 ,0x11])
>>> uart.write(barray)
8
>>> u2by=uart.read()
>>> print(u2by)
b'\x00\x06\x00 \xe1\xfd'
我们可以测一下
from machine import UART
#ESP32可以映射引脚,初始化的时候设置就行,串口号一般设置成2(0和1尽量别用。)
import time
uart= UART(2, baudrate=9600, bits=8, parity=None, rx=22,tx=23, stop=1, timeout=100)
barray = bytearray([0x00,0x03,0x00,0x02,0x00, 0x02 ,0x64 ,0x1A]) #问询帧
while True:
uart.write(barray)
time.sleep(1)
if(uart.any()):
u2by=uart.read() # 返回的是答应帧的内容
aa=u2by
G10 = int.from_bytes(aa[3:5],'big') # 十位
G1= int.from_bytes(aa[5:7],'big') # 个位
GZ=G10*10+G1
print(GZ,"LUX")
看吧毫无疑问,是好使的~
边栏推荐
- [8.1] Code Source - [The Second Largest Number Sum] [Stone Game III] [Balanced Binary Tree]
- 多列属性column元素的可见性:display、visibility、opacity、垂直对齐方式:vertical-align、z-index 越大越显示在上层
- token, jwt, oauth2, session parsing
- UI自动化测试 App的WebView页面中,当搜索栏无搜索按钮时处理方法
- DEJA_VU3D - Cesium功能集 之 057-百度地图纠偏
- 【8.3】代码源 - 【喵 ~ 喵 ~ 喵~】【树】【与】
- DEJA_VU3D - Cesium功能集 之 058-高德地图纠偏
- 狗仔队:表面编辑多视点图像处理
- DEJA_VU3D - Cesium功能集 之 059-腾讯地图纠偏
- dedecms报错The each() function is deprecated
猜你喜欢
Event parse tree Drain3 usage and explanation
Homework 8.4 Interprocess Communication Pipes and Signals
Some conventional routines of program development (1)
UE4 第一人称角色模板 添加生命值和调试伤害
[MRCTF2020]PYWebsite
[CISCN2019 South China Division]Web11
mutillidae download and installation
UI自动化测试 App的WebView页面中,当搜索栏无搜索按钮时处理方法
Visibility of multi-column attribute column elements: display, visibility, opacity, vertical alignment: vertical-align, z-index The larger it is, the more it will be displayed on the upper layer
多御安全浏览器新版下载 | 功能优秀性能出众
随机推荐
多御安全浏览器 V10.8.3.1 版正式发布,优化多项内容
How to solve complex distribution and ledger problems?
pyqt5 + socket 实现客户端A经socket服务器中转后主动向客户端B发送文件
Detailed explanation of Mysql's undo log
The solution to the failure to read channel information when dedecms generates a message in the background
Mysql的redo log详解
Qixi Festival earn badges
App rapid development and construction experience: the importance of small programs + custom plug-ins
[Geek Challenge 2019]FinalSQL
机器学习概述
Develop your own node package
What is the function of industrial-grade remote wireless transmission device?
狗仔队:表面编辑多视点图像处理
[Surveying] Quick Summary - Excerpt from Gaoshu Gang
【8.4】代码源 - 【数学】【历法】【删库】【不朴素的数列(Bonus)】
商业智能BI业务分析思维:现金流量风控分析(一)营运资金风险
[MRCTF2020] PYWebsite
The most comprehensive exam questions for software testing engineers in 2022
A 35-year-old software testing engineer with a monthly salary of less than 2W, resigns and is afraid of not finding a job, what should he do?
UE4 更改组件变量 (以修改第一人称角色模板的最大行走速度和跳跃高度为例)