当前位置:网站首页>ESP32 485 Illuminance
ESP32 485 Illuminance
2022-08-05 05:11:00 【Salted fish basket】
ESP32 485光照度
气象站基础呀
RS-485仅是一个电气标准,描述了接口的物理层,像协议、时序、串行或并行数据以及链路全部由设计者或更高层协议定义.
RS-485定义的是使用平衡(也称作差分)多点传输线的驱动器(driver)和接收器(receiver)的电气特性.
材料及接线
ESP32
单片机TTL转RS485模块
接线说明
| 开发板 | TTL转RS485模块 |
|---|---|
| 22 | TXD |
| 23 | RXD |
| 5v | VCC |
| GND | GND |
485光照度
采用工业级芯片,High-precision imported light sensor.采用RS485硬件接口,协议层兼容标准的工业Modbus-Rtu协议.


接线说明
| TTL转RS485模块 | 485温湿度传感器 | 开发板 |
|---|---|---|
| A+ | TXD_A 黑线 | |
| B- | RXD_B 黄线 | |
| 5v | 5V 红线 | |
| GND | GND 绿线 |
PS:基本485的接线都一样了
示例程序
Get illuminance
此485传感器范围0~200000Lux
勒克斯(lux,Statutory symbolslx)照度单位,1 Lux equals 1流(lumen,lm)The luminous flux is evenly distributed in 1㎡ Illuminance over the area.
1 lx大约等于1candlelight in1Illuminance at a distance of meters,The lowest illuminance we commonly see in camera parameter specifications(MINIMUM.ILLUMINATION),Indicates that the camera only needs to be on the markedLUX数值下,That is, a clear image can be obtained,此数值越小越好,说明CCDhigher sensitivity.同样条件下,Black and white cameras require far less illuminance than color cameras that still have to deal with color intensity10倍.
一般情况:Under the summer sun100,000 lx;Cloudy outside for10000 lx;Indoor fluorescent lamps are100 lx;距60W台灯60CM桌面为300lx;TV studio for1000 lx;Indoors at dusk10 lx;Street lights at night0.1 lx;烛光(20CM远处)10~15 lx.
PS:我买的485The light can be measured outside the range after all20Wlx And the summer sun is there10Wlx.So if the test is outdoor,When buying, ask about the size. Indoor is0~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")
Serial output light value,I tested it indoors
修改地址
In addition, we can also configure the address.
The following addresses are configured successfully,My current sensor address is00
>>> 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'
We can test it
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")
Look no doubt,是好使的~
边栏推荐
猜你喜欢
![[Surveying] Quick Summary - Excerpt from Gaoshu Gang](/img/35/e5c5349b8d4ccf9203c432a9aaee7b.png)
[Surveying] Quick Summary - Excerpt from Gaoshu Gang

【cesium】3D Tileset 模型加载并与模型树关联

一篇博客通关Redis技术栈

Develop a highly fault-tolerant distributed system

大学物理---质点运动学

About the installation of sklearn library

mutillidae download and installation

LeetCode:1403. 非递增顺序的最小子序列【贪心】

The production method of the powered small sailboat is simple, the production method of the electric small sailboat

University Physics---Particle Kinematics
随机推荐
Day019 Method overriding and introduction of related classes
Detailed explanation of Mysql's undo log
Homework 8.4 Interprocess Communication Pipes and Signals
Redis - 13. Development Specifications
mysql数据库表什么字段类型的存储长度最大?
[Nine Lectures on Backpacks - 01 Backpack Problems]
8.04 Day35-----MVC三层架构
RL强化学习总结(一)
dedecms后台生成提示读取频道信息失败的解决方法
mutillidae download and installation
Requests库部署与常用函数讲解
Excel画图
How to identify false evidence and evidence?
In the hot summer, teach you to use Xiaomi smart home accessories + Raspberry Pi 4 to connect to Apple HomeKit
Is the NPDP certificate high in gold content?Compared to PMP?
Flutter learning - the beginning
【学生毕业设计】基于web学生信息管理系统网站的设计与实现(13个页面)
JeeSite New Report
【cesium】加载并定位 3D Tileset
类的底层机制