Not sure if any one’s interested – but here’s a copy of my Flow heat Meter. I used a nodemcu and a nodemcu development base. ( $5)
2 flow meters connected to pins D7 and D8 ( $16 DN25)
4 ds18b20 connected to pin D4 ($4)
total $25
the hardest thing is setting up and zeroing out the ds18b20 as there is significant difference in temperature reads between different ds18b20s, and finding ds18b20s that give a constant stable temperature read with very little variation. but i allowed an area for ds calibration…
it takes sampling for and publishes at 5 second intervals. in MQTT Json format -
it will publish to topic FlowA and FlowB
it lists:
input temps (c)
output temps (c)
Flow rate ( l/s)
and energy (w) in both negative and positive values (i.e. if you have a heat pump connected to a radiant floor, it will tell the rate at which the floor is aborbing. when the heat pump is on, it will also tell what rate the floor is losing energy at any given moment – it give’s it in near realtime output, and can be graphed like emontx.- which is useful as you can figure out “realtime” COP and solar thermal energy output to the ~ second - as if they were PV panels – accuracy is reasonable. when error corrected it is about ~0.02- 0.05 degree, which is better than the 0.5c when not error corrected
if using Node-red to process the MQTT packet you will need to pass it through JSON function to convert it from string to an object
in node-red:
MQTT >> JSON>> FREEBOARD
I tried to use your code with arduinoJson 6 but is doesn’t work. I made a change “StaticJsonBuffer<200> jsonBuffer;” to “StaticJsonDocument<200> doc;” I don’t see any other Json programming in your Is it a lot of work to change your code for ArduinoJson 5 to ArduinoJson 6. I think I will help a lot of people, who wants to monitor there heatpump.
thank a lot
greetz Peter
what sort of error do you get when to run it . as i think I started out going to to use arduinojson.h but then just manual constructed the json instead so it does not even rely on it you should be able to comment out those lines arduinojson.h and StaticJsonBuffer<200> jsonBuffer;
Hi, Stephen,
I now can compile you sketch, I downgraded the Json library to version 5 and left your version original. I compiled and uploaded it to an Wemos D1 board. But in the serial screen I see that the board is not resonding as I should, see screenshot. Any idea what I’m doing wrong?
Forgot to say that I comment out the lines arduinojson.h and StaticJsonBuffer<200> jsonBuffer;
Is there a difference in programming in NodeMCU and the Wemos D1 I’am using?
first off does the wemos work with other basic ino ?
since stuff changes all the time what I would do is comment each void block leaving only the void setup() ( commenting out the last three lines setup_wifi(); … etc that call other voids and functions )and work my way through to see what breaking it. i suspect it either something in dallastemperature or how it connect to the network and functions have changed so they need to be updated
example :
see if it starts and runs that block… if it crashes there maybe something changed in DallasTemperature.h see what changed there…
nexted move on to setup_wifi ()
does it start and connect if not see what changed there
and work yourself through each block to find what got broken with library updates
oh yeah and I just remembered a weird quirk of arduino IDE that was introduced later on and wemos sometimes there nothing wrong with the code itself it just being particular on the order at which it calls it … when there a function call the function has to be before the void that called it …
so in the case of this ino you might just have to move void setup_wifi() before void setup() – as this is the only one that I see doing that
Hi Stephan,
I tried your suggestion to move the wifi program blok, but that doesn’t work either.
I orderd some nodeMCU boards at ali-express that takes a while, I hope that the program will work with nodeMCU. I will let you know in this forum,
Hi Stephen,
I have the nodeMCU board, but had still the same problem.
after some experimenting, I commented out pinmode(flowPin1, INPUT)
and AttachInterurrupt, see the attachment. and void flow1 and void flow 2
after that I got a good result on my serial monitor. So the board did not reset anymore. multiple flow heat meter ino.pdf (94.3 KB)
but from looking around the web a little bit it seams they changed the usage of unsigned long to volatile long for the esp – I have not tested just a little look around to see what might of change since
You need to declare a variable that is shared between the Interrupt Service Routine and the main program as “volatile” in order to prevent the compiler from optimising the code - which might lead to the code not working as you intend. Declaring a variable as volatile doesn’t change the type of variable - you can have a volatile unsigned long or a volatile (signed) long.
just for your info - I did an update and my kernel was patched today so now I can flash esp again – I tried the newest esp8266 and it crashes as you say- reverted back to 2.3.0 and it flashed fine . tried 2.6.0 crashes again from the looks they changed something in the attachedinterrupt as all I need to do is comment out those two lines and it no longer crashes… so either revert back to 2.3.0 and flash or figure out what they changed in the newer versions
for what I use I like Version 2.3.0 from what I see the much newer ones compile so slowly and upload even slower
Yessss, it works, I had the also the latest version of the 8266 and that gave the error. I downgraded the version to 2.3.0 and now it works like a charm,
Just one thing Stephan,
I connected 4 temperature sensors, but the program doesn’t find the first (device 0)
sensor. I checked the program but could not find any problem.
do you know what could be the problem?
thanks,