当前位置:网站首页>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,是好使的~
边栏推荐
猜你喜欢
随机推荐
App快速开发建设心得:小程序+自定义插件的重要性
一篇博客通关Redis技术栈
In the hot summer, teach you to use Xiaomi smart home accessories + Raspberry Pi 4 to connect to Apple HomeKit
Dephi reverse tool Dede exports function name MAP and imports it into IDA
dedecms报错The each() function is deprecated
Flutter TapGestureRecognizer 如何工作
【cesium】加载并定位 3D Tileset
Analyses the mainstream across technology solutions
number_gets the specified number of decimals
使用二维码解决固定资产管理的难题
About the installation of sklearn library
Flutter学习4-基本UI组件
Application status of digital twin technology in power system
二叉树基本性质+oj题解析
Shell(4)条件控制语句
u-boot in u-boot, dm-pre-reloc
upload upload pictures to Tencent cloud, how to upload pictures
dedecms dream weaving tag tag does not support capital letters fix
【解码工具】Bitcoin的一些在线工具
【cesium】Load and locate 3D Tileset