How to make an automatic dew controller - Arduino
Posted 09 September 2012 - 04:47 PM
All the old electronics stores I used to buy stuff from are gone. So it is pretty much Radio Shack or mail order. I was up at Fry's outside Chicago last weekend getting some PC parts, they have ton's of empty peg's in the electronics dept.
Posted 10 September 2012 - 09:12 PM
Last 2 sets of changes:
Sept 9, 2012 - Version 3.4
Added in storing of high and low values of all sensors in EEPROM. Sorry this part is all in fahrenheit at this time.
Added clearing of EEPROM Dew Destroyer variables with two consecutive powerups or rests with no Dallas one-wire sensors connected.
Added in the ability to run without the duty cycle input pot.
Added in the ability to run without the Voltage detect divider resistors.
Fix a bug in the duty cycle logic.
Sept 8, 2012 - Version 3.3
Added in Voltage Detect and display to the screen.
If low voltage is detected > 11.6V the turn off outputs and stop processing almost forever (400000000 miliseconds or just over 111 hours).
Using a USB cable only to power the Aruindo portion of the project, may result in low reference voltage on the Arduindo board and low or wrong voltage readings.
Added operational time to the screen (time since power up or last reset).
Removed S= number of sensors found from the screen. Information was redundant.
I have added a simple voltage divider network of resistors for voltage detect input. Why did I use 2.2K Ohm resistors, because that's what I had in my parts junk box. I used the 25% of the heater voltage and an input to analog pin 1 (A1). The Arduino has a 5V reference that it uses built in.
A couple of pictures of the inside. There are 2 transistors on heat sinks under the rats nest of wires. The other 2 transistors are on the right side. The 4 large bullet diodes are along the left side.
I was looking and there is an Arduino shield that has an RGB LCD display (color) and 5 buttons. It only used 2 data lines to connect to the Arduino. I was thinking if you drove the display in red it should work for the display and with the 5 buttons you could select all kinds of options/menus. Since it only uses 2 data lines, it frees up some additional digital ones for data input/output. On the down side you would have 2 shields stacked and with the display stacking right on-top of the Arduino you would have to use a different case.
Color LCD Shield: http://www.adafruit.com/products/714
Posted 10 September 2012 - 09:38 PM
Posted 10 September 2012 - 09:44 PM
Posted 11 September 2012 - 02:38 PM
Posted 12 September 2012 - 08:42 PM
High and low temp are now stored in Fahrenheit or Celsius, which ever has been selected.
Correct a previous error I made storing some of the values.
Change sensor high/low storage values to a function.
Change low voltage detect to recover and continue in the event of a low voltage spike.
Make Voltage reading a function.
Start working on cleanup of the code.
Current limitation I found this evening, can not store temperatures below zero.
Posted 14 September 2012 - 11:18 AM
Offset sensor values stored in EEPROM by 100 to allow for negative numbers. Value range is now from -99° to +155° for all sensors.
Posted 04 October 2012 - 11:26 AM
DS1307 - RTC (Real Time Clock with about 50 bytes of it's own EEPROM)
24C32 - EEPROM 32K bit (4K x 8bits or 4K byte).
DS18B20 - Dallas One-Wire temperature sensor.
This module's sells for between $4 and $33 depending who you buy it from. I got mine from Deal Extreme, the only bad thing is the long wait of 10-14 days for shipping.
The devices are simple to hook up as they use 2 analog pins to communicate over a serial bus using the I2C Philips protocol and the wire.h library.
SDA - Analog pin 4 (A4)
SCL - Analog pin 5 (A5)
DS - Digital pin 3 (D3) connection is optional and would only be used if you have a DS18B20 temp sensor on the board. I see no need for this as there already is the DHT11 to measure temp at the unit. It would also require additional program changes to accommodate a fifth Dallas On-Wire sensor. This sensor would be in parallel with the other 4 Dallas On-Wire sensors for the OTA's, Eyepiece and Aux.
Each device on the I2C serial bus has a unique address and there can only be one of each of the devices per serial bus.
DS1307 = 0x68 (104)
24C32 = 0x50 (80)
The 24C32 EEPROM is a slow device when compared to the Arduino and as I found out the hard way it required some delays to prevent extraneous results.
Right now I give the Dew Controller 15 seconds to stabilize and then save all the values to EEPROM memory. After that I save off the values every 15 minutes (900000 milliseconds) for as long as the Arduino is powered up. Four times an hour just seemed like a reasonable number without being over kill. at 4K you can have 341 sets of data entries 341 x 12 bytes = 4092. I leave a set of blank entries every time the Dew Controller is powered up, this makes it easy to locate. Using the Arduino IDE USB Serial Terminal you can dump the EEPROM memory to the screen and then copy and paste it into a .csv file. This allows you to use the data with a spread sheet program like Excel and then graph the data. There has been several concessions that I made to save on memory, I do not save the year as part of the date and I do not save the seconds in the time. Additionally the voltage is rounded to a single decimal place. Here is an example of what the data looks like:
Dumping stored values
'Current Position = 528'
Oct. 3, 2012 = Version 3.8
Add support for DS1307 RTC module.
Add support for 24C32 EEPROM (32K bits - 4kx8).
Replace limited data storage of EEPROM with larger I2C_EEPROM.
Added date and time to the saved data.
Reworked the save data routines.
Blank entry to indicate power up.
Save readings after the system has about 30 seconds to stabilize and then every 15 minutes after that.
Sept 17, 2013 = Version 3.7
Save off high and low voltages to EEPROM.
Added Serial commands sent through USB ATE or Ardino Serial Terminal (D or d to dump EEPROM memory, Z or z to zero out EEPROM memory, P or p to pause for 30 seconds).
Data in dumped in a format so you can copy and paste it in a csv file to use with a spread sheet.
One thing I have found that seems to pretty common is that documentation, libraries and example programs for all the different modules and devices is skimpy at best, sometimes wrong and a lot of time won't compile and if it does, it doesn't work or only partially works. The datasheets for the devices (if you can find them) are your best reference materials.
I am planning to hook an IR remote to let you set all the dew controller options without a computer and without adding buttons to the controller. You would also be able to control the LCD contrast and duty cycle and no longer require the (2) 100K trim pots. But unfortunately I let the factory smoke out of the IR sensor module. I have a couple of new ones on order.
Posted 09 October 2012 - 06:33 PM
Posted 09 October 2012 - 11:10 PM
1) I would use a DHT22 sensor instead of a DHT11. It is more accurate and has a larger working range. It gets well below 0°C (32°F) here in the winter. They have the same pin out, signal and power requirements, but the DHT22 is double the cost of the DHT11.
Good for 20-80% humidity readings with 5% accuracy
Good for 0-50°C temperature readings ±2°C accuracy
Good for 0-100% humidity readings with 2-5% accuracy
Good for -40 to 80°C temperature readings ±0.5°C accuracy
2) I would one of these boards to reduce the number of wires to the display.
IIC/I2C/TWI/SPI Serial Interface Board Module For Arduino 1602 LCD Display 5V
The biggest obstacle I had was in my initial learning of the Arduino was the large number of different versions of the libraries and example code. The fact that some of these don't compile, do not work at all or work with limited or intermittent results made the learning curve that much steeper.
The fact that you are already working with Arduino's will give you a leg up on most people.
Posted 21 November 2012 - 06:49 PM
My sketch has the line:
The IDE compiler throws up an error:
error:'DHT' does not name a type
I don't know how to sort this one out, can anyone help please?
Posted 21 November 2012 - 07:06 PM
If you are using the DHT11 library replace the line with this line.
Also replace all your references to DHT22 with DHT11.
I believe both devices use the same protocol etc... so they can use the same library.
If you can't get it working, zip up your sketch and libraries and send them to me and I'll take a look at it.
Posted 23 November 2012 - 02:45 PM
Someone else told to replace the: 'dht DHT' line with this:
#define DHT22PIN 2
#define DHTTYPE DHT22
DHT dht(DHT22PIN, DHTTYPE);
This got me passed the problem I flagged up. But now there are are problems in the main program loop.
However, I will certainly try what you suggest and let you know the result.
Many thanks for offering to look at my sketch; I appreciate that.
Posted 23 November 2012 - 03:10 PM
Well, I did as you suggested, but no luck. It stall at 'dht DHT'. With many other compile errors. So
Posted 23 November 2012 - 03:12 PM
Very many thanks for offering to help. I'm out of my depth with this!
Posted 23 November 2012 - 03:53 PM
Thought I would also send the sketch with all DHT22 lines; which includes the DHT22.h and cpp files.
If you try compiling this one, you'll see that it is not far from working.
Posted 23 November 2012 - 07:06 PM
I commented out 2 lines, found one typo where you had a DHT1 instead of a DHT11.
Then I ended up using my libraries, at least one of your is different.
So attached is the updated sketch and my whole library folder.
It also was getting an error that the compiled code was too big 18.9K, the max allowed is 14K. Your sketch has the board type set to a Nano w/AT Mega168. I changed it to an Arduino UNO and it compiles. If you really do have an Nano w/AT Mega168 you will need to work at reducing the program size down some.
A couple of other things I would recommend:
Change these 4 values to 5, 10 degrees Fahrenheit difference is way more than you need.
int dewAdjust1 = 10; // Temperature difference between the Dallas one wire heater sensors and the controller DHT-11 sensor, in Fahrenheit. One for each output port so you can adjust the outputs individually.
int dewAdjust2 = 10; //
int dewAdjust3 = 10; //
int dewAdjust4 = 10; /
Since you in the UK set this value to 1 so your temperatures are displayed in Celsius.
boolean temperatureC = 0; // Set to one to display temperatures on Celsius. Note: All math and debugging is still done in Fahrenheit.
Posted 24 November 2012 - 04:36 AM
That was quick!! Set to a Nano was it, where is that in the code? My board is a Uno R3.
Ok, I'll give it a try now and let you know how I get on.
Very many thanks Paul.
Posted 24 November 2012 - 06:10 AM
Sorry to be a pain, but your complete library was not attached. I've got your revised .ino where I can see the corrected typo. I tried compiling it with the library I have, but no go. I've attached a screen shoot of the errors.
Regarding the file size: I presume then that at 18.9k it will not upload to the Uno. That I will need to reduce the size somehow, perhaps starting with most of the comments. What do you think?
Where in the code is the board set; I can't see it anywhere.
Posted 24 November 2012 - 08:47 AM
I'm trying to find out about sketch maximum size, but have not found it yet. However, I see that the Uno has 32K flash memory of which 0.5K is used by the bootloader. my complete libray is 95.8K; is this a problem?
Please forgive my ignorance of all this, I'm a complete novice! Perhaps I should buy the Arduino book.
Posted 24 November 2012 - 10:02 AM
The sketch source size and library source sizes makes mo difference. It's the compiled object that makes the difference.
My libraries where too big to attach, so I put them on our clubs web site:
I don't put my libraries in the same folder as the sketches. Here is how I have my folders structured. The Arduino compiler knows to look in the correct folders when you have them like this.
Posted 24 November 2012 - 10:24 AM
168 = 16k
328 = 32k
1280 = 128k
2560 = 256k
I have a Uno in my Dew Controller which is 32K and an Uno clone from China that I am using for testing/experimenting which is also 32K.
The compiler tells you your object program size when it compiles successfully.
Posted 24 November 2012 - 10:50 AM
The errors generated by the compiler don't always point straight at the problem. The errors especially get convoluted when you are referencing something incorrectly in a library.
It's no problem helping you. I understand your learning pain as I went through it a few months back. It's extremely frustrating when you have no place to go for any help. In my case it forced me to learn a lot more about the Arduino and C/C++ languages.
I'm sitting here fighting with trying to integrate an Infared remote control into mine. When I just add the library in my Arduino either crashes or goes crazy. I know it's a memory conflict, I just haven't been able to find it.