Mqttt json message modifying while keeping intact

I did have to reverse a few things. but here is final flow
This is all your handy work @jbudd
Thanks

[{"id":"0f25d2844dab6c70","type":"mqtt in","z":"a34699b03789f7a6","name":"","topic":"tele/tas04/SENSOR","qos":"2","datatype":"json","broker":"31a99116.50a74e","nl":false,"rap":true,"rh":0,"inputs":0,"x":188.7339096069336,"y":282.2945861816406,"wires":[["a8ce7ae004eb838d"]]},{"id":"af7b42134d95a389","type":"link out","z":"a34699b03789f7a6","name":"West Fermenter Pressure","mode":"link","links":["5e4137c9fb96d24a"],"x":894.6302433013916,"y":242.22614097595215,"wires":[]},{"id":"21ad697deffbb97d","type":"link out","z":"a34699b03789f7a6","name":"Center Fermenter Pressure","mode":"link","links":["64e923c9d54a85a8"],"x":893.9075260162354,"y":278.41923332214355,"wires":[]},{"id":"2a72d10832148992","type":"link out","z":"a34699b03789f7a6","name":"East Fermenter Pressure","mode":"link","links":["9ef4a9cf492199bf"],"x":894.7007389068604,"y":314.6126232147217,"wires":[]},{"id":"5f0d481a6c5282fb","type":"link out","z":"a34699b03789f7a6","name":"extra","mode":"link","links":[],"x":891.9381046295166,"y":348.30430364608765,"wires":[]},{"id":"2a71b465c3426380","type":"mqtt in","z":"a34699b03789f7a6","name":"","topic":"tele/tas04/SENSOR","qos":"2","datatype":"json","broker":"31a99116.50a74e","nl":false,"rap":true,"rh":0,"inputs":0,"x":190.63024139404297,"y":525.2261180877686,"wires":[["53bbf35e81420d8e","c5c7ca43eee833fb"]]},{"id":"a8ce7ae004eb838d","type":"function","z":"a34699b03789f7a6","name":"Fermenters Pressure","func":"let msg0 = {};\nlet msg1 = {};\nlet msg2 = {};\nlet msg3 = {};\nfunction myfunction(sensorValue) {\n    let volts = sensorValue * 0.1875 / 1000\n    let psi = (volts - 0.5) * 30 / 4 // replace \"30\" with ever your max is on your transducer also assuming your range is 0.5-4.5 volts \n    return {\n        'sensorValue': sensorValue,\n        'psi': psi >= 0 ? psi : 0,\n        'volts': volts,\n     }\n}\nmsg0.payload = myfunction(msg.payload.ADS1115.A0);\nmsg1.payload = myfunction(msg.payload.ADS1115.A1);\nmsg2.payload = myfunction(msg.payload.ADS1115.A2);\nmsg3.payload = myfunction(msg.payload.ADS1115.A3);\nreturn [msg0, msg1, msg2, msg3];\n","outputs":4,"noerr":0,"initialize":"","finalize":"","libs":[],"x":397.6303024291992,"y":282.22622871398926,"wires":[["533cceab00a2329e"],["d90a057d90414b1d"],["382ed0af7e4f3afb"],["db73da70aa858f22"]]},{"id":"533cceab00a2329e","type":"smooth","z":"a34699b03789f7a6","name":"","property":"payload.psipayload.psi","action":"mean","count":"10","round":"2","mult":"single","reduce":false,"x":658.701244354248,"y":243.92142295837402,"wires":[["15d5dba10a15f828","af7b42134d95a389"]]},{"id":"d90a057d90414b1d","type":"smooth","z":"a34699b03789f7a6","name":"","property":"payload.psi","action":"mean","count":"10","round":"2","mult":"single","reduce":false,"x":657.611629486084,"y":277.9664897918701,"wires":[["56f77712fb804a5d","21ad697deffbb97d"]]},{"id":"382ed0af7e4f3afb","type":"smooth","z":"a34699b03789f7a6","name":"","property":"payload.psi","action":"mean","count":"10","round":"2","mult":"single","reduce":false,"x":658.7011184692383,"y":312.19068717956543,"wires":[["4c2178a1e77099e8","2a72d10832148992"]]},{"id":"db73da70aa858f22","type":"smooth","z":"a34699b03789f7a6","name":"","property":"payload.psi","action":"mean","count":"10","round":"2","mult":"single","reduce":false,"x":657.7908592224121,"y":349.1462993621826,"wires":[["412cef82df117dcc","5f0d481a6c5282fb"]]},{"id":"15d5dba10a15f828","type":"debug","z":"a34699b03789f7a6","name":"West","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":797.6056480407715,"y":243.0110263824463,"wires":[]},{"id":"56f77712fb804a5d","type":"debug","z":"a34699b03789f7a6","name":"Center","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":795.4337730407715,"y":277.9665355682373,"wires":[]},{"id":"4c2178a1e77099e8","type":"debug","z":"a34699b03789f7a6","name":"East","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":794.5382652282715,"y":314.19074058532715,"wires":[]},{"id":"412cef82df117dcc","type":"debug","z":"a34699b03789f7a6","name":"extra","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":796.4338340759277,"y":349.3254222869873,"wires":[]},{"id":"53bbf35e81420d8e","type":"function","z":"a34699b03789f7a6","name":"Boil Kettle Volume","func":"let msg0 = {};\nlet msg1 = {};\nlet msg2 = {};\nlet msg3 = {};\nlet msg4 = {};\nfunction myfunction(sensorValue) {\n    let volts = sensorValue * 0.1875 / 1000\n    let psi = (volts - 0.5) * 5 / 4\n    return {'sensorValue': sensorValue, 'psi': psi >= 0 ? psi : 0, 'volts': volts,};\n}\n\nmsg0.payload = myfunction(msg.payload.ADS1115.A0);\nmsg1.payload = myfunction(msg.payload.ADS1115.A1);\nmsg2.payload = myfunction(msg.payload.ADS1115.A2);\nmsg3.payload = myfunction(msg.payload.ADS1115.A3);\n\nlet upper = msg2.payload.psi;\nlet lower = msg1.payload.psi;\nlet sensorDist = (lower * 27.72) - (upper * 27.72);// this only works with water at specific gravity of 1.000 change formula to number you collect on first run\nlet specgrav = ((lower * 27.72) - (upper * 27.72)) / sensorDist;\nlet boilwc = (lower * 27.72) / specgrav;\nlet cubicinch = boilwc * 1017;\nlet boilVolume = cubicinch * 0.004329;\nmsg4.payload = {'boilVolume': boilVolume, 'gravity': specgrav};\nreturn [msg0, msg1, msg2, msg3, msg4];","outputs":5,"noerr":0,"initialize":"","finalize":"","libs":[],"x":391.7909164428711,"y":461.2041893005371,"wires":[[],[],[],[],["a533cc071d544180","504641de737e27df"]]},{"id":"504641de737e27df","type":"debug","z":"a34699b03789f7a6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":556.3071556091309,"y":435.51550102233887,"wires":[]},{"id":"a533cc071d544180","type":"link out","z":"a34699b03789f7a6","name":"Boil Volume","mode":"link","links":["d3730ac5b85a4c2d"],"x":583.8906803131104,"y":487.7912120819092,"wires":[]},{"id":"c5c7ca43eee833fb","type":"function","z":"a34699b03789f7a6","name":"HLT Volume ","func":"let msg0 = {};\nlet msg1 = {};\nlet msg2 = {};\nlet msg3 = {};\nlet msg4 = {};\nfunction myfunction(sensorValue) {\n    let volts = sensorValue * 0.1875 / 1000\n    let psi = (volts - 0.5) * 5 / 4\n    return {'sensorValue': sensorValue, 'psi': psi >= 0 ? psi : 0, 'volts': volts,};\n}\n\nmsg0.payload = myfunction(msg.payload.ADS1115.A0);\nmsg1.payload = myfunction(msg.payload.ADS1115.A1);\nmsg2.payload = myfunction(msg.payload.ADS1115.A2);\nmsg3.payload = myfunction(msg.payload.ADS1115.A3);\n\nlet upper = msg2.payload.psi;\nlet hltsensor = msg0.payload.psi;\n//let sensorDist = (lower * 27.72) - (upper * 27.72);// this only works with water at specific gravity of 1.000 change formula to number you collect on first run\n//let specgrav = ((lower * 27.72) - (upper * 27.72)) / sensorDist;\nlet hltwc = (hltsensor * 27.72);\nlet cubicinch = hltwc * 1017;\nlet hltVolume = cubicinch * 0.004329;\nmsg4.payload = {'hltVolume': hltVolume};\nreturn [msg0, msg1, msg2, msg3, msg4];","outputs":5,"noerr":0,"initialize":"","finalize":"","libs":[],"x":372.01171875,"y":561.0157127380371,"wires":[[],[],[],[],["f819fe9c7700486a","4ffe53c2526b4296"]]},{"id":"f819fe9c7700486a","type":"link out","z":"a34699b03789f7a6","name":"HLT volume","mode":"link","links":["54edad0afe454bd9"],"x":518.2617282867432,"y":587.8418712615967,"wires":[]},{"id":"4ffe53c2526b4296","type":"debug","z":"a34699b03789f7a6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":547.2578353881836,"y":529.9356212615967,"wires":[]},{"id":"31a99116.50a74e","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]

off topic a bit; How did you read the ADS1115? what nodes do you use?

Do you need for pressure or for volume?

here is my flow, top just covers psi
lower is how I calculate volume, however i had to "//" some lines because of issues.
and i have a weird thing going on with one of my sensors reading incorrectly by 50 percent.
so I had to make an adjustment.

[{"id":"a34699b03789f7a6","type":"tab","label":"pressuresensors","disabled":false,"info":"","env":[]},{"id":"0f25d2844dab6c70","type":"mqtt in","z":"a34699b03789f7a6","name":"","topic":"tele/tas04/SENSOR","qos":"2","datatype":"json","broker":"31a99116.50a74e","nl":false,"rap":true,"rh":0,"inputs":0,"x":155.73391723632812,"y":281.29459381103516,"wires":[["a8ce7ae004eb838d","04778b58f2249d9f"]]},{"id":"af7b42134d95a389","type":"link out","z":"a34699b03789f7a6","name":"West Fermenter Pressure","mode":"link","links":["5e4137c9fb96d24a"],"x":894.6302433013916,"y":242.22614097595215,"wires":[]},{"id":"21ad697deffbb97d","type":"link out","z":"a34699b03789f7a6","name":"Center Fermenter Pressure","mode":"link","links":["64e923c9d54a85a8"],"x":893.9075260162354,"y":278.41923332214355,"wires":[]},{"id":"2a72d10832148992","type":"link out","z":"a34699b03789f7a6","name":"East Fermenter Pressure","mode":"link","links":["9ef4a9cf492199bf"],"x":894.7007389068604,"y":314.6126232147217,"wires":[]},{"id":"5f0d481a6c5282fb","type":"link out","z":"a34699b03789f7a6","name":"extra","mode":"link","links":[],"x":891.9381046295166,"y":348.30430364608765,"wires":[]},{"id":"a8ce7ae004eb838d","type":"function","z":"a34699b03789f7a6","name":"Fermenters Pressure","func":"let msg0 = {};\nlet msg1 = {};\nlet msg2 = {};\nlet msg3 = {};\nfunction myfunction(sensorValue) {\n    let volts = sensorValue * 0.1875 / 1000\n    let psi = (volts - 0.5) * 30 / 4 // replace \"30\" with ever your max is on your transducer also assuming your range is 0.5-4.5 volts \n    return {\n        'sensorValue': sensorValue,\n        'psi': psi >= 0 ? psi : 0,\n        'volts': volts,\n     }\n}\nmsg0.payload = myfunction(msg.payload.ADS1115.A0);\nmsg1.payload = myfunction(msg.payload.ADS1115.A1);\nmsg2.payload = myfunction(msg.payload.ADS1115.A2);\nmsg3.payload = myfunction(msg.payload.ADS1115.A3);\nreturn [msg0, msg1, msg2, msg3];\n","outputs":4,"noerr":0,"initialize":"","finalize":"","libs":[],"x":397.6303024291992,"y":282.22622871398926,"wires":[["533cceab00a2329e"],["d90a057d90414b1d"],["382ed0af7e4f3afb"],["db73da70aa858f22"]]},{"id":"533cceab00a2329e","type":"smooth","z":"a34699b03789f7a6","name":"","property":"payload.psi","action":"mean","count":"10","round":"2","mult":"single","reduce":false,"x":658.701244354248,"y":243.92142295837402,"wires":[["15d5dba10a15f828","af7b42134d95a389"]]},{"id":"d90a057d90414b1d","type":"smooth","z":"a34699b03789f7a6","name":"","property":"payload.psi","action":"mean","count":"10","round":"2","mult":"single","reduce":false,"x":657.611629486084,"y":277.9664897918701,"wires":[["56f77712fb804a5d","21ad697deffbb97d"]]},{"id":"382ed0af7e4f3afb","type":"smooth","z":"a34699b03789f7a6","name":"","property":"payload.psi","action":"mean","count":"10","round":"2","mult":"single","reduce":false,"x":658.7011184692383,"y":312.19068717956543,"wires":[["4c2178a1e77099e8","2a72d10832148992"]]},{"id":"db73da70aa858f22","type":"smooth","z":"a34699b03789f7a6","name":"","property":"payload.psi","action":"mean","count":"10","round":"2","mult":"single","reduce":false,"x":657.7908592224121,"y":349.1462993621826,"wires":[["412cef82df117dcc","5f0d481a6c5282fb"]]},{"id":"15d5dba10a15f828","type":"debug","z":"a34699b03789f7a6","name":"West","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":797.6056480407715,"y":243.0110263824463,"wires":[]},{"id":"56f77712fb804a5d","type":"debug","z":"a34699b03789f7a6","name":"Center","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":795.4337730407715,"y":277.9665355682373,"wires":[]},{"id":"4c2178a1e77099e8","type":"debug","z":"a34699b03789f7a6","name":"East","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":794.5382652282715,"y":314.19074058532715,"wires":[]},{"id":"412cef82df117dcc","type":"debug","z":"a34699b03789f7a6","name":"extra","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":796.4338340759277,"y":349.3254222869873,"wires":[]},{"id":"04778b58f2249d9f","type":"debug","z":"a34699b03789f7a6","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":383,"y":175.66666412353516,"wires":[]},{"id":"f9e48ea47e418f0c","type":"debug","z":"a34699b03789f7a6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":515.5732460021973,"y":501.75,"wires":[]},{"id":"ca2e414bcd46d253","type":"link out","z":"a34699b03789f7a6","name":"Boil Volume","mode":"link","links":["d3730ac5b85a4c2d"],"x":675.1568117141724,"y":621.0257225036621,"wires":[]},{"id":"0d0e7be9c565ae63","type":"link out","z":"a34699b03789f7a6","name":"HLT volume","mode":"link","links":["54edad0afe454bd9"],"x":632.5278224945068,"y":732.0763692855835,"wires":[]},{"id":"53c1ac9d1ba3e971","type":"debug","z":"a34699b03789f7a6","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":306.52392578125,"y":691.1701049804688,"wires":[]},{"id":"644f582199539a37","type":"function","z":"a34699b03789f7a6","name":"Boil Kettle Volume","func":"let msg0 = {};\nlet msg1 = {};\nlet msg2 = {};\nlet msg3 = {};\nlet msg4 = {};\nlet msg5 = {};\nlet msg6 = {};\nfunction myfunction(sensorValue) {\n    let volts = sensorValue * 0.1875 / 1000\n    let psi = (volts - 0.5) * 5 / 4\n    let psix = (volts - 0.5) * 10 / 4\n    return {'sensorValue': sensorValue, 'psi': psi >= 0 ? psi : 0,'psix': psix >= 0 ? psix : 0 ,'volts': volts,};\n}\n\nmsg0.payload = myfunction(msg.payload.A0);\nmsg1.payload = myfunction(msg.payload.A1);\nmsg2.payload = myfunction(msg.payload.A2);\nmsg3.payload = myfunction(msg.payload.A3);\n\nlet upper = msg2.payload.psi;\nlet lower = msg1.payload.psi;\nlet hltsensor = msg0.payload.psix;\nlet sensorDist = 10.758825; //(lower * 27.72) - (upper * 27.72);// this only works with water at specific gravity of 1.000 change formula to number you collect on first run\nlet specgrav = 1; //((lower * 27.72) - (upper * 27.72)) / sensorDist;\nlet boilwc = (lower * 27.72) / specgrav;\nlet hltwc = (hltsensor * 27.72);\nlet cubicinchh = hltwc * 1017;\nlet cubicinchb = boilwc * 1017;\nlet boilVolume = cubicinchb * 0.004329;\nlet hltVolume = cubicinchh * 0.004329;\n\nmsg4.payload = {'boilVolume': boilVolume, 'gravity': specgrav};\nmsg5.payload = {'hltVolume': hltVolume};\nmsg6.payload = {'sensordist': sensorDist};\nreturn [msg0, msg1, msg2, msg3, msg4, msg5, msg6];","outputs":7,"noerr":0,"initialize":"","finalize":"","libs":[],"x":316.0570297241211,"y":567.4386835098267,"wires":[["f9e48ea47e418f0c"],["30afa85b4807b163"],["7ded4a541b3a62e5"],["e1676c147498e1ec"],["ca2e414bcd46d253","4fe0e784f5c23308"],["0d0e7be9c565ae63","24e1892952a75a5d"],["53c1ac9d1ba3e971"]]},{"id":"4fe0e784f5c23308","type":"debug","z":"a34699b03789f7a6","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":779.1171722412109,"y":592.0719566345215,"wires":[]},{"id":"24e1892952a75a5d","type":"debug","z":"a34699b03789f7a6","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":680.1210784912109,"y":667.0719747543335,"wires":[]},{"id":"f65ecd4b82bb1169","type":"switch","z":"a34699b03789f7a6","name":"If =442FBOIL","property":"payload","propertyType":"msg","rules":[{"t":"hask","v":"A0","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":342.00000762939453,"y":434.2106237411499,"wires":[["644f582199539a37","e175eeb4d302e8eb"],[]]},{"id":"0e89b950f9d6c21f","type":"split","z":"a34699b03789f7a6","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":183.00000381469727,"y":438.21063137054443,"wires":[["f65ecd4b82bb1169"]]},{"id":"e1676c147498e1ec","type":"debug","z":"a34699b03789f7a6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":606.1093597412109,"y":567.0602560043335,"wires":[]},{"id":"e175eeb4d302e8eb","type":"debug","z":"a34699b03789f7a6","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":464.1210746765137,"y":375.0602569580078,"wires":[]},{"id":"bf1a60ead1951a32","type":"mqtt in","z":"a34699b03789f7a6","name":"","topic":"Railtemp1/SENSOR","qos":"2","datatype":"json","broker":"31a99116.50a74e","nl":false,"rap":true,"rh":0,"inputs":0,"x":155,"y":368.21063137054443,"wires":[["0e89b950f9d6c21f"]]},{"id":"30afa85b4807b163","type":"debug","z":"a34699b03789f7a6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":793.890625,"y":485.59961875,"wires":[]},{"id":"7ded4a541b3a62e5","type":"debug","z":"a34699b03789f7a6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":807.875,"y":528.60743125,"wires":[]},{"id":"31a99116.50a74e","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]

I also plan on having each vessel have its own esp8266 right now the brewhouse is connected to one esp, and the fermenters are connected to another.


looks messy but i soldered a 10 pin slot to board with terminal blocks so i can swap ads1115 if one goes bad.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.