当前位置:网站首页>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")
看吧毫无疑问,是好使的~
边栏推荐
- DEJA_VU3D - Cesium功能集 之 056-智图Arcgis地图纠偏
- Feature preprocessing
- DNS被劫持如何处理?
- Mysql's redo log detailed explanation
- 【8.4】代码源 - 【数学】【历法】【删库】【不朴素的数列(Bonus)】
- 七夕节赚徽章拉
- Day019 方法重写与相关类的介绍
- What is the function of industrial-grade remote wireless transmission device?
- 关于sklearn库的安装
- dedecms error The each() function is deprecated
猜你喜欢
随机推荐
[SWPU2019]Web1
七夕节赚徽章拉
In the hot summer, teach you to use Xiaomi smart home accessories + Raspberry Pi 4 to connect to Apple HomeKit
[SWPU2019]Web1
The log causes these pits in the thread block, you have to guard against
There are a lot of 4T hard drives remaining, prompting "No space left on device" insufficient disk space
Four-digit display header design
Detailed explanation of Mysql's undo log
upload upload pictures to Tencent cloud, how to upload pictures
dedecms error The each() function is deprecated
开发属于自己的node包
Cron(Crontab)--使用/教程/实例
软件管理rpm
日志导致线程Block的这些坑,你不得不防
How do newcomers get started and learn software testing?
[BJDCTF2020]EasySearch
mysql数据库表什么字段类型的存储长度最大?
How to solve the three major problems of bank data collection, data supplementary recording and index management?
In the WebView page of the UI automation test App, the processing method when the search bar has no search button
Bosses, I noticed that a mysql CDC connector parameters scan. The incremental. Sna



![[MRCTF2020] PYWebsite](/img/d4/57e8e5ee45b742894679f3f5671516.png)





