[emoji3]
I was clever and painted into a piece of cardboard and put that on the floor before taking the photo [emoji6][emoji38]
Announcement
Collapse
No announcement yet.
DIY humidity sensor
Collapse
X
-
The ribbon cable looks discreet, not sure the wife would be happy with the red arrow painted on the floorOriginally posted by ha_banos View PostMinor update. Got a flat long usb cable that fits and allows the door to lock shut. So no more running out of power!
I need a power surge protected tower multi plug adaptor which will have usb ports too. So that's the power sorted in future.

lol
Leave a comment:
-
Minor update. Got a flat long usb cable that fits and allows the door to lock shut. So no more running out of power!
I need a power surge protected tower multi plug adaptor which will have usb ports too. So that's the power sorted in future.
Leave a comment:
-
So getting data out of the sensor and putting on the Web...
I have chosen the quick and dirty method for now to get up and running. I used the online free dashboard (freeboard.io) to graph the numbers. The way this works is to run some Python code that is effectively a Web server. The Freeboard queries it for data and graphs it! Simples! Just need the Python code to also query the sensor for the data we want.
Diagram1.jpg
Now the code is a script that when you run it just listens for requests and sends back data like this - that Freeboard understands:
{"timestamp":"2018-Mar-03 18:01:28", "h":"60", "t":"18.3"}
You set up Freeboard to send a request for data every so often and give it the address of your system. I also had to route the request through my router (the red brick firewall) to the Pi - this is somewhat dangerous and only for the purposes of this demo!! I'd just do all this inside my network and use VPN to connect much more securely to see the data! But that's another story
Install some Python libraries onto the Pi courtesy of Mr Seal from GitHub https://github.com/MSeal/htu21df_sensor
There's a bit more config of the Pi that was needed to make sure every time it powers up it starts the Web server automagically. But I've bored you to tears now lol
And the code...
#!/usr/bin/env python3
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [
]
"""
import datetime
from http.server import SimpleHTTPRequestHandler, HTTPServer
from htu21 import HTU21
class S(SimpleHTTPRequestHandler):
def _set_headers(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
def do_GET(self):
htu = HTU21()
t=round(htu.read_temperature(),1)
h=round(htu.read_humidity())
resp="{\"timestamp\":\"%s\", \"h\":\"%s\", \"t\":\"%s\"}" % ('{:%Y-%b-%d %H:%M:%S}'.format(datetime.datetime.now()),h,t)
self._set_headers()
self.wfile.write(bytes(resp, "utf8"))
print (resp)
htu = None
def do_HEAD(self):
self._set_headers()
def run(server_class=HTTPServer, handler_class=S, port=80):
server_address = ('', port)
httpd = server_class(server_address, handler_class)
print ('Starting httpd...')
httpd.serve_forever()
if __name__ == "__main__":
from sys import argv
if len(argv) == 2:
run(port=int(argv[1]))
else:
run()
Next... maybe a BlueTooth Low Energy version!!!
Leave a comment:
-
The IOT Hygrometer has been running now for a week.
Its still not soldered - too cold and snowy to walk to the shed and dig around
so for now the sellotape method holds good. Got to hold the sensor board at an angle to get contact with the wires [emoji4]
I've also switched to a bigger USB battery pack so I can put the whole kaboodle inside the cabinette and it will power for a bout a week. With the bigger 20,000mha battery unit it looks like it will power for 8 or 9 days. Which is not bad.
It's been reading about 65% in the lower part of the humidor and just moved it up to the higher part to compare.
I'll cover the programming/software in the next post.
http://goo.gl/g1wKxp


Leave a comment:
-
I had to re-do my sellotaping as it has loosened overnight. No sensor, no readings...
So I've recharged the battery and also fixed a bug with the auto start up process to kick off the python server that feeds the dashboard. So its all up and running from around noon. I'll leave it to see how long it runs on the USB battery (5200mhA) I monitored the power draw which is 0.09A during normal operation so lets see how long it goes on battery.
NB: Sellotape is NO substitute for soldering! :P
Leave a comment:
-
I’ll probably spend as much time watching your hygrometer readings as I watch mine
Leave a comment:
-
Ok now we are live!
http://goo.gl/g1wKxp
I've shut it in the cabinet lets see how long it lives on that USB battery thing for now. The sensor is sellotaped in place until I solder it...
And I'm not sure how accurate the sensor is to humidity - will have to test that too.
Leave a comment:
-
-
Who can see this then?
http://goo.gl/g1wKxp
Its basic but its a start. I'll put the sensor in the humidor in a moment on a battery see how long it lasts. And the soldering is not yet done. Also there's no data storage set up yet - dashboard is live however.Last edited by ha_banos; 18-03-2018, 01:47 PM.
Leave a comment:
-
I've just spotted this. I hope you get it all up and running.
I tried the same sort of thing with my last display cabinet but gave up in the end because the Python
programming was just way over my head.
Leave a comment:
Powered by vBulletin® Version 5.7.5
Copyright © 2026 MH Sub I, LLC dba vBulletin. All rights reserved.
Copyright © 2026 MH Sub I, LLC dba vBulletin. All rights reserved.
All times are GMT. This page was generated at 01:59 AM.


Leave a comment: