Я пытаюсь прочитать данные датчика из «Modbus SHT20 Sensor XY-MD02», используя библиотеку «minimalmodbus», но не могу получить показания. Буду признателен, если поможете мне, где я делаю не так. Прошу прощения, если этот вопрос покажется глупым, поскольку это мой первый опыт связи по RS485.
Схема подключения
https://docs.google.com/document/d/1P_T ... 1PTz5cvIc/ edit?usp=sharing
[Модули и Датчики]
Преобразователь RS485 в TTL - https://silicontechnolabs.in/products/r ... -converter
Преобразователь температуры и влажности Датчик Modbus SHT20 XY-MD02 - https://roboticsdna.in/product/temperat ... gn={campai gn}&adgroup={adgroup}&keyword=&matchtype=&gad_source=1&gclid=Cj0KCQiAvbm7BhC5ARISAFjwNHtxYcYTCSiO4Y6TK0oxffiWH1NYwVIijQOv5MmM6OdBevpQqZE3KG4aAu0PEALw_wcB
и
Raspberry pi 5 — ОС Dibian
My Config.txt
# For more options and information see
# http://rptl.io/configtxt
# Some settings may impact device functionality. See link above for details
# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=off
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
# Additional overlays and parameters are documented
# /boot/firmware/overlays/README
# Automatically load overlays for detected cameras
camera_auto_detect=1
# Automatically load overlays for detected DSI displays
display_auto_detect=1
# Automatically load initramfs files, if found
auto_initramfs=1
# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2
# Don't have the firmware create an initial video= setting in cmdline.txt.
# Use the kernel's default instead.
disable_fw_kms_setup=1
# Run in 64-bit mode
arm_64bit=1
# Disable compensation for displays with overscan
disable_overscan=1
# Run as fast as firmware / board allows
arm_boost=1
[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1
[cm5]
dtoverlay=dwc2,dr_mode=host
[all]
dtparam=uart0=on
enable_uart=1
dtoverlay=i2c-rtc,ds3231
dtparam=rtc=off
#dtoverlay=pi3-miniuart-bt
Мой код –
import minimalmodbus
import serial
import time
instrument = minimalmodbus.Instrument('/dev/ttyAMA0', 1)
instrument.serial.baudrate = 9600
instrument.serial.timeout = 2
def read_temperature_humidity():
try:
temperature = instrument.read_register(0x0001, 2)
humidity = instrument.read_register(0x0002, 2)
temperature = temperature / 10.0
humidity = humidity / 10.0
print(f"Temperature: {temperature} °C")
print(f"Humidity: {humidity} %")
except minimalmodbus.NoResponseError:
print("No response from the sensor. Check connections and settings.")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
while True:
read_temperature_humidity()
time.sleep(2)
Вывод-
pi@raspberrypi:~ $ sudo python3 sensor.py
No response from the sensor. Check connections and settings.
No response from the sensor. Check connections and settings.
Подробнее здесь: https://stackoverflow.com/questions/793 ... ta-using-m
Raspberry Pi 5 с датчиком SHT20 (XY MD02) Проблемы и проблемы при чтении данных с использованием Minimalmodbus ⇐ Python
Программы на Python
1735299284
Anonymous
Я пытаюсь прочитать данные датчика из «Modbus SHT20 Sensor XY-MD02», используя библиотеку «minimalmodbus», но не могу получить показания. Буду признателен, если поможете мне, где я делаю не так. Прошу прощения, если этот вопрос покажется глупым, поскольку это мой первый опыт связи по RS485.
Схема подключения
https://docs.google.com/document/d/1P_Ts34HH1cGGb3XseNed1IJn0kJBaPhUwH1PTz5cvIc/ edit?usp=sharing
[Модули и Датчики]
Преобразователь RS485 в TTL - https://silicontechnolabs.in/products/rs485-to-ttl-converter
Преобразователь температуры и влажности Датчик Modbus SHT20 XY-MD02 - https://roboticsdna.in/product/temperature-and-humidity-transmitter-modbus-sht20-sensor-xy-md02/?src=google&kwd=&adgroup={adgroup}&device=c&campaign={campai gn}&adgroup={adgroup}&keyword=&matchtype=&gad_source=1&gclid=Cj0KCQiAvbm7BhC5ARISAFjwNHtxYcYTCSiO4Y6TK0oxffiWH1NYwVIijQOv5MmM6OdBevpQqZE3KG4aAu0PEALw_wcB
и
Raspberry pi 5 — ОС Dibian
My Config.txt
# For more options and information see
# http://rptl.io/configtxt
# Some settings may impact device functionality. See link above for details
# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=off
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
# Additional overlays and parameters are documented
# /boot/firmware/overlays/README
# Automatically load overlays for detected cameras
camera_auto_detect=1
# Automatically load overlays for detected DSI displays
display_auto_detect=1
# Automatically load initramfs files, if found
auto_initramfs=1
# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2
# Don't have the firmware create an initial video= setting in cmdline.txt.
# Use the kernel's default instead.
disable_fw_kms_setup=1
# Run in 64-bit mode
arm_64bit=1
# Disable compensation for displays with overscan
disable_overscan=1
# Run as fast as firmware / board allows
arm_boost=1
[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1
[cm5]
dtoverlay=dwc2,dr_mode=host
[all]
dtparam=uart0=on
enable_uart=1
dtoverlay=i2c-rtc,ds3231
dtparam=rtc=off
#dtoverlay=pi3-miniuart-bt
Мой код –
import minimalmodbus
import serial
import time
instrument = minimalmodbus.Instrument('/dev/ttyAMA0', 1)
instrument.serial.baudrate = 9600
instrument.serial.timeout = 2
def read_temperature_humidity():
try:
temperature = instrument.read_register(0x0001, 2)
humidity = instrument.read_register(0x0002, 2)
temperature = temperature / 10.0
humidity = humidity / 10.0
print(f"Temperature: {temperature} °C")
print(f"Humidity: {humidity} %")
except minimalmodbus.NoResponseError:
print("No response from the sensor. Check connections and settings.")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
while True:
read_temperature_humidity()
time.sleep(2)
Вывод-
pi@raspberrypi:~ $ sudo python3 sensor.py
No response from the sensor. Check connections and settings.
No response from the sensor. Check connections and settings.
Подробнее здесь: [url]https://stackoverflow.com/questions/79311665/raspberry-pi-5-with-sht20-sensorxy-md02-wring-issues-in-reading-data-using-m[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия