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.67k stars 612 forks source link

Photo for gas meter drifting away #101

Closed plin2 closed 3 years ago

plin2 commented 3 years ago

My gas meter implementation is quite instable. I wrote a script fetching the photo from the Digitizer every 5 minutes:

ESP32_gas_pictures

The last proper reading propagated via MQTT is 34500.953.

When I turn the device off/on by removing power it starts all over again.

My config.ini:

[MakeImage] ;LogImageLocation = /log/source ;LogfileRetentionInDays = 15 WaitBeforeTakingPicture = 5 ImageQuality = 5 ImageSize = VGA

[Alignment] InitialRotate = 177 /config/ref0.jpg 40 188 /config/ref1.jpg 432 420 SearchFieldX = 25 SearchFieldY = 25 AlignmentAlgo = Fast

[Digits] Model = /config/dig0721s1.tflite ;LogImageLocation = /log/digit ;LogfileRetentionInDays = 3 ModelInputSize = 20 32 digit1 45 303 37 67 digit2 106 304 37 67 digit3 170 303 37 66 ROI3 234 303 37 66 ROI4 295 303 37 66 ROI5 358 303 37 66 ROI6 420 303 37 66 ROI7 494 303 37 66

;[Analog] Model = /config/ana0630s2.tflite ;LogImageLocation = /log/analog ;LogfileRetentionInDays = 3 ModelInputSize = 32 32 analog1 444 225 92 92 analog2 391 329 92 92 analog3 294 369 92 92 analog4 168 326 92 92 ExtendedResolution = false

[PostProcessing] DecimalShift = -3 PreValueUse = true PreValueAgeStartup = 720 AllowNegativeRates = false MaxRateValue = 9 ErrorMessage = true CheckDigitIncreaseConsistency = true

[MQTT] Uri = mqtt://192.168.3.10:1883 Topic = gaszaehler/zaehlerstand TopicError = gaszaehler/error ClientID = gas ;user = USERNAME ;password = PASSWORD

[AutoTimer] AutoStart = true Intervall = 5

[Debug] Logfile = true LogfileRetentionInDays = 3

[System] TimeZone = CET-1CEST ;TimeServer = fritz.box ;Hostname = watermeter ;SetupMode = false

[Ende]

jomjol commented 3 years ago

Hello Peter,

reading out the pictures every 5 minutes is in the current setting not a good idea. To reduce the SD-card access, the image is then taken just in time. This takes 5-10 seconds and could interfere with the recognition itself. Although the web access is a frequent source of rebooting - reason is not know yet.

If you want to log the images, please use the writing of the files to the SD-card. You can access them via internal fileserver or by reading out the SD-card manually from time to time. The settings for this are:

[MakeImage]
LogImageLocation = /log/source
LogfileRetentionInDays = 3
WaitBeforeTakingPicture = 5
ImageQuality = 5
ImageSize = VGA

With this you would keep the last 3 days on the SD-card.

Beste regards, jomjol

plin2 commented 3 years ago

config.ini is adjusted. Will do a soft reboot and then a hard reboot to be on the safe side.

plin2 commented 3 years ago

update: I had the ESP running all night without any browser access. Now I have less black pictures, but several times they are upside down. ESP32_gas_pictures1 ESP32_gas_pictures2

When I compare the output from the gas meter and information from the heating system, there should be a more linear usage of gas Grafana_ESP32

Currently I'm working with the following markers alg_roi_20210102_1040 I went from the 494 on the bottom to the 1994, because I thought it might be too close to the edge. Now I'm wondering if these two markers don't have enough contrast to be sufficient enough for alignment.

plin2 commented 3 years ago

log_2021-02-01.txt Well, I think to see one pattern: The first hour after a hard reset is fine. Approximately 45-60 minutes after that I see the first upside down picture. Since yesterday evening I have ssen that pattern about 4 to 5 times. Hard resets are marked as blue lines. ESP32_gas_pictures11 ESP32_gas_pictures12 ESP32_gas_pictures16 ESP32_gas_pictures17 I even cleaned the glas of the gas meter, but that didn't help ...

... 2021-02-01_11-33-05: ============================================================================================= 2021-02-01_11-33-05: =================================== Main Started ============================================ 2021-02-01_11-33-05: ============================================================================================= 2021-02-01_11-33-09: Time zone set to CET-1CEST 2021-02-01_11-33-09: task_autodoFlow - next round - Round #1 2021-02-01_11-33-09: FlowControll.doFlow - ClassFlowMakeImage 2021-02-01_11-33-21: FlowControll.doFlow - ClassFlowAlignment 2021-02-01_11-35-18: download_get_handler 2021-02-01_11-35-18: download_get_handler 2021-02-01_11-35-22: download_get_handler 2021-02-01_11-35-22: download_get_handler 2021-02-01_11-35-22: delete_post_handler 2021-02-01_11-35-22: download_get_handler 2021-02-01_11-35-23: download_get_handler 2021-02-01_11-35-23: download_get_handler 2021-02-01_11-35-28: delete_post_handler 2021-02-01_11-35-28: download_get_handler 2021-02-01_11-35-28: download_get_handler 2021-02-01_11-35-28: download_get_handler 2021-02-01_11-36-09: FlowControll.doFlow - ClassFlowDigit 2021-02-01_11-36-27: FlowControll.doFlow - ClassFlowPostProcessing 2021-02-01_11-36-27: FlowControll.doFlow - ClassFlowMQTT 2021-02-01_11-36-27: sent publish successful in MQTTPublish, msg_id=27461, gaszaehler/zaehlerstand, 34514.160 2021-02-01_11-36-27: sent publish successful in MQTTPublish, msg_id=55125, gaszaehler/error, 2021-02-01_11-36-27: task_autodoFlow - round done 2021-02-01_11-36-27: CPU Temperature: 53.3 2021-02-01_11-38-09: task_autodoFlow - next round - Round #2 2021-02-01_11-38-09: FlowControll.doFlow - ClassFlowMakeImage 2021-02-01_11-38-20: FlowControll.doFlow - ClassFlowAlignment 2021-02-01_11-41-01: FlowControll.doFlow - ClassFlowDigit 2021-02-01_11-41-19: FlowControll.doFlow - ClassFlowPostProcessing 2021-02-01_11-41-19: FlowControll.doFlow - ClassFlowMQTT 2021-02-01_11-41-19: sent publish successful in MQTTPublish, msg_id=36929, gaszaehler/zaehlerstand, 34514.160 2021-02-01_11-41-19: sent publish successful in MQTTPublish, msg_id=23031, gaszaehler/error, 2021-02-01_11-41-19: task_autodoFlow - round done 2021-02-01_11-41-19: CPU Temperature: 61.1 2021-02-01_11-43-09: task_autodoFlow - next round - Round #3 2021-02-01_11-43-09: FlowControll.doFlow - ClassFlowMakeImage 2021-02-01_11-43-20: FlowControll.doFlow - ClassFlowAlignment 2021-02-01_11-44-58: FlowControll.doFlow - ClassFlowDigit 2021-02-01_11-45-16: FlowControll.doFlow - ClassFlowPostProcessing 2021-02-01_11-45-16: FlowControll.doFlow - ClassFlowMQTT 2021-02-01_11-45-16: sent publish successful in MQTTPublish, msg_id=60589, gaszaehler/zaehlerstand, 34514.258 2021-02-01_11-45-16: sent publish successful in MQTTPublish, msg_id=35517, gaszaehler/error, 2021-02-01_11-45-16: task_autodoFlow - round done 2021-02-01_11-45-16: CPU Temperature: 60.0 2021-02-01_11-48-09: task_autodoFlow - next round - Round #4 2021-02-01_11-48-09: FlowControll.doFlow - ClassFlowMakeImage 2021-02-01_11-48-20: FlowControll.doFlow - ClassFlowAlignment 2021-02-01_11-48-29: FlowControll.doFlow - ClassFlowDigit 2021-02-01_11-48-47: FlowControll.doFlow - ClassFlowPostProcessing 2021-02-01_11-48-47: FlowControll.doFlow - ClassFlowMQTT 2021-02-01_11-48-47: sent publish successful in MQTTPublish, msg_id=290, gaszaehler/zaehlerstand, 34514.266 2021-02-01_11-48-47: sent publish successful in MQTTPublish, msg_id=35964, gaszaehler/error, 2021-02-01_11-48-47: task_autodoFlow - round done 2021-02-01_11-48-47: CPU Temperature: 53.3 2021-02-01_11-53-09: task_autodoFlow - next round - Round #5 2021-02-01_11-53-09: FlowControll.doFlow - ClassFlowMakeImage 2021-02-01_11-53-20: FlowControll.doFlow - ClassFlowAlignment 2021-02-01_11-54-58: FlowControll.doFlow - ClassFlowDigit 2021-02-01_11-55-16: FlowControll.doFlow - ClassFlowPostProcessing 2021-02-01_11-55-16: FlowControll.doFlow - ClassFlowMQTT 2021-02-01_11-55-16: sent publish successful in MQTTPublish, msg_id=27322, gaszaehler/zaehlerstand, 34514.359 2021-02-01_11-55-16: sent publish successful in MQTTPublish, msg_id=26682, gaszaehler/error, 2021-02-01_11-55-16: task_autodoFlow - round done 2021-02-01_11-55-16: CPU Temperature: 58.9 2021-02-01_11-58-09: task_autodoFlow - next round - Round #6 2021-02-01_11-58-09: FlowControll.doFlow - ClassFlowMakeImage 2021-02-01_11-58-20: FlowControll.doFlow - ClassFlowAlignment 2021-02-01_11-58-29: FlowControll.doFlow - ClassFlowDigit 2021-02-01_11-58-47: FlowControll.doFlow - ClassFlowPostProcessing 2021-02-01_11-58-47: FlowControll.doFlow - ClassFlowMQTT 2021-02-01_11-58-47: sent publish successful in MQTTPublish, msg_id=10627, gaszaehler/zaehlerstand, 34514.367 2021-02-01_11-58-47: sent publish successful in MQTTPublish, msg_id=55797, gaszaehler/error, 2021-02-01_11-58-47: task_autodoFlow - round done 2021-02-01_11-58-47: CPU Temperature: 53.3 2021-02-01_12-03-09: task_autodoFlow - next round - Round #7 2021-02-01_12-03-09: FlowControll.doFlow - ClassFlowMakeImage 2021-02-01_12-03-21: FlowControll.doFlow - ClassFlowAlignment 2021-02-01_12-03-29: FlowControll.doFlow - ClassFlowDigit 2021-02-01_12-03-47: FlowControll.doFlow - ClassFlowPostProcessing 2021-02-01_12-03-48: FlowControll.doFlow - ClassFlowMQTT 2021-02-01_12-03-48: sent publish successful in MQTTPublish, msg_id=7557, gaszaehler/zaehlerstand, 34514.367 2021-02-01_12-03-48: sent publish successful in MQTTPublish, msg_id=58005, gaszaehler/error, 2021-02-01_12-03-48: task_autodoFlow - round done 2021-02-01_12-03-48: CPU Temperature: 53.3 2021-02-01_12-08-09: task_autodoFlow - next round - Round #8 2021-02-01_12-08-09: FlowControll.doFlow - ClassFlowMakeImage 2021-02-01_12-08-20: FlowControll.doFlow - ClassFlowAlignment 2021-02-01_12-09-59: FlowControll.doFlow - ClassFlowDigit 2021-02-01_12-10-17: FlowControll.doFlow - ClassFlowPostProcessing 2021-02-01_12-10-17: FlowControll.doFlow - ClassFlowMQTT 2021-02-01_12-10-17: sent publish successful in MQTTPublish, msg_id=58496, gaszaehler/zaehlerstand, 34514.441 2021-02-01_12-10-17: sent publish successful in MQTTPublish, msg_id=36365, gaszaehler/error, 2021-02-01_12-10-17: task_autodoFlow - round done 2021-02-01_12-10-17: CPU Temperature: 53.3 2021-02-01_12-13-09: task_autodoFlow - next round - Round #9 2021-02-01_12-13-09: FlowControll.doFlow - ClassFlowMakeImage 2021-02-01_12-13-18: FlowControll.doFlow - ClassFlowAlignment 2021-02-01_12-17-28: FlowControll.doFlow - ClassFlowDigit 2021-02-01_12-17-46: FlowControll.doFlow - ClassFlowPostProcessing 2021-02-01_12-17-46: FlowControll.doFlow - ClassFlowMQTT 2021-02-01_12-17-46: sent publish successful in MQTTPublish, msg_id=62381, gaszaehler/zaehlerstand, 34514.441 2021-02-01_12-17-46: sent publish successful in MQTTPublish, msg_id=18063, gaszaehler/error, 2021-02-01_12-17-46: task_autodoFlow - round done 2021-02-01_12-17-46: CPU Temperature: 53.3 2021-02-01_12-18-10: task_autodoFlow - next round - Round #10 2021-02-01_12-18-10: FlowControll.doFlow - ClassFlowMakeImage 2021-02-01_12-18-18: FlowControll.doFlow - ClassFlowAlignment 2021-02-01_12-22-34: FlowControll.doFlow - ClassFlowDigit 2021-02-01_12-22-52: FlowControll.doFlow - ClassFlowPostProcessing 2021-02-01_12-22-52: FlowControll.doFlow - ClassFlowMQTT 2021-02-01_12-22-52: sent publish successful in MQTTPublish, msg_id=34605, gaszaehler/zaehlerstand, 34514.441 2021-02-01_12-22-52: sent publish successful in MQTTPublish, msg_id=25281, gaszaehler/error, 2021-02-01_12-22-52: task_autodoFlow - round done 2021-02-01_12-22-52: CPU Temperature: 53.3 2021-02-01_12-23-10: task_autodoFlow - next round - Round #11 2021-02-01_12-23-10: FlowControll.doFlow - ClassFlowMakeImage 2021-02-01_12-23-18: FlowControll.doFlow - ClassFlowAlignment 2021-02-01_12-25-57: FlowControll.doFlow - ClassFlowDigit 2021-02-01_12-26-15: FlowControll.doFlow - ClassFlowPostProcessing 2021-02-01_12-26-15: FlowControll.doFlow - ClassFlowMQTT 2021-02-01_12-26-15: sent publish successful in MQTTPublish, msg_id=6401, gaszaehler/zaehlerstand, 34514.441 2021-02-01_12-26-15: sent publish successful in MQTTPublish, msg_id=22082, gaszaehler/error, 2021-02-01_12-26-15: task_autodoFlow - round done 2021-02-01_12-26-15: CPU Temperature: 71.1 2021-02-01_12-28-10: task_autodoFlow - next round - Round #12 2021-02-01_12-28-10: FlowControll.doFlow - ClassFlowMakeImage 2021-02-01_12-28-18: FlowControll.doFlow - ClassFlowAlignment 2021-02-01_12-32-26: FlowControll.doFlow - ClassFlowDigit 2021-02-01_12-32-44: FlowControll.doFlow - ClassFlowPostProcessing 2021-02-01_12-32-44: FlowControll.doFlow - ClassFlowMQTT 2021-02-01_12-32-44: sent publish successful in MQTTPublish, msg_id=22317, gaszaehler/zaehlerstand, 34514.441 2021-02-01_12-32-44: sent publish successful in MQTTPublish, msg_id=63398, gaszaehler/error, 2021-02-01_12-32-44: task_autodoFlow - round done 2021-02-01_12-32-44: CPU Temperature: 71.1 2021-02-01_12-33-10: task_autodoFlow - next round - Round #13 2021-02-01_12-33-10: FlowControll.doFlow - ClassFlowMakeImage 2021-02-01_12-33-18: FlowControll.doFlow - ClassFlowAlignment 2021-02-01_12-37-29: FlowControll.doFlow - ClassFlowDigit 2021-02-01_12-37-47: FlowControll.doFlow - ClassFlowPostProcessing 2021-02-01_12-37-47: FlowControll.doFlow - ClassFlowMQTT 2021-02-01_12-37-47: sent publish successful in MQTTPublish, msg_id=10950, gaszaehler/zaehlerstand, 34514.441 2021-02-01_12-37-47: sent publish successful in MQTTPublish, msg_id=49266, gaszaehler/error, Negative Rate - Returned old value - read value: 34514.438 - raw value: N0NNN.NNN 2021-02-01_12-37-47: task_autodoFlow - round done 2021-02-01_12-37-47: CPU Temperature: 53.3 2021-02-01_12-38-10: task_autodoFlow - next round - Round #14 2021-02-01_12-38-10: FlowControll.doFlow - ClassFlowMakeImage 2021-02-01_12-38-18: FlowControll.doFlow - ClassFlowAlignment 2021-02-01_12-39-47: File is locked: /sdcard/html/robots.txt - wait for 1 2021-02-01_12-39-49: download_get_handler 2021-02-01_12-39-49: download_get_handler 2021-02-01_12-39-49: download_get_handler 2021-02-01_12-39-49: download_get_handler 2021-02-01_12-39-49: download_get_handler 2021-02-01_12-39-49: download_get_handler 2021-02-01_12-39-49: download_get_handler 2021-02-01_12-39-50: download_get_handler 2021-02-01_12-39-50: download_get_handler 2021-02-01_12-40-28: download_get_handler 2021-02-01_12-40-29: File is locked: /sdcard/html/robots.txt - wait for 1 2021-02-01_12-40-31: download_get_handler ...

jomjol commented 3 years ago

Hello Peter, it is hard for me to do here a remote debugging. I suggest to get in personal contact (e.g. skype) and discuss this problem there. Can you somehow send me a private message through another channel (via iobroker or fhem, ...) with your email, than I will contact you this way. Best regards, jomjol

jomjol commented 3 years ago

Hallo Peter, ich schließe den Issue mal nach unserer offline Diskussion und deiner positiven RM, dass es vermutlich eher an der Hardware liegt. Beste Grüße, jomjol

plin2 commented 3 years ago

Additional information for those who run into the same problem: How do you determine that your ESP32-CAM is defect? I used another ESP32-CAM with the old sd card. The problem didn't occur any more. Then I flashed the sample ESP32-CAM Webcam sketch onto the "defect" one. Even that stopped working after some time.