jomjol / AI-on-the-edge-device

Easy to use device for connecting "old" measuring units (water, power, gas, ...) to the digital world
https://jomjol.github.io/AI-on-the-edge-device-docs/
5.91k stars 646 forks source link

Mqtt request #23

Closed ff20000 closed 4 years ago

ff20000 commented 4 years ago

Is there a possibility to include a mqtt client so it can send the watermeter reading to the mqtt server. So it can talk to home assistant, domoticz enz..

phlupp commented 4 years ago

i started to implement a modbus server. it will provide actual value via modbus tcp. maybe this is usable as well for you. I am going to use this with ioBroker

jomjol commented 4 years ago

Hi phlupp, as there were several request from other channels, I started also a first implementation. The new rolling version contains a very simple mqtt client. Can we align it with your work, to avoid double implementation?

phlupp commented 4 years ago

@jomjol That is a good idea. I have not started yet, I wait for an update from ioplatform for the espressif environment. They have not yet modbus tcp implemented. But the Mqtt protocol should be already implemented.

phlupp commented 4 years ago

You can vote here

modbus tcp

Jamoth commented 4 years ago

When implementing mqtt with a json messages that includes a value and a timestamp, this would open up for the opportunity to implement a deep sleep mode with timer interrupt. With a button on interrupt the device could be woken up for further configuration or updates. I really would like to see that feature. Keep up the good work.

jomjol commented 4 years ago

Updated MQTT on rolling version, now allowing a user / password logon. How do you consider the deep sleep? I do not see the advantage at the moment. The calculation on the ESP32 takes about 2 minutes. So if you would wake it up, you would need to wait quite some time. The workaround is, to buffer the last read value. This will not work, if you send the ESP to deep sleep. In general technically a JSON respond should not be a problem, beside, that slowly the firmware is running out of free memory, as I can only us roughly half of it, due to OTA.

Jamoth commented 4 years ago

A retained message that has been sent to the mqtt broker eliminates the need to wait for the esp. To get the last read value back onto the esp, once it wakes up, you could read that value back (so no need to save that into flash for deep sleep). For a use case where a new value is only needed (or wanted) every now and then (i.e. once every 3 hours/ once a day) you could reduce the amount of energy used.

jomjol commented 4 years ago

MQTT is implemented, for the moment no JSON is planned. Maybe a future version it is an option. I will close the issue, as the initial request is implemented and tested.