Closed amgstone closed 1 year ago
Could you provide some details about your gas meter? How many pulses does the device send per m³?
https://www.samgas.com.ua/lichylnyk-gazu-membrannyy-samgaz-g25-rs2001-2 https://www.samgas.com.ua/sites/default/files/_samgaz_re_red_0_6_3_10-12-2018_14.pdf
I've trouble to translate the PDF document. Could you read the document and tell me the page which is about the low frequency pulses?
On the last reel after the comma is fixed permanent magnet for working with a low-frequency pulse generator. The design of the counting device has a plastic case in which the counting mechanism itself is assembled with the display display drums (Fig. 10):
globals:
- id: total_pulses
type: int
restore_value: true
initial_value: '7470502'
esphome:
name: gas
friendly_name: gaz
esp8266:
board: esp01_1m
restore_from_flash: true
preferences:
flash_write_interval: 10min
api:
encryption:
key: !secret api_encryption_key
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: !secret ap_wifi_ssid
password: !secret ap_wifi_password
captive_portal:
binary_sensor:
- platform: gpio
id: reed
pin:
number: GPIO2
name: "Reed contact closed"
filters:
- delayed_on: 20ms
on_press:
then:
- lambda: id(total_pulses) += 1;
- output.turn_off: led
on_release:
then:
- output.turn_on: led
sensor:
- platform: template
name: "Gas Cubic meters used"
device_class: gas
unit_of_measurement: "m³"
state_class: "total_increasing"
icon: "mdi:fire"
accuracy_decimals: 2
lambda: |-
return id(total_pulses) * 0.001;
output:
- platform: gpio
pin: GPIO0
id: 'led'
Please give it a try. If you attach a LED to your setup it will be turned on on every pulse.
I install yaml, everything is ok, but as soon as I insert the reader into the gas meter, esp becomes offline.
when the sensor is inserted into the gas meter, esp does not want to install yaml
after unplugging and turning on the power, esp starts counting from the beginning, does not remember the last value
I will have to build the setup on my own this evening to get an idea what's going on here.
globals:
- id: total_pulses
type: int
restore_value: true
initial_value: '7470502'
esphome:
name: gas
friendly_name: gaz
esp8266:
board: d1_mini
restore_from_flash: true
preferences:
flash_write_interval: 10min
api:
encryption:
key: !secret api_encryption_key
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: !secret ap_wifi_ssid
password: !secret ap_wifi_password
captive_portal:
binary_sensor:
- platform: gpio
id: reed
pin:
number: GPIO5
name: "Reed contact closed"
filters:
- delayed_on: 20ms
on_press:
then:
- lambda: id(total_pulses) += 1;
- output.turn_off: led
on_release:
then:
- output.turn_on: led
sensor:
- platform: template
name: "Gas Cubic meters used"
device_class: gas
unit_of_measurement: "m³"
state_class: "total_increasing"
icon: "mdi:fire"
accuracy_decimals: 2
lambda: |-
return id(total_pulses) * 0.001;
output:
- platform: gpio
pin: GPIO2
id: 'led'
Please attach the red wire to GPIO5 / D1
and try again. :-)
I've tested the setup. It's working and the total pulses are stored every 10 minutes to the flash/rtc:
preferences:
flash_write_interval: 10min
Does the LED of the wemos blink once on every round of the gas meter?
with d1 does not respond
Could you try to describe the issue in detail? You could write the summary in your mother language if you like.
when it was connected to d4, everything worked, but when I connected the sensor to the esp meter, it did not start. When I connected it to d1, the sensor did not work, did not react to the magnet.
You have to use a pull-up (a resistor between D1 and 3.3V).
and how should it be connected according to the scheme? I have resistors.
I will paint the schematics later the day!
I've enabled the internet pull-up of the ESP. Please try this updated YAML:
globals:
- id: total_pulses
type: int
restore_value: true
initial_value: '7470502'
esphome:
name: gas
friendly_name: gaz
esp8266:
board: d1_mini
restore_from_flash: true
preferences:
flash_write_interval: 10min
api:
encryption:
key: !secret api_encryption_key
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: !secret ap_wifi_ssid
password: !secret ap_wifi_password
captive_portal:
binary_sensor:
- platform: gpio
id: reed
pin:
number: GPIO5
mode: INPUT_PULLUP
name: "Reed contact closed"
filters:
- delayed_on: 20ms
on_press:
then:
- lambda: id(total_pulses) += 1;
- output.turn_off: led
on_release:
then:
- output.turn_on: led
sensor:
- platform: template
name: "Gas Cubic meters used"
device_class: gas
unit_of_measurement: "m³"
state_class: "total_increasing"
icon: "mdi:fire"
accuracy_decimals: 2
lambda: |-
return id(total_pulses) * 0.001;
output:
- platform: gpio
pin: GPIO2
id: 'led'
work perfectly
http://joxi.ru/gmvVao0sqYL5bm when I change the value to the current one and flash esp, nothing changes in HA, in the sensor: sensor.gas_gas_cubic_meters_used and add utility meter to yaml
I assume this multiplicator is wrong:
lambda: |-
return id(total_pulses) * 0.001;
Could you check how many times the reed contact is closed while the last digit of the gas meter is spinning? I assume it's closed once per round. So the multiplicator should be:
lambda: |-
return id(total_pulses) * 0.01;
The initial_value
is written once to the RTC/ESP. I don't know how to override this initial value without changing the name of the variable.
http://joxi.ru/Q2KqbERuLD4NKr then when i changed the value to 0.01
You could add a button
entity to the YAML to initialize the total_pulses
varable with a new value (0
) on button press:
button:
- platform: template
name: "Set value"
on_press:
- lambda: id(total_pulses) = 0;
The new value is written to the flash/RTC after 10 minutes:
preferences:
flash_write_interval: 10min
initial values can be changed in HA utility meter. But you need to add it to yaml.
Did you see the YAML above how to set the initial value of total_pulses
using a temporary added button
entity?
http://joxi.ru/82Q4bdkuwejP0m work))))
Cool! Please compare the value of the gas meter with the value of the ESPHome node in a few days to verify the multiplication is correct and the ESPHome increments the counter just as fast as the gas meter.
and the utility meter does not need to be added for statistics?
No. It's useless in my opinion and shouldn't be added to the YAML.
The Gas Cubic meters used
sensor should be sufficient.
for some reason, some impulses are present when there is no gas consumption
How long is the cable between the ESP and the reed contact?
2 meters, original length
The enabled internal resistor isn't probably enough and you could increase the debounce time.
Please try 150ms. If you miss pulses decrease the value step by step.
I'm sorry that this is off topic, I'm trying to configure the gas meter, can you tell me if I configured the utility meter correctly?