Popular Post Fairlight Posted April 15, 2016 Popular Post Posted April 15, 2016 Hello people! Below you will find information about a small project I completed. The whole think begun when I thought that it would be nice if I had temperature and humidity monitoring of my coolidor online and be able to access them from anywhere. When I started I only knew some basic things about all this but upon completion I ended up knowing basic python programming and some linux as well. So the whole idea here is that a small and inexpensive computer (raspberry pi) is hooked to the coolidor and performs two basic functions: Collecting and uploading humidity and temperature in real time and controlling the coolidor’s fans. 1) Humidity and temperature logging and uploading. To collect the data a humidity/temperature sensor is used called AM2303. Basically it is a DHT22 sensor prewired and featuring a plastic casing. If you’re interested you can read the manufacturer’s info here: http://www.aosong.com/asp_bin/Products/en/AM2303.pdf Here you can see it temporarily attached to the rpi To be completely honest with you it’s not the perfect sensor. However, I truly believe that it’s far better than any commercial cigar hygrometer I’ve used in the past. You can see some serious testing of the sensor here (along with some useful information about sensors in general): http://www.kandrsmith.org/RJS/Misc/Hygrometers/DHT22/calib_dht22_v1.html There are currently two ready python libraries for this sensor (for Arduino as well) so it’s quite easy to get recordings from it. After I managed to read the sensor I did a 3 point calibration using bovedas and a tupperwear. This showed that an offset of 1.4% RH must be applied to the sensor data in order to get accurate humidity measurements. Fixing that takes about 1 second in software in contrast to trying to calibrate horrible digital hygrometers used for cigars. Of course if someone is concerned about accuracy calibration needs to be repeated in a year due to sensor drift. Me personally, I am much more concerned about fluctuations and stability rather than absolute accuracy. When all these were done I wrote a small python script that collects sensor data (2 measurements/min) and uploads then in a free to use API called plotly. The same scripts also plots the data. You can see the data yourself in real time here (that's obviously the whole point here): https://plot.ly/89/~Fairlight/ The only problem now is that data collecting and uploading are done with the same script which means that if for a reason upload fails then logging stops as well. This can be solved by using offline logging and storing the data locally THEN uploading. To be honest I don’t know if I will bother to implement something like this. 2) Fan control When I initially installed fans in my coolidor, years ago, I didn’t have any guidance on how often they should be switched on in relation to the amount of air they move. Thanks to pigfish (god thank you!) I finally found out that if for 22cfm there should be a 25% duty cycle. I bought a 7.5V adapter for the fans which produces an airflow of around 20cfm. But then I wanted to get rid of the horrible digital timers. Plus there was no way I could program 1min on 4 off in these. They are also very prone to failure, I ve already changed 3 of them. Since the rpi was going to get hooked anyway I had the idea of making an electronic switch for the fans based on a 2n2222 transistor. This transistors basically switches an external 7.5V supply to the fans on and off using an input for rpi’s GPIO.The circuit is very similar to this. The main differences is that instead of a motor (M1) here we have the coolidor’s fans and there is no R1 resistance. I made a small circuit using perfboard and glued it with hot glue above one of the fans inside the coolidor. A very simple python script switches the fans on and off. Because the 2 scipts (data collecting and uploading and fan control) must continuously run (specially the fan one) a program called upstart monitors the state of the script and if they fail it reboots them automatically. I then attached the rpi to the coolidor using Velcro (its completely removable). I routed the cables through the plastic drain plug. The red/black cable you see here is the external 7.5V supply for the fans. The black bundle contains 5 cables, 3 for the sensor and 2 for the switching circuit board. I also placed two leds directly to the rpi. A blue one that remains lit when the fans are on and a red one that blinks for a second every time a measurement is uploaded. Obviously there is a also a cheap wi fi usb adapter hooked to the thing. Cost: Nothing really. The cost of the sensor was 4 usd and as of the cost of the circuit board I don’t really know. It must be less than 1 usd. I already had a rpi doing nothing so if you don’t have one that will cost you around 35usd. However it can be done with much cheaper hardware. Difficulty: For me it was challenging but only because I was a complete beginner in anything. It took me about two months, working it a bit on weekends. However if you already know BASIC python programming and linux it can be done in a matter of days if not hours. I can also give you my horrible code if you wish. That’s it. Hope you like it. Next project is probably a freezador. The weather here in Greece is brutal on cigars. 10
planetary Posted April 15, 2016 Posted April 15, 2016 Very interesting! It might be good to put the sensor into the ambient environment (where you have a control temp + hygrometer, which you trust) to see how long it takes to notice, and stabilize on the new readings -- and also how far off they are from the control. The stable temperature is impressive! You must have it situated in a good spot in the house. 2
Fairlight Posted April 16, 2016 Author Posted April 16, 2016 Oh I made that and a whole bunch of other interesting experiments. The most interesting among these, I guess they were the ones in which I was measuring the time the coolidor takes to recover from an opening. I then varied the 'open time' to see how it impacts the time it needs to recover. With a 'normal' opening this time is around 40 mins. I am using 3 hygrometers (with temperature) along the am2303. Trust me the am2303 is way better. It is fast and sensitive especially when compared to comercial cigar hygrometers. Yes the temp is stable now but its 23c (73,4F). I also tested it when central heating was on and it wasn't that stable. You could actually see the daily fluctuation caused by the central heating on the data, it was pretty consistent. A cool thing to see, not so cool for the cigars though. 1
PigFish Posted April 16, 2016 Posted April 16, 2016 Congratulations mate... good job! I built a similar unit once, just to test ideas in a passive insulated cooler. I have since tossed the cooler, but I did save some pictures of the device. This pic is from 2012. The one thing that hung me up on this project was my desire to actively humidify it. I live in a largely dry environment. It cause me to create what I called the desiccant humidifier. This is a humidification appliance with nominally wet desiccant products. It is a powered appliance connected to the controller and set to humidify when the rH declined below the set point. Of course it could not hold a lot of water, or the equilibrium (normal evaporation) process would take the humidor up in rH incidentally over time. But, once the desiccant was pretty much equalized with say a 60rH environment, you could add 10ml or so of water to it and that excess would be used to keep balance in the humidor when the appliance was under power. Otherwise since the desiccant was largely isolated it would not typically run up the rH as the water would tend to remained locked up in the appliance. I chose an approach where everything was built into the lid and just moved out of the way when opened. Good job mate! Cheers! -Piggy
planetary Posted April 16, 2016 Posted April 16, 2016 40 minutes -- interesting! I wonder what it would take to get the Rpi to SMS you alerts when you have an excursion beyond acceptable parameters. Buddy of mine who's got an Arduino setup monitoring his homebrew made that work. Saved his bacon one time, when he was on vacation, and a power outage wreaked havoc with the internal house temperature, and he was able to have a neighbor come over and reset his AC. 1
PigFish Posted April 16, 2016 Posted April 16, 2016 In used to do a lot of comparisons between active humidor products to passive ones. Most of this stuff is obsolete today, I don't even recall what I was testing and why, but it does help to demonstrate the difference. Here is one from the file cabinet! Cheers.
Fairlight Posted April 16, 2016 Author Posted April 16, 2016 40 minutes -- interesting! I wonder what it would take to get the Rpi to SMS you alerts when you have an excursion beyond acceptable parameters. Buddy of mine who's got an Arduino setup monitoring his homebrew made that work. Saved his bacon one time, when he was on vacation, and a power outage wreaked havoc with the internal house temperature, and he was able to have a neighbor come over and reset his AC. I am sure a SMS notification is feasible, a simple google search revealed at least 3 different ways to do that. The Rpi is much more powerful than the arduino. I guess its not really necessary because you can access the data from a mobile anyway but I may do it just for fun when I have time. You can also make an android widget if you 're capable. I have an old graph that it might interest you. This is during calibration using a tuperware and bovedas. What happens here is that the system is stabilized at 75, I open the tupperwear, replace the bovedas with 69 and close it. You can see how much time it takes to stabilize at the new level. Because at the time I hadn't put timestamps yet what you see on the x-axis is measurements. Each measurement is app. 30secs. Therefore it takes about 17,4mins (58 measurements). https://plot.ly/73/~Fairlight/ Not really relevant to my coolidor since the area and the humidification are different but i think it shows what a 4usd sensor is capable of. Bear in mind that could can actually take a measurement out of it every 2 seconds. Really you can make a lot of interesting things with these controllers/computers. I haven't seen it done anywhere but for example you could drive an active humidifier using sophisticated input from multiple sensors from different places. You could make a complicated feedback algorithm this way that may be a lot better than a simple 1 point 'set' controller. Congratulations mate... good job! Well it means a lot coming from you, since I learned a lot from your posts. To find relevant information in these things is extremely hard and when you finally do it is probably wrong. You're probably the only one I know who has the skills, will and patience to make things work really as supposed to. This is very rare. I really hope you share your input to my next project when its done if you want to of course.
Anthonyjoseph89 Posted April 16, 2016 Posted April 16, 2016 I have a friend that is a retired programmer. Now you got me thinking about all kinds of ideas. I've been looking at the raspberry pi recently too. Good stuff. Sent from my SM-G928V using Tapatalk
Lotusguy Posted April 16, 2016 Posted April 16, 2016 Just get a decent sensor - get the Bosch Sensortec BME280 and make sure you got a proper AMBIENT temperature (I.e keep the sensor away from any and all heat sources).
Fairlight Posted April 17, 2016 Author Posted April 17, 2016 get the Bosch Sensortec BME280 I just checked it. What makes you think that it's a better sensor than the AM2303? You can use very high-end sensors if you wish to. Problem is, if there is no available library for them you must be ready for reading binary data out of them and I don't know if I am there yet, There are no cold or heat sources in my coolidor, the sensor is placed in the middle of the thing.
morganti Posted April 19, 2016 Posted April 19, 2016 Very nice. I am working on something very similar for a humidor that I am building from scratch. I tried to use an Arduino in early stages but it was too underpowered for what I wanted it to do. As for the sensor, there are a couple other sensors that are a bit more accurate that I have worked with in the past, I can find them if you want. As for SMS, most cell providers have some sort of Email to TXT service. So in your code just set a condition like: if humidity falls below X then send email to: [email protected] (example). Just make sure that you don't get charged for it. This is what I'm doing for my project. I say that now, but have not started to work on the PI code yet, just the web services. 2
Fairlight Posted April 19, 2016 Author Posted April 19, 2016 Let us know how it progresses. Sounds like you're more experienced than me. I'd love to know the details.
morganti Posted April 20, 2016 Posted April 20, 2016 Let us know how it progresses. Sounds like you're more experienced than me. I'd love to know the details. For sure. Seeing this project kind of sparked a bit of a fire to get started. So far I was able to get the temp and humidity readings sent to my my web service for logging. Right now I am figuring out the best methods for error handling and alerts - should it come from the hardware (pi) or the server. As for experience, I have very little Python experience, but I have a decade of web, iOS, and database experience that helps to make sense of the python code. If you need any help, just ping me and I will do what I can to help. My grand scheme is to build a cabinet humidor that has active humidification that gets turned on automatically by the PI, as well as fans for air circulation - pretty much what you have figured out. I want to be able to control it all using a PiTFT touchscreen very similar to what Gerber does on their humidors. I need to rig up a door open sensor to prevent the system from sending alerts while I am rotating boxes. I almost forgot the LED control as well. My ideas grow by the day, so I need to focus on small parts, get it figured out and then move on.
Fairlight Posted April 20, 2016 Author Posted April 20, 2016 Go for it! Python is a very easy language. The door open sensor should be quite easy to implement as well. The humidity control should also be quite manageable especially if the humidor is not temperature-controlled. However you must be dead sure that it works 100% how it should because an error there can be detrimental to the cigars.
morganti Posted May 3, 2016 Posted May 3, 2016 It's been a while since I last checked in. Fairlight, how have the fans been working? Any issues with the setup? I am in the process of starting to rig up some fans to be controlled by the Pi. Any advice after a few weeks of running them? In the meantime I have been working on the dev side of things and have added a touchscreen to the Pi. It's pretty cool
Fairlight Posted May 3, 2016 Author Posted May 3, 2016 Hello. The whole thing works completely fine except the very occasional crash of the script that collects and uploads data (most of the times due to API errors). The script that controls the fans never failed, i know because I am logging it. If you want to perform critical control with these things (active humidifaction etc) it would be best to use an arduino for that job. Reason being that the arduino is a microconttroler that will never crash. You can still hook up the arduino to the rpi and have all the advanced functionality you may wish (screens, local/remote web server etc). If you haven't seen it already I urge you to check the brewpi system for two reasons. One is that it uses a similar setup (rpi+arduino) and second because it uses an interesting pid learning algorithm that I am sure it can applied to cigars both for temperature and humidity control.
morganti Posted May 5, 2016 Posted May 5, 2016 Hello. The whole thing works completely fine except the very occasional crash of the script that collects and uploads data (most of the times due to API errors). The script that controls the fans never failed, i know because I am logging it. If you want to perform critical control with these things (active humidifaction etc) it would be best to use an arduino for that job. Reason being that the arduino is a microconttroler that will never crash. You can still hook up the arduino to the rpi and have all the advanced functionality you may wish (screens, local/remote web server etc). If you haven't seen it already I urge you to check the brewpi system for two reasons. One is that it uses a similar setup (rpi+arduino) and second because it uses an interesting pid learning algorithm that I am sure it can applied to cigars both for temperature and humidity control. The brewpi is pretty cool. I was thinking about the arduino and pi working together but wasn't sure about the best way to make it all work. What you said makes a lot of sense. The pi is great for applications, but the Arduino would be great for a single process. I have a laundry list of parts that I need to get. The next stage is the hardware configuration and running wires.
Fairlight Posted May 6, 2016 Author Posted May 6, 2016 They communicate with a (simulated) serial port. You can find tons of info online as well as in the brewpi project. Best of luck and don't forget to post all the gritty details!
scottyfwil Posted May 16, 2016 Posted May 16, 2016 I would love to build this into my system of humidors. I am NOT a programmer, rather an infrastructure guy. Do you have any how-to documentation or code samples I could reference to get up and running? Great setup!
Fairlight Posted May 16, 2016 Author Posted May 16, 2016 I am not a programmer either, in fact I am complete beginner. I have several resources that might help and of course I can give you my own code. I'll send you a pm.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now