Git Product home page Git Product logo

ferraris_mqtt_energy_counter_meter_tcrt5000's Introduction

build No Maintenance Intended

Logo

Ferraris TCRT5000 ESP8266 Energy Meter Counter MQTT

Description

This project allows you to count the rounds per KWh of meter disk with the red mark of ferraris energy counter . The code is tested on ESP8266 platform. You are able to connect maximum four energy meter. You can use the cheap TCRT5000 as infrared sensors. Printable enclosures are available on thingiverse.

DEPRECATED - This repo will not be updated! See forks for updates!

Features

  • the code creates a filesystem on flash storage of the esp8266
  • all settings are stored on the filesystem in a JSON format
  • Wifi-Manager for easy connection to available AccessPoints
  • MQTT client to transmit the values to a central server like home-automation-systems
  • Webpage to configure all settings or read the values
  • OTA Over-The-Air update of firmware

Logo Logo Logo

Steps to get running

  1. Install VSCode + PlatformIO
  2. Follow the installation guide to compile the framework https://github.com/maakbaas/esp8266-iot-framework/blob/master/docs/installation-guide.md

Calibrate sensor

  1. Connect the sensor Pin A0 to Pin A0 on the NodeMCU board
  2. Open the dashboard and calibrate the sensor by moving up/down - left/right until the best hysteresis
  3. Turn the poti left until the light is off, now turn right and stop when the light turn on.

Logo

Using upload ready binary

You are able to upload the compiled binary without Arduino IDE installed. You will find the compiled bin file in binary folder. The binary supports ESP8266 with 4MB flash e.g. NodeMCU version 2+3.

Weblinks to get running

ToDo

  • adding floats
  • adding gas sensor
  • adding impuls settings for S0

Changelog

Ver. 0.94

(Eisbaeeer 20221225)

  • Last Version - Deprecated. See Forks for updates!!!
  • Changed structure for auto-compiling different boards
  • Fixed: missing react-website compile by auto-compile
  • removed obsolete binary folder

Ver. 0.92

(Eisbaeeer 20211014)

  • Bugfix: Interrupt Routinen bei MQTT Übertragung unterbrochen
  • Bugfix: Interrupt Routinen beim Speichern mit littleFS unterbrochen
  • Dashboard mit zusätzlichen Infos erweitert

Ver. 0.91

(Eisbaeeer 20211011)

  • Graphen zum Dashboard hinzugefügt
  • ISR mit no-delay Entprellung angepasst
  • Nachkommastellen durch fehlerhafte addition von floats entfernt
  • Entprellung ist jetzt konfigurierbar

Version 0.9

(Eisbaeeer 20210917)

  • Graphen zum Dashboard hinzugefügt
  • Analogwert vom Sensor wird jetzt auf dem Dashboard angezeigt

Version 0.8

(Eisbaeeer 20210914)

  • Bugfix Zählerroutine - jetzt per Interrupt auf alle Eingänge

Version 0.7

(Eisbaeeer 20210822)

  • Bugfix Zählerstand
  • Zählerstand auf Nachkommastellen erweitert

Version 0.6

(Eisbaeeer 20210819)

  • Moved from ArduinoIDE to PlatformIO
  • Merged project to framework

Version 0.5

(Eisbaeeer 20210813)

  • Bugfix boolean
  • Added 3 digits after dot

Version 0.4

(Eisbaeeer 20200905)

  • Bugfix Zähler 3 und 4 (Zählerstand)
  • Neu: MQTT Server Port konfigurierbar
  • Neu: MQTT publish Zeit einstellbar (1-9999 Sekunden)
  • Blinken der internen LED aus kompatibilitätsgründen von anderen Boards entfernt (manche Boards nutzen D4 für die interne LED)
    (ACHTUNG: mit dieser Version gehen die Zählerdaten verloren! bitte über Browser neu eintragen!)
  • Neu: Port D4 auf D5 umgezogen! (D4 ist bei manchen Boards die interne LED
  • Neu: Alle Zählerdaten werden im EEPROM abgespeichert.

Version 0.3

(Eisbaeeer)

  • adding upload of firmware bin files via webpage (http://.../update)

Version 0.2

(Eisbaeeer 20200911)

  • fixing debounce to 20ms

Version 0.1

(Eisbaeeer 20200803)

  • Initial Version
  • Filesystem to store and read values from
  • Wifi-Manager to connect to Wifi easy
  • Stored values are in JSON format
  • MQTT client to publish values
  • HTTP page for configuration
  • Over the air update of firmware
  • four meter counter (IR-Input pins)

License

The MIT License (MIT) Copyright (c) 2020 Eisbaeeer [email protected]

ferraris_mqtt_energy_counter_meter_tcrt5000's People

Contributors

eisbaeeer avatar etlamgit avatar morrisjobke avatar ss89 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ferraris_mqtt_energy_counter_meter_tcrt5000's Issues

Huge spikes in the measured kW

Thank you for this project! I tried to achieve the same with ESPHome, but failed to calibrate the sensor. The dashboard with the analog sensor really helps with that.

However, I am still facing issues with bouncing. Sometimes one round results in a spike of the measured kW. See screenshot from my sensor in Home-Assistant.

I already tried adjusting the poti and the debouncing time for the sensor in the configuration. But it's hard to test because the spike only happen sporadically.

How can I best avoid these spikes?
Higher debouncing time? Lower debouncing time?

Thank you!

image

NodeMCU disconnect after some time

For some reason the NodeMCU stop working.
After a while (days) it stops sending data over MQTT and isn´t connected to wlan.
An other device (NodeMCU other firmware at same position) is working well for months.

Unit of meters should be configurable

IMHO the unit of the meters should be configurable, so that the end-user can decide which meter they are reading.

In my case I want to put the device in a room where i have one of each:

  • power meter
  • gas meter
  • water meter

Exception on NodeMcu v3 when opening captive portal in browser

Hi,

I try to make this project run on my NodeMcu v3 and can build and deploy it using PlatformIO without any issues.
My goal is to have later 2 TCRT5000 connected to measure on a single Ferraris counter but with 2 directional detection.

The problem starts when opening the captive portal in the browser to enter my personal Wifi connection data.

My steps to reproduce

  1. restart the NodeMcu and start Serial Monitor (in VS Code): message says "Opened a captive portal", blue LED is on.
  2. connect to wifi "Ferraris MQTT": browser opens automatically the 192.168.4.1 with showing the Wifi settings

when the page has loaded, immediately the serial monitor shows an unhandled C++ exception and the whole NodeMcu crashes and restarts:

The exception starts like this:

Opened a captive portal
192.168.4.1

User exception (panic/abort/assert)
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Unhandled C++ exception: OOM

>>>stack>>>

ctx: sys
sp: 3fffedf0 end: 3fffffb0 offset: 0010
3fffee00:  3fffb05c 4021993c 00000144 4022e896  
3fffee10:  00000000 3fff1684 3fffb05c 4021993c
...

and the bottom of the stack trace shows the beginning always like this:

...
0x4027fef0 in pm_wakeup_init at ??:?
0x4021164c in WiFiUDP::parsePacket() at C:\Users\***\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266WiFi\src/WiFiUdp.cpp:198
0x40233dec in PubSubClient::connected() at .pio\libdeps\nodemcuv2\PubSubClient\src/PubSubClient.cpp:689
0x402299d9 in PubSubClient::loop() at .pio\libdeps\nodemcuv2\PubSubClient\src/PubSubClient.cpp:371
0x402069f5 in WifiManager::loop() at .pio\libdeps\nodemcuv2\ESP8266 IoT Framework\src/WiFiManager.cpp:245
0x4020aef9 in loop at src/main.cpp:370 (discriminator 2)
0x4020b0ab in setup at src/main.cpp:306
0x40100680 in ets_post at C:\Users\***\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/core_esp8266_main.cpp:238
0x401006a1 in esp_schedule at C:\Users\***\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/core_esp8266_main.cpp:136
0x4022ecca in loop_wrapper() at C:\Users\***\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/core_esp8266_main.cpp:264


last failed alloc call: 40219778(324)

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

last failed alloc caller: 0x40219778

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3424, room 16
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8
tail 0
chksum 0x2b
csum 0x2b
v000f1190
~ld

How can I make it run without crashing?
Any help is appreciated!

OLED

Hallo

Währe es möglich ein OLED Display mit einzubinden

LG Gerrit

Use better MQTT format and announce the device

I'm using mosquitto as a MQTT broker and homeAssistant (HA) for home automation. HA wasn't able to auto discover the energy meter, as it won't announce itself over MQTT and is not using json to report itself as a device (or 4 devices). I had to fiddle with config files and parsing of announces values to get correct entities into HA.
It would be really helpful to announce your device over MQTT and use json to transmit the recorded values. You can find examples at: https://www.home-assistant.io/docs/mqtt/discovery/

Support of two TRCT5000 devices per meter to detect direction of meter disc

With installed solar panels it might happen that the Ferraris Meter runs in reverse order as energy is fed into the electric net if the panels provide more energy as consumed locally. So far the project does not detect the direction change and the energy supplied is counted as consumtion.

With two TCRT5000 modules the rotating direction of the meter disk can be detected by evaluating the detection sequence of the disc mark. This should result in either a message reporting the direction or a negative value of the power calculated or both.

As this project supports several meters with a TCRT-module per each, one approach could be to combine the detection of two TCRT-modules mounted to the screen of one meter.

I already developed a design how to mount two TCRT5000 modules to the meter screen. You can find it in https://www.thingiverse.com/thing:5820811

Increase digits of username and password

Hi Eisbaeer,

i found your ferraris counter am I'm thrilled.
Gerate job.
I have one more request.
Is it possible to increase the number of digits in the password and the username to 24 digits?
I would like to send the data to thingspeak because i can only access the internet via my neighbor's wifi there.
The thinkspeak mqtt access generate usernames and passwords with 24 digits.

Thanks

Grüße aus Frankfurt/Main

Marcus

Refactor for more flexibility

Currently for each new meter we want to add, we do need to add a lot of code.

This should be more flexible in my opinion, as in the easiest case i should only have to raise the number of meters and recompile my firmware (maybe not even that?). Depending on the setup of the pins, we'd have to predefine all possible meter to pin configurations.

If we ignore the most flexible way, then i could think of some pre-compiler stuff and we'd be good.

Maybe there is an even smarter way, that doesn't even need pre-compiler magic?

meter counter overflow

Hi, tolles Projekt, schade dass ich erst jetzt darauf gestoßen bin.
Ich hab gerade festgestellt, dass ich mit den kWh von meinem Zähler nicht arbeiten kann, denn dies führt zum Zahlenüberlauf.
Ich muss von 2218269 die beiden ersten Stellen weglassen, damit der Wert noch in einen int32_t passt.

Hi, great project, too bad I only came across it now.
I just realized that I can't work with the kWh from my meter, because this leads to number overflow.
I have to leave out the first two digits from 2218269 so that the value still fits into an int32_t.

cu
Gelbwichtel

Deaktivierung von unnötigen Zählern

Hallo ich habe mal eine frage ich habe nur einen Zähler und bekomme immer alle angezeigt

gibt es eine Möglichkeit die unnötigen zu deaktivieren ?

LG Gerrit

Lolin V3 freeze

Ab und zu friert der esp ein. Dann muss ich immer ein reset machen. Könnte es sein das der eprom Speicher voll läuft?
Nutze einen NodeMCU Lolin V3 Module ESP8266 ESP-12F WIFI

Add a power per day value

The device is exposing the current energy flow (as kW - it would be more useful to announce it as W) and how much energy has been used since it was installed (as kWh). Providing a daily count would be useful too (in kWh), which resets itself to 0 at 00:00 AM.

Hide MQTT password

Whenever I visit the config page, the MQTT password is revealed as plain text. It would be more practical to hide the password once it was saved, as other devices are doing this too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.