This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Temperature pressure and humidity on LCD
#1
If I want to send the values of temperature, pressure and humidity also to a 16x2 LCD display, to monitor online the values, which python program should I change?

Thanks.
Reply
#2
One way to do it is to combine adafruit's examples for 16x2 https://learn.adafruit.com/drive-a-16x2-...ython-code or if you have an I2C enabled 16x2 board this example http://www.raspberrypi-spy.co.uk/2015/05...pberry-pi/ with something like this https://github.com/dalexgray/RaspberryPI_HTU21DF because if you want to get the values for temp/humidity from OP it can get a bit confusing since you need to look at how the data is handled in
Code:
~/.openplotter/i2c.py
(or
Code:
~/.openplotter/i2c_d.py
if you are using the 0.9.0 alpha) and add the code for ad hoc LCD 16x2 support in there.
In any case, in my opinion, the easiest way to do it (and also get a web UI dashboard with logging/graphs/gauges etc. which you can access online from anywhere) is via Node-red.

[Image: 2wcfx5j.jpg]

 if you are using the HTU21D temp/humidity sensor I have created a flow just for that (with support for 16x2 LCD - an I2C version board). Just import the Flow via Clipboard using string below:


Code:
[{"id":"f9b45da3.755a18","type":"johnny5","z":"77e62316.d8a60c","name":"Humidity","func":"\nvar hygrometer = new five.Hygrometer({\n   controller: \"HTU21D\"\n});\nhygrometer.on(\"data\", function() {\n//    line1 = { topic: 'Hum', payload: parseFloat(this.relativeHumidity).toFixed(2)};      \n    if (global.get(\"hum\")===\"true\") {\n        line1 = { topic: 'Hum', payload: Math.abs(parseFloat(this.relativeHumidity)).toFixed(2)};      \n        node.send(line1);\n    }\n    else \n    {\n        line2 = { topic: 'Hum', payload: 0};      \n        node.send(line2);\n    }\n//    node.send({topic: 'hum-test', payload: global.get(\"hum\")});\n   \n});\n\n\n\n\n","board":"4e98624c.17d1cc","noerr":0,"x":749.6006469726562,"y":166.30178833007812,"wires":[["7e82532a.cba1ec"]]},{"id":"a24f7dff.706be","type":"ui_gauge","z":"77e62316.d8a60c","name":"","group":"894de917.0b07b8","order":0,"width":0,"height":0,"gtype":"gage","title":"Humidity","label":"%","format":"{{value|number:1}}%","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"x":1153,"y":201.5,"wires":[]},{"id":"a94a3e23.f4c41","type":"ui_chart","z":"77e62316.d8a60c","name":"","group":"c3d6d8ae.8cb92","order":0,"width":0,"height":0,"label":"Temperature/Humidity chart","chartType":"line","legend":"true","xformat":"%H:%M:%S","interpolate":"cardinal","nodata":"No data","ymin":"0","ymax":"100","removeOlder":1,"removeOlderUnit":"86400","x":1142,"y":283.5,"wires":[[],[]]},{"id":"4fa078ce.f751a8","type":"debug","z":"77e62316.d8a60c","name":"","active":true,"console":"false","complete":"payload","x":1161,"y":124.5,"wires":[]},{"id":"dc91f51d.79faa8","type":"ui_switch","z":"77e62316.d8a60c","name":"","label":"Hydro/Temp Sensor On/Off","group":"2a0510f8.1c73b","order":0,"width":0,"height":0,"passthru":true,"topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":552,"y":274.5,"wires":[["78a75590.a85c7c"]]},{"id":"e94dfe3e.52afa","type":"inject","z":"77e62316.d8a60c","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":true,"x":349,"y":274.5,"wires":[["dc91f51d.79faa8"]]},{"id":"78a75590.a85c7c","type":"function","z":"77e62316.d8a60c","name":"enabled/disabled","func":"if (msg.payload === \"true\") {\n    global.set(\"hum\",\"true\");\n    msg.enabled = true;\n}\nelse {\n    global.set(\"hum\",\"false\");\n    msg.enabled = false;\n}\n\nmsg.payload = global.get(\"hum\");\n\nreturn msg;\n","outputs":1,"noerr":0,"x":729,"y":270.5,"wires":[["724b59b4.a667b"]]},{"id":"724b59b4.a667b","type":"debug","z":"77e62316.d8a60c","name":"","active":true,"console":"true","complete":"payload","x":942,"y":277.5,"wires":[]},{"id":"5b1388b7.3a5578","type":"inject","z":"77e62316.d8a60c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":409,"y":579,"wires":[["9e6c4005.d89a1"]]},{"id":"9e6c4005.d89a1","type":"function","z":"77e62316.d8a60c","name":"Sensor on/off","func":"if (global.get(\"hum\")===\"true\")\n    node.send({topic: 'hum-test', payload: global.get(\"hum\")});\nelse node.send({topic: 'hum-test', payload: \"huh?!\"});","outputs":1,"noerr":0,"x":600,"y":588,"wires":[["a6dec53a.62354"]]},{"id":"a6dec53a.62354","type":"debug","z":"77e62316.d8a60c","name":"","active":true,"console":"false","complete":"false","x":812,"y":602,"wires":[]},{"id":"7e82532a.cba1ec","type":"delay","z":"77e62316.d8a60c","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":922.5,"y":171.5,"wires":[["4fa078ce.f751a8","a24f7dff.706be","a94a3e23.f4c41","c08f788b.bfe72"]]},{"id":"7ba77c1a.e6cfe4","type":"johnny5","z":"77e62316.d8a60c","name":"temp","func":"\nvar thermometer = new five.Thermometer({\n   controller: \"HTU21D\"\n});\nthermometer.on(\"change\", function(){\n    line2 = { topic: 'Temp', payload: parseFloat(this.celsius).toFixed(2)};      \n    node.send(line2);\n});\n\n\n\n\n","board":"4e98624c.17d1cc","noerr":0,"x":710.591064453125,"y":357.6055908203125,"wires":[["f0ebaaec.2c70b"]]},{"id":"f0ebaaec.2c70b","type":"delay","z":"77e62316.d8a60c","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":913.5934753417969,"y":355.3217010498047,"wires":[["88250fb9.bbdb08","a94a3e23.f4c41","a3adf3c9.41d0b","caa3b708.a0553"]]},{"id":"88250fb9.bbdb08","type":"ui_gauge","z":"77e62316.d8a60c","name":"","group":"894de917.0b07b8","order":0,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"%","format":"{{value|number:1}}%","min":"-10","max":"50","colors":["#00b500","#e6e600","#ca3838"],"x":1167.1937255859375,"y":359.85028076171875,"wires":[]},{"id":"a3adf3c9.41d0b","type":"debug","z":"77e62316.d8a60c","name":"","active":true,"console":"false","complete":"false","x":1147.5,"y":427.5,"wires":[]},{"id":"c08f788b.bfe72","type":"johnny5","z":"77e62316.d8a60c","name":"LCD 1602","func":"var lcd = new five.LCD({\n    controller: \"PCF8574A\"\n});\n\nnode.on(\"input\", function(msg){\n    if (msg.payload!==\"\")\n        lcd.cursor(0, 0).print(\"Humidity:\"+msg.payload+\"%\");\n});","board":"4e98624c.17d1cc","noerr":0,"x":1148,"y":57,"wires":[[]]},{"id":"caa3b708.a0553","type":"johnny5","z":"77e62316.d8a60c","name":"LCD 1602","func":"var lcd = new five.LCD({\n    controller: \"PCF8574A\"\n});\n\nlcd.useChar(\"sbox\");\n\nnode.on(\"input\", function(msg){\n    if(msg.payload!==\"\")\n        lcd.cursor(1, 0).print(\"Temp:\"+msg.payload+\" :sbox:C\");\n});","board":"4e98624c.17d1cc","noerr":0,"x":1103,"y":496,"wires":[[]]},{"id":"4e98624c.17d1cc","type":"nodebot","z":"77e62316.d8a60c","name":"OSMC","username":"","password":"","boardType":"raspi-io","serialportName":"","connectionType":"local","mqttServer":"","socketServer":"","pubTopic":"","subTopic":"","tcpHost":"","tcpPort":"","sparkId":"","sparkToken":"","beanId":"","impId":"","meshbluServer":"https://meshblu.octoblu.com","uuid":"","token":"","sendUuid":""},{"id":"894de917.0b07b8","type":"ui_group","z":"77e62316.d8a60c","name":"Sensors","tab":"bef75269.861ca8","disp":true,"width":"6"},{"id":"c3d6d8ae.8cb92","type":"ui_group","z":"77e62316.d8a60c","name":"Charts","tab":"bef75269.861ca8","disp":true,"width":"6"},{"id":"2a0510f8.1c73b","type":"ui_group","z":"77e62316.d8a60c","name":"Controls","tab":"bef75269.861ca8","disp":true,"width":"6"},{"id":"bef75269.861ca8","type":"ui_tab","z":"77e62316.d8a60c","name":"Home","icon":"home"}]
Reply
#3
Thanks for your answer,  you have confirmed to me what I thought, in fact I tried to add LCD support code, on file i2c.py but still no works fine. I'll continue to work there!
I'm also trying node-red and will try your flow, thanks! I'll let you know!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)