找回密码
 立即注册

微信扫码登录

搜索
查看: 69|回复: 1

[硬件DIY] 【学习-记录-分享】燃气DIY篇

[复制链接]

2

主题

17

回帖

223

积分

中级会员

积分
223
金钱
204
HASS币
0
发表于 2 小时前 | 显示全部楼层 |阅读模式
本帖最后由 fk0074 于 2026-1-21 10:00 编辑

燃气DIY-巧读天然气表
引用大佬的教程及评论区各位大佬的代码,【学习-记录-分享】燃气DIY篇2-巧读天然气表(https://bbs.hassbian.com/thread-16773-1-2.html)。
简介
家里开暖气,想记录不同温度设置下对用能的影响,新奥燃气的统计结果有滞后,学习了大佬的帖子后手动制作,还增加了433发射模块以及温湿度传感器模块,后续还可以拓展更多模块。
目的
利用计量码盘最后一位数字“0”的的小镜面反射部,使用光电采样计量,集成到HA中记录并统计用气量。
准备
在巨人的肩膀上,操作难度就小很多,为了打印外壳,购入了3D打印机,自制配件,通过esp8266模块直接接入。有个注意事项,TCRT5000有个检测距离,1mm-8mm,上面的可调电阻是调整检测距离的,因此在设计3d打印模型的时候,一定要提前预留好距离,免得过近了无法监测。
硬件
esp8266,TCRT5000循迹模块x1,DHT22温湿度模块x1,H34L低电压无线发射模块x1等。
还需要3D打印制作esp8266模块盒,具体见图。

esphome:
  name: laundry
  friendly_name: '燃气'

esp8266:
  board: nodemcuv2


# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: ""

ota:
- platform: esphome
  password: ""

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: ""
    password: ""

captive_portal:
   
remote_transmitter:
  pin: D1
  # RF uses a 100% carrier signal
  carrier_duty_percent: 100%


switch:
  - platform: template
    name: Up
    turn_on_action:
      - remote_transmitter.transmit_rc_switch_raw:
          code: '0111110110100111101010000000000000010001'   # 0x4F 8C10 0611
          protocol:
            pulse_length: 350
            sync: [14, 4]
            zero: [1, 2]
            one: [2, 1]
          repeat:
            times: 5
            wait_time: 7500us

  - platform: template
    name: down
    turn_on_action:
      - remote_transmitter.transmit_rc_switch_raw:
          code: '0111110110100111101010000000000000110011'   # 0x4F 8C10 0611
          protocol:
            pulse_length: 350
            sync: [14, 4]
            zero: [1, 2]
            one: [2, 1]
          repeat:
            times: 5
            wait_time: 7500us
  
  
  - platform: template
    name: stop
    turn_on_action:
      - remote_transmitter.transmit_rc_switch_raw:
          code: '0111110110100111101010000000000001010101'   # 0x4F 8C10 0611
          protocol:
            pulse_length: 350
            sync: [14, 4]
            zero: [1, 2]
            one: [2, 1]
          repeat:
            times: 5
            wait_time: 7500us

  - platform: template
    name: light
    turn_on_action:
      - remote_transmitter.transmit_rc_switch_raw:
          code: '0111110110100111101010000000000000001111'   # 0x4F 8C10 0611
          protocol:
            pulse_length: 350
            sync: [14, 4]
            zero: [1, 2]
            one: [2, 1]
          repeat:
            times: 5
            wait_time: 7500us

  - platform: template
    name: power
    turn_on_action:
      - remote_transmitter.transmit_rc_switch_raw:
          code: '011111011010011110101000000000001110000'   # 0x4F 8C10 0611
          protocol:
            pulse_length: 350
            sync: [14, 4]
            zero: [1, 2]
            one: [2, 1]
          repeat:
            times: 5
            wait_time: 7500us

# binary_sensor:
#   - platform: gpio
#     name: "gas_count"
#     pin:
#       number: GPIO4
#       inverted: true
#       mode:
#         input: true
#         pullup: true

time:
  - platform: sntp
    id: sntp_time
    timezone: Asia/Shanghai
    # on_time:
    #   - cron: '* 10 2 * * *'  #每天2点10分重启
    #     then:
    #       - switch.toggle: ranqi_esp8266_restart
globals:
   - id: counter_int
     type: float
     restore_value: yes
     initial_value: '0'

binary_sensor:
  - platform: gpio
    pin:
      number: D3
      mode: INPUT_PULLUP
      inverted: True
    name: gas_counter_key_point
    id: gas_counter_key_point
    icon: mdi:gas-burner
    on_release:
      then:
        - lambda: |-
            id(counter_int) += 0.01;
            id(gas_meter).publish_state(id(counter_int));
sensor:  
  - platform: template
    name: "gas_meter"
    id: gas_meter
    lambda: !lambda |-
        return id(counter_int);
    unit_of_measurement: 'm³'
    state_class: 'total_increasing'
    accuracy_decimals: 2
    device_class: 'gas'
    update_interval: 60s  
  - platform: dht
    pin: D2
    temperature:
      name: "outdoor Temperature"
    humidity:
      name: "outdoor Humidity"
    update_interval: 60s
# switch:
#   - platform: restart  #用于重启NodeMCU
#     name: "ranqi_esp8266_restart"
#     id: ranqi_esp8266_restart

9924bf058044a17f86caa616866c3f47.jpg
Snipaste_2026-01-21_09-49-02.png

评分

参与人数 2金钱 +26 收起 理由
shay + 10 无私奉献
hhh. + 16 论坛有你更精彩!

查看全部评分

回复

使用道具 举报

23

主题

722

回帖

3244

积分

论坛元老

积分
3244
金钱
2499
HASS币
0
发表于 半小时前 | 显示全部楼层
有个大佬用纽扣电池的方案,,,你这个方案还是220V供电过来接的电源吧?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )

GMT+8, 2026-1-21 12:00 , Processed in 0.364138 second(s), 7 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表