Gas meter - Receive magnetic pulses with an ESP8266

preview_player
Показать описание
Buy me a coffee:

Unfortunately, an error has slipped into the calculation of the binary numbers. Correctly the right side of the decimal point should look like this:
1/2^2 + 1/2^3 + 1/2^6 = 0.25 + 0.125 + 0.015625 = 0.390625
For the small numbers I noted above the binary digits, I should not have started with 0, 1, 2, 3... but with 1, 2, 3, 4...

Links:

Code, KiCAD-Files:

3D-Model of the Case on Thingiverse:

Songs:
"8-bit-Laserstrahl" by betatronik (CC BY-NC-SA)
"Auf Dem Wind (calm)" by betatronik (CC BY-NC-SA)
"Make-New" by Ketsa (CC BY-NC-ND)
"Towel Defence Ending" by sawsquarenoise (CC-BY)
"Hachimantai Snow" by Maarten Schellekens (CC BY-NC)
"Poor Boy" by Pedro Santiago (CC BY-NC-SA)
"D2" by Maarten Schellekens (CC BY-NC)
"Long Story" by Sergey Cheremisinov (CC BY-NC)
"Salt Lake Swerve - Chillout Remix" by Maarten Schellekens (CC BY-NC)
"Mallet Play" - Maarten Schellekens (CC BY-NC)
"Tuesday Night - Radio Edit" by Maarten Schellekens (CC BY-NC)
"Salt Lake Swerve - Chillout Remix" by Maarten Schellekens (CC BY-NC)
"Just Wondering" by Maarten Schellekens (CC BY-NC)

Photos/Videoclips:
Wikinaut (CC-BY-SA)
Tim Reckmann (CC-BY)
Magic TV (CC0)
Alexas_Fotos (CC0)
juwelfahim48 (CC0)
Danil_Shostak (CC0)
motionstock (CC0)
torstensimon (CC0)
TheMarcKnight (CC0)
INESby (CC0)
jplenio (CC0)
Ra Boe (CC BY-SA 3.0)
Digital_Expert (CC0)

Sources:

0:00 Intro
0:42 ESP-32-cam project
1:54 Abstract
2:45 A reed switch with problems
3:02 Interrupts
5:21 Without interrupts
6:05 The precision of floats
7:09 Binary
9:30 Server side
10:28 Conclusion
10:57 What is the purpose and how to save money
12:22 Outro
Рекомендации по теме
Комментарии
Автор

Some of my viewers have pointed out to me that even "double" variables are liable to cause errors over time and will lead to mismatches in the long run. It seems that it is common practice to solve such problems better with integers or unsigned integers. The decimal places are obtained by dividing the result by 100, as in my case. I amended this in my code on Github. I do the shifting of the decimal place in Node-Red. You can also find the flow on Github.

One additional tip is to buy the plastic encapsulated reed switches instead of the normal glass ones as they are prone to breaking. The viewer @gadjetsvideo brought this to my attention in connection with my window sensor video.

Also, I did not mention in the video that reed switches have different sensitivities to the magnetic field. This is indicated with AT (ampere turns). The viewer @Benedek T. seems to be experienced in this field and recommends reed switches with 6-8 AT for this purpose. Thank you, @Benedek T., for your feedback.

Unfortunately, an error has slipped into the calculation of the binary numbers. Correctly the right side of the decimal point should look like this:
1/2^2 + 1/2^3 + 1/2^6 = 0.25 + 0.125 + 0.015625 = 0.390625
For the small numbers I noted above the binary digits, I should not have started with 0, 1, 2, 3... but with 1, 2, 3, 4...

MakerMeik
Автор

I would even make it an unsigned int, simply dividing by 100 at the very end where it is presented to the user if needed. 😉

Picik
Автор

Loving it! I have a meter that flashes a diode with variable frequency to indicate electricity use. I am thinking of using a photo resistor for this

Brickkzz
Автор

So many comments to make.
1) Re all the problems you had with floats etc., why are you trying to represent this number in your code at all? Can't your ESP01 just send a signal periodically when e.g. 1 unit passes? Then Node-RED does all that counting stuff.
2) General advice about interrupts: they are only required when coding a microcontroller if you have done things that introduce delays in code. This is best avoided. Instead of delays, use timers - far more powerful. Only use ISR when you are needing to sort out deep sleep / battery efficiency etc.
3) If there's switch bounce, deal with it in code. Always better that way. Then you can more easily tweak debounce time to suit. Also if there's accuracy drift over time, you can change this later. Combined with the fact you are using timers instead of delays, it's really easy to code a debounce detection. There is even a cool library you can use if you prefer not to get your hands dirty...

MatSmithLondon
Автор

I hope you upload some more content soon always enjoy your videos

Rhys_Beer
Автор

Just a note: as someone who developed commercial knockoffs for gas meter pulse sensors, it is nontrivial to choose a reed switch, since these magnets in the meters vary quite a bit in strength. I recommend using 6-8 AT ones, and leaving LONG LEADS on them, to help with magnetic fields (this might be a myth, but in my experience, it helps with sensitivity problems).

benedekt.
Автор

You can get rid of all problems with an bipolar position sensor ( the switch version will be inconsistent in time )

JonyMemonyk
Автор

little funfact: floats are called floats because the position of the comma can float. If you look at your meter, you can see that the comma is printed at one place and can't move. Your meter actually works with an integer and the unit is 10־³m³

martinrocket
Автор

Hiyou have two way´s to read the gas counter. What it the best way? ESPcam or mgnetoc pulses?

jbwork
Автор

You should use the debounce library to filter the input

babblo
Автор

Great project, thank you for sharing. BUT
Why there is a magnet inside gas meter???

steveb
Автор

I love the project. Some issues though. First, the calculation is wrong. 0.5 + 0.25 + whatever is certainly more than 0.4. The issue here is, that your first digit after the decimal point stands already for 2^-1. Second, as others pointed out, using double instead of float is just kicking the can down the road. It has essentially the same issues as float, just less often. A better solution would be to use an integer type and count hundredths.

stephan
Автор

Man könnte den ESP über ein Flipflop ein schalten getriggert durch den Zähler, wenn der esp gestartet ist überträgt er die Daten und danach schaltet er sich über den Flipflop selber wieder aus. das ist so stromsparend das man das mit ner Batterie jahrelang betreiben kann, und man umgeht das polling und ein paar andere sachen.

hanssprungfeld
Автор

hi, they are needed to be adjusted to the amount of flow, to maintain a certain temperature in relation to an outside temperature. If the size of a radiator is chosen correctly to the size of the room, then u are right they all have nearly the same flow but in most cases, the flow is different like the gas pedal of a car and every room is a different car but all of them need s to have to maintain the same speed or in ur case room temperature. For this, u need a special computer program to count the resistance in the pipes to even get to set up the pump flow to a correct value, to be able to provide the flow to every room that is needed. That is also the problem why some installation technicians failed to do they install what they guess is good sometimes and often they overbuild the system and the rooms were heated too much un some rooms when u try now to set up the flow u will end up imbalance the system so much that sometimes it gets worse and create loud flow noise when u try to limit the flow, u should get someone to do it for you even the software for this is expensive and most time not sold to individuals because u need the knowledge and training to use this software corectly

christian
Автор

Why not use a hall sensor?
Why not count ticks instead of "0.1 of something" ? Ticks in long integer :)
How did you reduce heating costs by balancing? Doesent the local termostat in each room do that already?

pepethefrog
Автор

Nice project, just to much data: simple solutions : do not use read switch, use a hall sensor, they have no noise. and use some de-bouncing code, best to wait 25ms after a changing before a retrigger is allowed), a hall sensor should not need a de-bouncing as there is no mechanics involved.

patrickmaartense
Автор

Would have been more useful to go through each part and what’s needed

akhan
Автор

again don't use ever, never never use float or double, it unnecessary because of the problem u already see for urself, even the gas meter don't use it, it uses whole numbers and someone painted a dot on the meter for better reading ;-) that is always a rookie mistake, even in databases

christian
join shbcf.ru