Jump to content


Photo

How to make an automatic dew controller - Arduino

  • Please log in to reply
246 replies to this topic

#26 Pauls72

Pauls72

    Viking 1

  • *****
  • Posts: 621
  • Joined: 28 Oct 2007
  • Loc: LaPorte, IN

Posted 09 September 2012 - 04:47 PM

A 10 or 15 turn trim pot would work much better, but at night in the dark who would want to be cranking and cranking on a pot. I am slim on room inside the case to put a larger size pot.

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.

#27 Pauls72

Pauls72

    Viking 1

  • *****
  • Posts: 621
  • Joined: 28 Oct 2007
  • Loc: LaPorte, IN

Posted 10 September 2012 - 09:12 PM

Well I found out today the pdf's I previously created and posted have a number of truncated lines. So here is my current version in PC text format and an Arduino .ino source file.

PC-Text: http://michiana-astr...l3_20120909.txt

Source: http://michiana-astr...l3_20120909.zip

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.

Posted Image

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.

Posted Image

Posted Image


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

#28 Pauls72

Pauls72

    Viking 1

  • *****
  • Posts: 621
  • Joined: 28 Oct 2007
  • Loc: LaPorte, IN

Posted 10 September 2012 - 09:38 PM

I you click on this picture you can watch the updated video.

Posted Image

#29 mitaccio

mitaccio

    Viking 1

  • *****
  • Posts: 513
  • Joined: 17 Mar 2009
  • Loc: Oahu, Hawaii

Posted 10 September 2012 - 09:44 PM

I really like the LCD shield, but see one issue I hope they resolve: there isn't a PWM control for the backlight. The display may be too bright for astronomical use. But the 2 pin use is a great idea, couple that with the 5 buttons and it has great potential.

#30 Pauls72

Pauls72

    Viking 1

  • *****
  • Posts: 621
  • Joined: 28 Oct 2007
  • Loc: LaPorte, IN

Posted 11 September 2012 - 02:38 PM

I noticed the temperature results of my DHT-11 sensor always drifted up over time. I still have it external to the case and I have some space under it for air flow. As a test, I left it running overnight on the counter and had all 4 Dallas one wire sensors right by the DHT-11. This morning when I got up it showed it was 8°F over the the 4 Dallas sensors. I turned it off for an hour or so and then all 5 sensors where the same again. This was with it running about 7 hours.

#31 Pauls72

Pauls72

    Viking 1

  • *****
  • Posts: 621
  • Joined: 28 Oct 2007
  • Loc: LaPorte, IN

Posted 12 September 2012 - 08:42 PM

Sept 11, 2012 - Version 3.5
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.

PC-Text: http://michiana-astr...l3_20120911.txt

Source: http://michiana-astr...l3_20120911.zip

#32 Pauls72

Pauls72

    Viking 1

  • *****
  • Posts: 621
  • Joined: 28 Oct 2007
  • Loc: LaPorte, IN

Posted 14 September 2012 - 11:18 AM

Sept 13, 2012 - Version 3.6
Offset sensor values stored in EEPROM by 100 to allow for negative numbers. Value range is now from -99° to +155° for all sensors.

PC-Text: http://michiana-astr...l3_20120913.txt

Source: http://michiana-astr...l3_20120913.zip

#33 Pauls72

Pauls72

    Viking 1

  • *****
  • Posts: 621
  • Joined: 28 Oct 2007
  • Loc: LaPorte, IN

Posted 04 October 2012 - 11:26 AM

I have added a RTC (Real Time Clock) and EEPROM (external non-volatile memory) module. What I purchased was a Tiny I2C RTC DS1307 and 24C32 module @ $6.00. There are sever different versions of this board being sold with different combinations of the following three components:
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.
http://dx.com/p/tiny...o-146677?item=1

Posted Image Posted Image

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.

Posted Image

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'
Memory location,Month/Day,Hours:Minutes,S1,S1,S3,S4,Temp,Humidty,DewPoint,Volts
Address=0,0/0,0:0,0,0,0,0,0,0,0,0.00V
Address=12,10/3,21:36,77,77,77,76,78,42,55,13.10V
Address=24,10/3,21:50,77,77,77,76,77,42,53,13.10V
Address=36,10/3,22:5,77,76,77,76,78,42,55,13.10V
Address=48,10/3,22:20,77,76,77,76,78,42,55,13.10V
Address=60,10/3,22:35,77,76,77,76,78,41,54,13.20V
Address=72,10/3,22:50,77,76,77,76,78,41,55,13.20V
Address=84,10/3,23:5,77,76,77,76,78,41,54,12.90V
Address=96,10/3,23:20,77,76,77,76,78,41,54,12.80V
Address=108,10/3,23:36,77,76,77,76,78,41,54,12.80V
Address=120,0/0,0:0,0,0,0,0,0,0,0,0.00V
Address=132,10/3,23:41,77,76,77,76,78,41,54,13.00V
Address=144,0/0,0:0,0,0,0,0,0,0,0,0.00V
Address=156,10/3,23:52,77,76,77,76,78,41,54,13.20V
Address=168,10/4,0:6,77,76,77,76,78,41,54,13.20V
Address=180,10/4,0:21,77,76,77,76,78,41,54,13.20V
Address=192,10/4,0:36,77,77,77,76,78,41,54,13.20V
Address=204,10/4,0:51,77,77,78,77,78,41,54,13.20V
Address=216,10/4,1:7,77,76,77,76,77,40,52,13.20V
Address=228,10/4,1:22,77,77,77,77,77,41,52,13.20V
Address=240,10/4,1:36,76,76,77,76,77,40,52,13.30V
Address=252,10/4,1:51,77,76,77,76,77,41,52,13.20V
Address=264,10/4,2:6,76,76,77,76,77,40,52,13.30V
Address=276,10/4,2:21,76,76,77,76,77,41,52,13.30V
Address=288,10/4,2:36,76,76,77,76,77,40,52,13.30V
Address=300,10/4,2:52,76,76,76,75,77,40,52,13.30V
Address=312,10/4,3:7,76,75,76,75,75,41,51,13.30V
Address=324,10/4,3:21,76,75,76,75,75,41,51,13.30V
Address=336,10/4,3:36,75,75,76,75,75,41,51,13.40V
Address=348,10/4,3:51,75,75,76,75,75,41,51,13.40V
Address=360,10/4,4:6,75,75,75,74,75,41,51,13.40V
Address=372,10/4,4:21,75,75,75,74,75,41,51,13.40V
Address=384,10/4,4:37,75,75,76,75,75,41,51,13.40V
Address=396,10/4,4:52,76,75,76,75,75,41,51,13.50V
Address=408,10/4,5:6,75,75,76,75,75,41,51,13.40V
Address=420,10/4,5:21,76,76,76,75,75,41,51,13.50V
Address=432,10/4,5:36,75,75,76,75,75,41,51,13.50V
Address=444,10/4,5:51,76,75,76,75,75,41,51,13.50V
Address=456,10/4,6:6,75,75,76,75,75,41,51,13.60V
Address=468,10/4,6:22,76,75,76,75,75,41,51,13.50V
Address=480,10/4,6:36,76,75,76,75,75,41,51,13.60V
Address=492,10/4,6:51,76,75,77,75,77,41,52,13.50V
Address=504,0/0,0:0,0,0,0,0,0,0,0,0.00V
Address=516,10/4,6:57,77,76,77,76,77,43,53,13.70V
Address=528,0/0,0:0,0,0,0,0,0,0,0,0.00V
Address=540,0/0,0:0,0,0,0,0,0,0,0,0.00V
Address=552,0/0,0:0,0,0,0,0,0,0,0,0.00V
Address=564,0/0,0:0,0,0,0,0,0,0,0,0.00V
Address=576,0/0,0:0,0,0,0,0,0,0,0,0.00V
Address=588,0/0,0:0,0,0,0,0,0,0,0,0.00V
Address=600,0/0,0:0,0,0,0,0,0,0,0,0.00V
Address=612,0/0,0:0,0,0,0,0,0,0,0,0.00V
Address=624,0/0,0:0,0,0,0,0,0,0,0,0.00V
Address=636,0/0,0:0,0,0,0,0,0,0,0,0.00V
Address=648,0/0,0:0,0,0,0,0,0,0,0,0.00V


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.


PC-Text: http://michiana-astr...l3_20121003.txt

Source: http://michiana-astr...rojects/DewCtrl

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.
http://dx.com/p/ir-r...5-135520?item=2

#34 UmaDog

UmaDog

    Vanguard

  • *****
  • Posts: 2052
  • Joined: 15 Sep 2010
  • Loc: Basel, Switzerland

Posted 09 October 2012 - 06:33 PM

This looks awesome. I've recently started working on Arduinos for work so I'm tempted to give this project a go next.

#35 Pauls72

Pauls72

    Viking 1

  • *****
  • Posts: 621
  • Joined: 28 Oct 2007
  • Loc: LaPorte, IN

Posted 09 October 2012 - 11:10 PM

If I had it to do over, there are 2 things I would change:

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.

DHT11
Good for 20-80% humidity readings with 5% accuracy
Good for 0-50°C temperature readings ±2°C accuracy

DHT22
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
http://www.ebay.com/...984.m1423.l2649

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.

#36 ThadeusB

ThadeusB

    Explorer 1

  • -----
  • Posts: 71
  • Joined: 14 Nov 2012
  • Loc: Somerset, UK

Posted 21 November 2012 - 06:49 PM

Help please someone!

My sketch has the line:

dht22 DHT22;

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?

Thanks

#37 Pauls72

Pauls72

    Viking 1

  • *****
  • Posts: 621
  • Joined: 28 Oct 2007
  • Loc: LaPorte, IN

Posted 21 November 2012 - 07:06 PM

I assume your using the DHT11 library or do you have one for the DHT22?
#include <dht11.h>

If you are using the DHT11 library replace the line with this line.
dht11 DHT11;
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.


#38 ThadeusB

ThadeusB

    Explorer 1

  • -----
  • Posts: 71
  • Joined: 14 Nov 2012
  • Loc: Somerset, UK

Posted 23 November 2012 - 02:45 PM

Thanks for replying Paul. I have the adafruit library for both DHT11 and 22.

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.

Phil

#39 ThadeusB

ThadeusB

    Explorer 1

  • -----
  • Posts: 71
  • Joined: 14 Nov 2012
  • Loc: Somerset, UK

Posted 23 November 2012 - 03:10 PM

Hi Paul,

Well, I did as you suggested, but no luck. It stall at 'dht DHT'. With many other compile errors. So

Attached Files



#40 ThadeusB

ThadeusB

    Explorer 1

  • -----
  • Posts: 71
  • Joined: 14 Nov 2012
  • Loc: Somerset, UK

Posted 23 November 2012 - 03:12 PM

Paul, something went wrong with the last message. So I'll try attaching the zip file again.

Very many thanks for offering to help. I'm out of my depth with this!

Phil

#41 ThadeusB

ThadeusB

    Explorer 1

  • -----
  • Posts: 71
  • Joined: 14 Nov 2012
  • Loc: Somerset, UK

Posted 23 November 2012 - 03:13 PM

I'll try again!!!

Attached Files



#42 ThadeusB

ThadeusB

    Explorer 1

  • -----
  • Posts: 71
  • Joined: 14 Nov 2012
  • Loc: Somerset, UK

Posted 23 November 2012 - 03:14 PM

That one did it.

#43 ThadeusB

ThadeusB

    Explorer 1

  • -----
  • Posts: 71
  • Joined: 14 Nov 2012
  • Loc: Somerset, UK

Posted 23 November 2012 - 03:53 PM

Hi Paul,

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.

Regards

Phil

Attached Files



#44 Pauls72

Pauls72

    Viking 1

  • *****
  • Posts: 621
  • Joined: 28 Oct 2007
  • Loc: LaPorte, IN

Posted 23 November 2012 - 07:06 PM

Phil,

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.

Good Luck,
Paul

Attached Files



#45 ThadeusB

ThadeusB

    Explorer 1

  • -----
  • Posts: 71
  • Joined: 14 Nov 2012
  • Loc: Somerset, UK

Posted 24 November 2012 - 04:36 AM

Hi Paul,

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.

Regards

Phil

#46 ThadeusB

ThadeusB

    Explorer 1

  • -----
  • Posts: 71
  • Joined: 14 Nov 2012
  • Loc: Somerset, UK

Posted 24 November 2012 - 06:10 AM

Hi Paul,

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.

Regards

Phil

Attached Files



#47 ThadeusB

ThadeusB

    Explorer 1

  • -----
  • Posts: 71
  • Joined: 14 Nov 2012
  • Loc: Somerset, UK

Posted 24 November 2012 - 08:47 AM

Hi Paul,

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.

Regards

Phil

#48 Pauls72

Pauls72

    Viking 1

  • *****
  • Posts: 621
  • Joined: 28 Oct 2007
  • Loc: LaPorte, IN

Posted 24 November 2012 - 10:02 AM

Phil,

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:
http://michiana-astr...l/libraries.zip

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.

Paul

Posted Image

Posted Image

Posted Image

#49 Pauls72

Pauls72

    Viking 1

  • *****
  • Posts: 621
  • Joined: 28 Oct 2007
  • Loc: LaPorte, IN

Posted 24 November 2012 - 10:24 AM

The maximum compiled sketch size is limited by the amount of flash memory on your Arduino board. It happens that in their naming convention on a lot of the boards, the first part of the number is the amount of memory.

168 = 16k
328 = 32k
1280 = 128k
2560 = 256k

Posted Image

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 Image

#50 Pauls72

Pauls72

    Viking 1

  • *****
  • Posts: 621
  • Joined: 28 Oct 2007
  • Loc: LaPorte, IN

Posted 24 November 2012 - 10:50 AM

Because a lot of the libraries are open source and put out in the public domain for free anyone can go and change them and they do. So you can find a lot of different versions of a library for the same device using the same name. I struggled learning this the hard way. I am by know means an Arduino or C/C++ expert, but I have learned a fair amount in building this project.

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.






Cloudy Nights LLC
Cloudy Nights Sponsor: Astronomics