mirror of
https://github.com/esphome/esphome.git
synced 2025-03-15 15:18:16 +00:00
ppd42x PIN added
This commit is contained in:
parent
3a313c5b84
commit
3769567ebf
@ -4,7 +4,7 @@ from esphome import pins
|
|||||||
from esphome.components import sensor
|
from esphome.components import sensor
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import CONF_ID, CONF_PM_10_0, CONF_PM_2_5, CONF_NAME, \
|
from esphome.const import CONF_ID, CONF_PM_10_0, CONF_PM_2_5, CONF_NAME, \
|
||||||
CONF_UPDATE_INTERVAL, CONF_TIMEOUT
|
CONF_UPDATE_INTERVAL, CONF_TIMEOUT, CONF_PIN
|
||||||
from esphome.cpp_generator import Pvariable, add
|
from esphome.cpp_generator import Pvariable, add
|
||||||
from esphome.cpp_helpers import gpio_input_pin_expression, \
|
from esphome.cpp_helpers import gpio_input_pin_expression, \
|
||||||
setup_component
|
setup_component
|
||||||
@ -25,24 +25,23 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
|||||||
|
|
||||||
|
|
||||||
def to_code(config):
|
def to_code(config):
|
||||||
for pm_10_0 in gpio_input_pin_expression(config[CONF_PM_10_0]):
|
|
||||||
yield
|
|
||||||
for pm_02_5 in gpio_input_pin_expression(config[CONF_PM_2_5]):
|
|
||||||
yield
|
|
||||||
rhs = App.make_ppd42x_sensor(config[CONF_NAME], pm_10_0, pm_02_5,
|
|
||||||
config.get(CONF_UPDATE_INTERVAL))
|
|
||||||
ppd42x = Pvariable(config[CONF_ID], rhs)
|
|
||||||
|
|
||||||
if CONF_TIMEOUT in config:
|
if CONF_TIMEOUT in config:
|
||||||
add(ppd42x.set_timeout_us(config[CONF_TIMEOUT]))
|
add(ppd42x.set_timeout_us(config[CONF_TIMEOUT]))
|
||||||
|
|
||||||
if CONF_PM_2_5 in config:
|
if CONF_PM_2_5 in config:
|
||||||
conf = config[CONF_PM_2_5]
|
conf_02_5 = config[CONF_PM_2_5]
|
||||||
sensor.register_sensor(ppd42x.make_pm_02_5_sensor(conf[CONF_NAME]), conf)
|
for auto pm_02_5 in gpio_input_pin_expression(conf_02_5[CONF_PIN]):
|
||||||
|
yield
|
||||||
|
sensor.register_sensor(ppd42x.make_pm_02_5_sensor(conf_02_5[CONF_NAME]), conf_02_5)
|
||||||
if CONF_PM_10_0 in config:
|
if CONF_PM_10_0 in config:
|
||||||
conf = config[CONF_PM_10_0]
|
conf_10_0 = config[CONF_PM_10_0]
|
||||||
sensor.register_sensor(ppd42x.make_pm_10_0_sensor(conf[CONF_NAME]), conf)
|
for auto pm_10_0 in gpio_input_pin_expression(conf_10_0[CONF_PIN]):
|
||||||
|
yield
|
||||||
|
sensor.register_sensor(ppd42x.make_pm_10_0_sensor(conf_10_0[CONF_NAME]), conf_10_0)
|
||||||
|
|
||||||
|
rhs = App.make_ppd42x_sensor(config[CONF_NAME], pm_10_0, pm_02_5,
|
||||||
|
config.get(CONF_UPDATE_INTERVAL))
|
||||||
|
ppd42x = Pvariable(config[CONF_ID], rhs)
|
||||||
sensor.setup_sensor(ppd42x, config)
|
sensor.setup_sensor(ppd42x, config)
|
||||||
setup_component(ppd42x, config)
|
setup_component(ppd42x, config)
|
||||||
|
|
||||||
|
@ -503,12 +503,14 @@ sensor:
|
|||||||
rx_only: false
|
rx_only: false
|
||||||
|
|
||||||
- platform: ppd42x
|
- platform: ppd42x
|
||||||
timeout: 30000 # mandatory
|
|
||||||
pm_2_5:
|
pm_2_5:
|
||||||
name: "SDS011 PM2.5"
|
pin: GPIO32
|
||||||
|
name: "ppd42 PM2.5"
|
||||||
pm_10_0:
|
pm_10_0:
|
||||||
name: "SDS011 PM10.0"
|
pin: GPIO35
|
||||||
|
name: "ppd42 PM10.0"
|
||||||
update_interval: 5min
|
update_interval: 5min
|
||||||
|
timeout: 30000us # default value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user