escort ordu kıbrıs escort escort izmit escort bodrum escort rize escort konya escort kırklareli escort van halkalı escort escort erzurum escort sivas escort samsun escort tokat altinrehbereskisehir.com konyachad.com sakaryaehliyet.com tiktaktrabzon.com escortlarkibris.net canakkalesondaj.com kayseriyelek.com buderuskonya.com DIY humidity sensor - UK Cigar Forums

Announcement

Collapse
No announcement yet.

DIY humidity sensor

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    OK I think I've sussed the connection stuff - its worse than the software! I'll need to do some soldering!!

    The test was a success! I had to hold the sensor against the pins with my hand to get a connection with the pins, but this is just a test. But I can get some readings from the sensor using some code. That's the key thing!!

    IMG_20180218_185907.jpg

    And with one hand - power back up and run the initial tests...

    This command reports the hardware address of the sensor if its found - 40 in this case. So the connection is good.
    Screenshot from 2018-02-18 18-56-40.png

    So now we can run some python commands to get some humidity and temp values - the values seem a bit out but ill try to figure out why...
    (This is what the Python3 shell looks like)
    Screenshot from 2018-02-18 18-57-46.jpg

    For those with the eagle eyes - I breathed at the sensor to see what it reads. The reading went up to 97% humidity and dropped back to the base level 23% after a few moments.

    And in order to get to this point had to do some more setup on the Pi Zero... so here goes again:

    1. Enable I2C and GPIO functions
    - Run the configuration utility https://www.raspberrypi.org/document...aspi-config.md
    - I enabled the I2C and remote GPIO (may not need the latter, not sure) both done from the Interfacing Options menu item.
    - Restart the PI Zero after doing this.

    2. Install some Python3 drivers and the GPIO drivers
    - WTF is Python?!? See https://wiki.python.org/moin/FrontPage
    - Run the following commands to do so:
    sudo apt-get install pigpio python-pigpio python3-pigpio python3-pip python-smbus i2c-tools
    pip3 install htu21df

    Now you can test to check the sensor is connected:
    sudo i2cdetect -y 1

    And get some readings:
    python3 -m htu21.htu21
    Last edited by ha_banos; 19-02-2018, 07:46 AM.
    .--
    I think I may finally have this CAD under control...

    Comment


    • #32
      The only thing I gleaned from all of that was from the screen shot where it said - type "help" ! I think I could handle that.

      Sent from my SM-G900F using Tapatalk

      Comment


      • #33
        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.

        Comment


        • #34
          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.
          .--
          I think I may finally have this CAD under control...

          Comment


          • #35
            I can


            Sent from my iPhone using Tapatalk

            Comment


            • #36
              Is this a live reading?!
              Only the impossible is worth the effort.

              JEANETTE WINTERSON,

              Comment


              • #37
                Originally posted by ha_banos View Post
                Who can see this then?

                https://freeboard.io/board/-ALhe7
                Ooh me me pick_me.jpeg
                'Cigars are a hobby, cigarettes an addiction'

                Comment


                • #38
                  Originally posted by thedame007 View Post
                  Is this a live reading?!
                  Yes - but the humidity reading calibration is out. So need to fix. Other hygrometers reading ~67%.
                  .--
                  I think I may finally have this CAD under control...

                  Comment


                  • #39
                    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.
                    Last edited by ha_banos; 18-03-2018, 01:48 PM. Reason: upd link
                    .--
                    I think I may finally have this CAD under control...

                    Comment


                    • #40
                      I’ll probably spend as much time watching your hygrometer readings as I watch mine
                      Only the impossible is worth the effort.

                      JEANETTE WINTERSON,

                      Comment


                      • #41
                        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
                        .--
                        I think I may finally have this CAD under control...

                        Comment


                        • #42
                          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





                          Last edited by ha_banos; 18-03-2018, 01:48 PM. Reason: upd link
                          .--
                          I think I may finally have this CAD under control...

                          Comment


                          • #43
                            It's warmer in your humidor than it is in my house
                            Only the impossible is worth the effort.

                            JEANETTE WINTERSON,

                            Comment


                            • #44
                              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!!!
                              .--
                              I think I may finally have this CAD under control...

                              Comment


                              • #45
                                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.

                                .--
                                I think I may finally have this CAD under control...

                                Comment

                                Working...
                                X