- 12.11.2018: ordered 1st flow sensor (male-female, 6.55cm) for 7.10€
- 1/2" YF-B4 NTC Brass water Hall flow sensor flow rate temperature measurement METER
- arrived on ??
- Only noticed then that it's not bidirectional and this one is exactly the wrong way around, such that I need to use two adapters for it.
- 23.01.2019: ordered 2nd flow sensor (male-male, 4.4cm) for 8.48€
- 17.01.2020: Wemos D1 mini stopped working because it rusted because water was dripping from the ceiling (not from normal showering but leak from apartment above). See rust-1.jpg, rust-2.jpg.
- 18.01.2020: installed replacement Wemos D1 mini (now on small breadboard with most wiring done under the PCB).
- Fixed bug: duration was 30s too long (included timeout).
- Fixed reporting of flow when light switch is turned on/off by ignoring the first pulse interval. TODO: might need to ignore up to 3 intervals ({1: 3156, 2: 147, 3: 3, 4: 0}).
- Flow worked, but temperatures are way too high > 110-147 C.
- 20.01.2020: debugged temperature issue with 1st replacement D1 mini -> 2nd replacement. Tried 2nd flow sensor. Fried 2nd replacement?
- A0 is not working right: ~2.8 V measured between GND and A0, when shorted it should report 0, but it led to reboot. 3V3-A0 works and reports 1023. Seems like A0 is connected to something it shouldn't be. Header pins are soldered fine.
- Soldered header pins to another replacement Wemos D1 mini. Everything works as expected: A0-3V3 reports 1023, A0-GND reports 0.
- Temperatures seem as before. Took the chance to compare:
- Directly measured NTC thermistor's resistance, temperature from table (cut-off):
- middle: 34 kOhm -> ?
- coldest: 84.60 kOhm -> 13.5 C
- warmest: 13.57 kOhm -> 54 C?
- Temperatures IR:NTC (IR temp. gun aimed at bathtub with shower head ~5cm above : calculated temp.)
- middle: 33.6:36.6 33.1:36.2
- coldest: 11.0:12.60 10.6:12.24 10.3:11.97
- warmest: 52.3:61.29 52.3:62.16
- Values seem good enough. Maybe water cools off between sensor and shower head.
- Directly measured NTC thermistor's resistance, temperature from table (cut-off):
- Switched to 2nd flow sensor since it's shorter (see flow-sensors.jpg for comparison) and have not tried it yet.
- Flow seems to be the same. Resistance of thermistor is slightly different: ~32kOhm@34C, 77kOhm@10C, 20kOhm@55C.
- Resistance is much less responsive than for the other flow sensor. This one seems to have the NTC on the outside of the metal, where the other one has it on a pin that is screwed in so that it's in the stream.
- E.g. changed water from 10C to 54C (~5s IR temp.), resistance took >1min to change from 77kOhm to 28kOhm, would have taken even longer to reach 20kOhm. The other flow sensor (84.6-13.6kOhm range) went from 80kOhm to 24kOhm in 10s and to 16kOhm in 20s.
- -> changed back to 1st flow sensor
- After changing back to 1st flow sensor the 2nd Wemos D1 mini broke? Post-mortem:
- Does not boot reliably anymore. Can connect via serial, but initially it just crash-looped with 'Fatal exception (0): epc1=0x4023a09c, ...'
- Not able to flash (or do anything with esptool): 'Failed to connect to ESP8266: Timed out waiting for packet header'
- 22.01.2020:
- fix-logs.py to normalize logs
- fix-logs.sh to delete spurious start/flow{1,3}/stop sequences, kept ~/shower.org.log (after fix-logs.py) to drop diff from InfluxDB (TODO)
- 23.01.2020: Tried to debug bricked 2nd D1 mini again.
- Hall effect sensor was connected to 5V and signal on D5 is then also a square wave between 0 and 5V (checked yesterday on oscilloscope with the 2nd flow sensor). For the 2nd flow sensor I get the same wave with 3.3V. Maybe should have connected it to 3.3V instead? Later found out that only the 2nd one works with 3.3V whereas the 1st flow sensor needs at least 5V.
- Could that have killed it? Google search says Wemos D1 mini's GPIO pins should be 5V tolerant:
- https://forum.arduino.cc/index.php?topic=428521.msg2955576#msg2955576
- Some people say it could break it after some time. However, mine was running fine for 9 months and only broke after reconnecting the initial flow sensor, so more likely there was some problem there (but connections were fine).
- Now it started flashing, but then esptool stopped at 60% with exception 'Failed to write compressed data to flash after seq 8 (result was C100)'
esptool.py -b 9600 --port /dev/cu.wchusbserialfa130 chip_id
failed atRunning stub...
withStopIteration
, but worked without-b 9600
.- Changed default baud rate for flashing back to 115200 and it flashed successfully from vscode...
- However, the module stil seems damaged. Only seldomly manages to connect to Wifi < 30s, mostly fails and restarts, also loses connection after it was established. On reset it often goes into the crash-loop mentioned above. Only fixed by re-flashing. -> Abandon.
- Resoldered both replacement Wemos D1 minis (only the ESP8266 onto the PCB). No change.
- Tried to fix the A0 on the previous Wemos D1 mini by replacing R16 (part of voltage divider to extend range from 1V to 3.2V) which only measured 167 kOhms instead of the 224 kOhms on the other two Wemos D1 minis. Desoldered replacement from the rusted one. Did not fix A0 being high at 3.3V instead of 0V.
- Desoldered R16 again. Now A0 was at 3.3V but the ESP's ADC pin at almost 0V (before at 1V).
- The schematic says: A0 -220kOhm-> ADC -> 100kOhm -> GND.
- A0-ADC was ~280kOhm with replaced R16. ADC-GND is the correct 100kOhm.
- The short (maybe to the RST pin which is 3.3V) must be inside the PCB. There aren't any components. The vias look normal.
- On the other one RST-A0 is infty, and A0-RST is 0Ohm, whereas here RST-A0 is 350kOhm?
- Could make/adjust my own voltage divider and use the 1V ADC pin instead of the 3.3V A0 instead.
- Abandon Wemos D1 minis and try Doit ESP32 DevKit V1 board.
- Needed larger breadboard and some wiring below since it's so wide that only one row on one side is free.
- Needed to adjust code since some includes are different (used ifdef, also to switch pin config).
- Hardware differences:
- It has 6 usable ADC pins (only ADC1 since ADC2 is shared with Wifi) with 12bit resolution instead of one A0 with 10bit on the Wemos. This claims slightly non-linear behavior, but linked issue claims it's fixed; TODO test.
- Wemos says its GPIO pins are 5V tolerant, whereas this only mentions 3.3V.
- Test on breadboard with 2nd flow sensor on 3.3V worked. Tried in bathroom with 1st flow sensor and didn't work. Only than noticed that the 1st flow sensor really needs 5V as opposed to the 2nd flow sensor. Checked with oscilloscope: with 3.3V it always stays high, wanted to check with 5V and only then noticed that the breadboard power supply gave 7V instead of 5V when switched from 3.3V to 5V. Checked flow sensor with 7V and got square wave. First thought the breadboard power supply broke, but then noticed that it gave 5V with another micro USB power supply. Checked bathroom micro USB power supply and it really is at 7V now... When did that break and did that fry the Wemos? Checked power supply again on 11.03.2020: only shows 7V at 0A, but 5.5V at 0.05A, so that was probably not a problem.
- Measured current GND-SIG on 1st flow sensor on 5V to see if I need a level shifter or current limiting resistor to use it on the 3.3V specified ESP32 pins at all.
- 80uA at 0V setting; 495uA at 5V setting. Disconnected from power, measured 10kOhm between SIG-GND and SIG-VCC. Should be fine.
- Tried Wemos again, but still 'Failed to connect to ESP8266: Timed out waiting for packet header'.
- Installed Doit ESP32 with flow sensor on 5V and signal pin directly into D15.
- Temperatures were a bit too low (cold -3, middle -7, hot -10), calibrated with IR gun. Introduced tempFactor 1.2 (range was 1.20-1.35) and tempOffset 1.0 to fit the curve. tempFactor 1.25 without offset was also ok, but a bit too cold in the cold range.
- 25.01.2020: seems like everything is working fine now with Doit ESP32 and replacement power supply.
- Reconnected 3 times to MQTT today. WiFi seems not to be super stable.
- Still there's the issue with the light switch triggering interrupts.
- This guy said he had the same problem and it was fixed by putting a ferrite bead around the power cable. Had some mini USB cables with ferrite beads, but they couldn't be taken off. Ordered 5x 5mm ferrite cores.
- 26.02.2020: disconnected Doit ESP32 since it was not reliable:
- Sometimes it did not start measuring. Needed to be reset then ((un)plug power).
- Sometimes it kept measuring pulses after flow has stopped. This happend more often after some time. Needed to be reset to make it stop.
- Sometimes it reported single temperatures -340C up to 310 in between correct temperatures.
- 29.02.2020: Got ferrite beads.
- 06.03.2020: Got three new Wemos D1 minis.
- 11.03.2020: Removed Doit ESP32 and installed Wemos D1 mini again (still had its breadboard).
- Noticed that flow sensor does not work anymore (signal stays at 5V so it's not the cables). USB via MBP and power supply (PS) delivers 5.04V, but Wemos D1 mini only has 4.6V on 5V with MBP and only 3.9-4.15V with PS. Thought that is the problem. But also if connected to the 5V directly it does not show any pulses on oscilloscope anymore.
- 12.03.2020: Connected the 2nd flow sensor which works fine and shows pulses at 5V (and also at 3.2V).
- Measured temperature: coldest IR 11.7C, NTC 15.87; turned to hottest; IR 56C 24C NTC after 2s; 34C after 40s; 58.2C IR, 42C NTC after 1m30s; 45C NTC after 2m30s. Seems to be a logistic curve, since it takes longer at the to reach the extremes, but still much slower than the 1st flow sensor NTC.
- Let 25C water run, took >2m to reach 48kOhm, probably also 50kOhm at 25C but very slow to reach. Set R25C to 47000.
- Used thermistor calculator with pairs 77kOhm @ 10C, 47kOhm @ 25C, 20kOhm @ 55C to calculate new beta model coefficient of 2778.34, which aligned perfectly with the Steinhart-Hart model curve. Ok, but takes several minutes to stabilize at a temperature.
- ordered (6.20$) 1st flow sensor again, but male-male.
- Put ferrite bead around USB cable from power supply.
- 24.04.2020: Replaced 2nd flow sensor with the 1st flow sensor replacement. Works and temperature reacts much faster again. Quick test with old values: min 12C IR, 14C NTC; max 58C IR, 57C NTC.