Gas meter with Hall Sensor, counting via ADC (A0)
Moderators: grovkillen, Stuntteam, TD-er
Gas meter with Hall Sensor, counting via ADC (A0)
Hello,
after experimenting with reed contacts, I found out, that I get a far more reliable measurement from a hall sensor (Type 49E) for the rotating magnet of some gas meters.
With reed contacts, I always got some bouncing, and other effects.
I now get a nice kind of sine wave, only the negative part of it. I want to count the number of negative waves, triggering for instance a pulse counter, but preferably over A0 input, with a software defined threshold.
I want to be adjustable about the values for the triggers, as I want to be able to cover tolerances between different gas meters. I.e. I don't want a hardware solution with resistors triggering a digital GPIO.
So. please, can I use the ADC/A0 input and maybe a rule, to realise something like:
"if you get lower then -0,51 and then higher than -0,49 then trigger pulse counter"?
Some ideas/hints would be very nice.
Kind Regards, Metatron
after experimenting with reed contacts, I found out, that I get a far more reliable measurement from a hall sensor (Type 49E) for the rotating magnet of some gas meters.
With reed contacts, I always got some bouncing, and other effects.
I now get a nice kind of sine wave, only the negative part of it. I want to count the number of negative waves, triggering for instance a pulse counter, but preferably over A0 input, with a software defined threshold.
I want to be adjustable about the values for the triggers, as I want to be able to cover tolerances between different gas meters. I.e. I don't want a hardware solution with resistors triggering a digital GPIO.
So. please, can I use the ADC/A0 input and maybe a rule, to realise something like:
"if you get lower then -0,51 and then higher than -0,49 then trigger pulse counter"?
Some ideas/hints would be very nice.
Kind Regards, Metatron
Re: Gas meter with Hall Sensor, counting via ADC (A0)
How many pulses per second do you expect?
Re: Gas meter with Hall Sensor, counting via ADC (A0)
One pulse is one liter of gas.
This is the signal: Sampling 1s to HA with esphome.
However, I want to prevent the traffic and solve it on esp side. I have some experience with espeasy.
I won't get much faster, but slower down to standstill at any position - if no gas is used.
This is the signal: Sampling 1s to HA with esphome.
However, I want to prevent the traffic and solve it on esp side. I have some experience with espeasy.
I won't get much faster, but slower down to standstill at any position - if no gas is used.
Re: Gas meter with Hall Sensor, counting via ADC (A0)
Given it is more than a second between pulses, you could try what was discussed here: viewtopic.php?p=60251#p60251
It is a very similar question to what you're trying to do.
It is a very similar question to what you're trying to do.
Re: Gas meter with Hall Sensor, counting via ADC (A0)
Thank you!
That looks promising, I will read it through!
Regards, Metatron
That looks promising, I will read it through!
Regards, Metatron
Re: Gas meter with Hall Sensor, counting via ADC (A0)
I would like to use the pulse counter.
Count I trigger the pulse counter by a rule command without hardware?
Or do I need to trigger it with a gpio connected to another one?
I don't like the idea to send the pulses directly to my smart home software. If this is unavailable, e.g. for maintenance, I loose pulses.
Count I trigger the pulse counter by a rule command without hardware?
Or do I need to trigger it with a gpio connected to another one?
I don't like the idea to send the pulses directly to my smart home software. If this is unavailable, e.g. for maintenance, I loose pulses.
Re: Gas meter with Hall Sensor, counting via ADC (A0)
you could use an unused gpio for the pulse counter and pulse this gpio with a rule.
something like:
Edit:
You don’t necessarily need the pulse counter. you could also store the value in an dummy-device:
something like:
Code: Select all
On analog#value Do
If %eventvalue% > something and [var#1] = 1
LongPulse_mS,14,1,100
Let,1,0
Else
Let,1,1
Endif
Endon
You don’t necessarily need the pulse counter. you could also store the value in an dummy-device:
Code: Select all
On analog#value Do
If %eventvalue% > something and [var#1] = 1
TaskValueSet,Dummy,Value,[Dummy#Value]+1
Let,1,0
Else
Let,1,1
Endif
Endon
Re: Gas meter with Hall Sensor, counting via ADC (A0)
Yep generating a pulse, only to count it on the same device is wasting resources and very prone to error as everything done on the ESP8266 is done in software.
Better store it in a variable, or if you need to keep it after a reboot (without power loss) you can use a dummy task and use taskValueSet to store it in the dummy.
Better store it in a variable, or if you need to keep it after a reboot (without power loss) you can use a dummy task and use taskValueSet to store it in the dummy.
Re: Gas meter with Hall Sensor, counting via ADC (A0)
Thank you all for the valuable input. I will see, how I can use this.
Please don't forget, the pulse counter produces not only the sum, but 3 values.
And furthermore, there are codes and automations for all kind of smart home software systems, do deal with the output of the espeasy pulse counter.
So if I plan to build some of these readers, everyone can easily implement it in his/hers system.
Please don't forget, the pulse counter produces not only the sum, but 3 values.
And furthermore, there are codes and automations for all kind of smart home software systems, do deal with the output of the espeasy pulse counter.
So if I plan to build some of these readers, everyone can easily implement it in his/hers system.
Re: Gas meter with Hall Sensor, counting via ADC (A0)
PS: Everyone using the standard reed solution could also easily switch to the hall version, as it produces the same output, just better without bouncing.
Re: Gas meter with Hall Sensor, counting via ADC (A0)
What other values do you need?
If it is about the duration between pulses, this can also be done in rules.
Simply count the nr. of pulses and have a loop timer set to every minute (or whatever interval you need) and calculate the power usage based on the nr of counts. (make sure not to divide by zero )
Anyway, I get it that you may want to have an analog version of the pulse counter plugin
If it is about the duration between pulses, this can also be done in rules.
Simply count the nr. of pulses and have a loop timer set to every minute (or whatever interval you need) and calculate the power usage based on the nr of counts. (make sure not to divide by zero )
Anyway, I get it that you may want to have an analog version of the pulse counter plugin
Re: Gas meter with Hall Sensor, counting via ADC (A0)
Hello,
yes, in theory, this would be the most comfortable solution to transfer any cyclic analog signal to cylce counts.
However, with the suggestions here, I believe I can make it work with rules!
Thank you!
yes, in theory, this would be the most comfortable solution to transfer any cyclic analog signal to cylce counts.
However, with the suggestions here, I believe I can make it work with rules!
Thank you!
Re: Gas meter with Hall Sensor, counting via ADC (A0)
Hey Metatron! Dit you get it working in the end? I'm trying the same thing with a hall effects sensor. Could you maybe share your code? I'm not that great with it and it would help immensely.
Re: Gas meter with Hall Sensor, counting via ADC (A0)
You have to connect the output of the hall sensor to the ADC/A0 input on your microcontroller. You may need to add some additional circuitry, such as a voltage divider, to ensure that the input voltage stays within the range of the ADC.
Write a function to read the ADC value and convert it to a voltage. The voltage will vary with the position of the rotating magnet and will generate a sine wave. The negative peaks of the wave will correspond to the point where the magnet is closest to the sensor.
Set a threshold voltage that will trigger the pulse counter. This threshold voltage should be set to a value that is slightly below the negative peak of the sine wave. You can make this threshold voltage adjustable by adding a potentiometer or some other variable resistor to your circuit.
Write a function to read the ADC value and convert it to a voltage. The voltage will vary with the position of the rotating magnet and will generate a sine wave. The negative peaks of the wave will correspond to the point where the magnet is closest to the sensor.
Set a threshold voltage that will trigger the pulse counter. This threshold voltage should be set to a value that is slightly below the negative peak of the sine wave. You can make this threshold voltage adjustable by adding a potentiometer or some other variable resistor to your circuit.
Re: Gas meter with Hall Sensor, counting via ADC (A0)
This is a really strange answerbidrohini wrote: ↑16 Feb 2023, 15:26 You have to connect the output of the hall sensor to the ADC/A0 input on your microcontroller. You may need to add some additional circuitry, such as a voltage divider, to ensure that the input voltage stays within the range of the ADC.
Write a function to read the ADC value and convert it to a voltage. The voltage will vary with the position of the rotating magnet and will generate a sine wave. The negative peaks of the wave will correspond to the point where the magnet is closest to the sensor.
Set a threshold voltage that will trigger the pulse counter. This threshold voltage should be set to a value that is slightly below the negative peak of the sine wave. You can make this threshold voltage adjustable by adding a potentiometer or some other variable resistor to your circuit.
/Ton (PayPal.me)
Re: Gas meter with Hall Sensor, counting via ADC (A0)
I think the answer sketches the idea, it is ok.
I have not had the time, yet, to implement it.
As soon as I have, I will post the result.
I have not had the time, yet, to implement it.
As soon as I have, I will post the result.
Re: Gas meter with Hall Sensor, counting via ADC (A0)
Well, it is indeed a rather strange answer, as we have the ADC plugin in ESPEasy since the very beginning...
The ADC plugin even has plugin ID nr 2, just indicating how early in the project it was added.
So I really wonder what @bidrohini means to suggest here as this is a forum for the ESPEasy project and thus writing code for it is absolutely not needed.
The ADC plugin even has plugin ID nr 2, just indicating how early in the project it was added.
So I really wonder what @bidrohini means to suggest here as this is a forum for the ESPEasy project and thus writing code for it is absolutely not needed.
-
- New user
- Posts: 1
- Joined: 26 Sep 2024, 06:17
Re: Gas meter with Hall Sensor, counting via ADC (A0)
Here is the answer if you like to use mqtt
https://github.com/CraigHoffmann/water-meter-reader
https://github.com/CraigHoffmann/water-meter-reader
Re: Gas meter with Hall Sensor, counting via ADC (A0)
Why suggest an entirely different project with only 1 purpose on a forum about ESPEasy which can do the same and more?dp1971@gmail.com wrote: ↑26 Sep 2024, 06:18 Here is the answer if you like to use mqtt
https://github.com/CraigHoffmann/water-meter-reader
Who is online
Users browsing this forum: No registered users and 1 guest