Jump to content

Stargazers Lounge Uses Cookies

Like most websites, SGL uses cookies in order to deliver a secure, personalised service, to provide social media functions and to analyse our traffic. Continued use of SGL indicates your acceptance of our cookie policy.

sgl_imaging_challenge_banner_android_vs_ios_winners.thumb.jpg.803608cf7eedd5cfb31eedc3e3f357e9.jpg

brown_rb

Arduino Dew Controller Feature Rich

Recommended Posts

DISCLAIMER

This project is released into the public domain as is where is, with no obligation or responsibility accepted on the part of the author, for any mishaps or failures caused by this product or use of this product. Users intending to use this project or code do so at their own risk and usage of product and code is deemed to be acceptance of those risks.

In other words, the author accepts no responsibility to damage caused to any equipment or goods or self by using the ideas, schematics and code associated with this project, or loss of income or all other losses that may be incurred.

RELEASE

The schematic, code and ideas are released into the public domain. Users are free to implement these but may NOT sell projects based on this project for commercial gain without express written permission granted from the author. 

Share this post


Link to post
Share on other sites

I will see about adding a source forge site for the pdfs and a lot of the other files, including the windows application, as these would easily break the 1MB limit here.

Share this post


Link to post
Share on other sites

For the LCD1602_I2C library files, you need to go here

http://www.dfrobot.com/image/data/DFR0154/LiquidCrystal_I2Cv1-1.rar

and here for more info

http://www.dfrobot.com/wiki/index.php?title=I2C/TWI_LCD1602_Module_(SKU:_DFR0063)

Note that the library supports the LCD1602 and the larger LCD2004. No hardware or software changes are required if you want to use the larger LCD2004 display.

Share this post


Link to post
Share on other sites

You can use a higher accuracy sensor such as the DHT21/22 or 33. No hardware or software changes are necessary, all ready supported. However the DHT11 is cheap and works well. In software we can add or subtract a bias offset value to get a more accurate reading from the DHT11.

This chart shows the various sensors and their characteristics. 

post-33939-0-68367300-1411015363.jpg

Share this post


Link to post
Share on other sites

The two toggle switches allow power override to 100% for each associated channel.

They are connected via a voltage divider network to A0 of the Arduino.

One can calculate the voltage and current with the various combinations and then get a range of values which can be tested in the switch detection code to determine which switch is On or OFF.

Working out Toggle Switch Diver Network
Must use 1M resistor from A0 to GND, this would pull it low
5v
1.2
sw1 3.36V = 687 reading range 650-720
1.2
sw2 1.68V = 344 reading range 310-380
1.2
gnd
Total R = 3.6, I = 1.4ma
1023 = 5V, 
SW1/SW2 both ON
5V
1.2
SW1/SW2 2.41V = 493 reading range 460-530
1.2
GND
Total R = 2.4K, I= 2.01ma
Predicted values and Actual values
SW1 687 681
SW2 344 338
SW1+SW2 493 509
So you can see the predicted value for SW1 was 687 and the actual value, read by a test program, was 681. The difference of course is the tolerance in the resistors used.
Here is a test program that was used to test the toggle switches
/* Test Program 2
Tests toggle switches
Requires toggle switches and serial port monitor
*/
#include <Arduino.h>
// use voltage divider network for two push button switches using A0 and A1
// use software debouncing
#define ToggleSwPin  A0         // Toggle switches wired to A0 via resistor divider network
#define BUTTONDELAY 20
#define DEBUG_ON
long buttonLastChecked = 0; // variable to limit the button getting checked every cycle
int PBVal;                  // holds state of toggle switch read 
// read the toggle switches and return which one is ON
int readtoggleswitches(int pinNum) {
  //  sw1 650-720, sw2 310-380, sw1 and sw2 460-530  
  int val = 0;         // variable to store the read value
  
  digitalWrite((14+pinNum), HIGH); // enable 20k internal pullup
  val = analogRead(pinNum);   // read the input pin
  Serial.print("Analogue Value = "); Serial.println(val);
  
  val = 0;
  
  if ( val >= 650 && val <=720 ) { 
      return 1;          // toggle sw1 ON and SW2 OFF
  }
  else if ( val >= 460 && val <= 530 ) { 
      return 3;          // toggle sw1 and sw2 ON
  }
  else if ( val >= 310 && val <= 380 ) {
      return 2;          // toggle sw2 ON and SW1 OFF
  }    
  else return 0;  // no button found to have been pushed
}
void setup() {
  Serial.begin(57600);
  Serial.println("Test Program 2: Toggle switches");
}
void loop() {
  if( buttonLastChecked == 0 ) // see if this is the first time checking the buttons
    buttonLastChecked = millis()+BUTTONDELAY;  // force a check this cycle
  if( millis() - buttonLastChecked > BUTTONDELAY ) { // make sure a reasonable delay passed
    PBVal = readtoggleswitches(ToggleSwPin);
    if( PBVal == 1 ) Serial.println("PB1 ON");
    if( PBVal == 2 ) Serial.println("PB2 ON");
    if( PBVal == 3 ) Serial.println("PB1 and PB2 ON");
    if( PBVal == 0 ) Serial.println("Both switches OFF");
    buttonLastChecked = millis(); // reset the lastChecked value
  }
  delay(1000);
}

Share this post


Link to post
Share on other sites

I developed a number of test programs which one can use to test each of the components separately. The idea behind this is to to build the controller, then test each device (such as switches, LCD, sensor, probes etc) using a test program to verify correct operation. In this way each part of the controller can be "checked" off (or fixed if not working) and then the controller code can be downloaded.

If one attempted to run the controller straight off, and there was some problem (such as shorted tracks, missing jumper etc), it complicates trying to resolve the issue. Using individual test programs makes like easier.

The test programs are

Test1 Tests the LCD
Test2 Test the toggle switches PB1 and PB2
Test3 tests the DHT11/DHT21/22/33 sensor using the dht lib
Test4 Tests the cooling fan and RGB LEDS
Test5 Tests the PWM outputs, the LEDS should vary in brightness, Uses the Serial Port 57600bps
Test6 Tests the DS1820 sensor probes
Test7 Bluetooth HC05 module
I will post the arduino code for each of the test programs shortly.
Cheers
Robert

Share this post


Link to post
Share on other sites

Here is the first test program, that tests to see if the LCD1602 is working. One may need to adjust the backlight potentiometer whilst running the program,

/* Test program 1 - LCD test
requires lcd1602 I2C
*/
#include <Arduino.h>
#include <Wire.h>
#include <LiquidCrystal_I2C1602.h>    // needed for LCD1602-I2C
LiquidCrystal_I2C lcd(0x27, 16, 2); // address 0x27, 16 characters by 2 rows
void setup() {
  Serial.begin(57600);    // initialise serial port
  Serial.println("Test Program 1: LCD1602+I2C");
  // initialise the lcd display
  lcd.init();
  lcd.backlight();
  lcd.print("Dew Control");
  lcd.setCursor( 0, 1 );              // col, row
  lcd.print("Test");
  delay(2000);
  Serial.println("If you do not see anything, try adjusting the backlight and check connections");
}
// --------------------------------------------------------
void loop() {
  lcd.clear();
  lcd.setCursor( 0, 0 );
  lcd.print("Dew Control");
  lcd.setCursor( 0, 1 );              // col, row
  lcd.print("Test");
  delay(2000);
}

Share this post


Link to post
Share on other sites

Here is test program 2 to test the 100% override toggle switches

/* Test Program 2
Tests toggle switches
Requires toggle switches and serial port monitor
*/
#include <Arduino.h>
// use voltage divider network for two push button switches using A0 and A1
// use software debouncing
#define ToggleSwPin  A0         // Toggle switches wired to A0 via resistor divider network
#define BUTTONDELAY 20
#define DEBUG_ON
long buttonLastChecked = 0; // variable to limit the button getting checked every cycle
int PBVal;                  // holds state of toggle switch read 
// read the toggle switches and return which one is ON
int readtoggleswitches(int pinNum) {
  //  sw1 650-720, sw2 310-380, sw1 and sw2 460-530  
  int val = 0;         // variable to store the read value
  
  digitalWrite((14+pinNum), HIGH); // enable 20k internal pullup
  val = analogRead(pinNum);   // read the input pin
  Serial.print("Analogue Value = "); Serial.println(val);
  
  val = 0;
  
  if ( val >= 650 && val <=720 ) { 
      return 1;          // toggle sw1 ON and SW2 OFF
  }
  else if ( val >= 460 && val <= 530 ) { 
      return 3;          // toggle sw1 and sw2 ON
  }
  else if ( val >= 310 && val <= 380 ) {
      return 2;          // toggle sw2 ON and SW1 OFF
  }    
  else return 0;  // no button found to have been pushed
}
void setup() {
  Serial.begin(57600);
  Serial.println("Test Program 2: Toggle switches");
}
void loop() {
  if( buttonLastChecked == 0 ) // see if this is the first time checking the buttons
    buttonLastChecked = millis()+BUTTONDELAY;  // force a check this cycle
  if( millis() - buttonLastChecked > BUTTONDELAY ) { // make sure a reasonable delay passed
    PBVal = readtoggleswitches(ToggleSwPin);
    if( PBVal == 1 ) Serial.println("PB1 ON");
    if( PBVal == 2 ) Serial.println("PB2 ON");
    if( PBVal == 3 ) Serial.println("PB1 and PB2 ON");
    if( PBVal == 0 ) Serial.println("Both switches OFF");
    buttonLastChecked = millis(); // reset the lastChecked value
  }
  delay(1000);
}

Share this post


Link to post
Share on other sites

I had a chance today to do some current measurements.

Normal = 240ma, 0% pwm power to dew straps and fan off
With DN003 straps connected, oth channels at 100% PWM = 1Amp
According to DewNot, the DN002 straps should draw approximately 0.35Amps each, giving 0.7Amps for both dew straps.
So combining this with around 240milliamps for the controller gives about 940milliamps, very close to the measured current of 1 ampere.
As I will be using the DN007 straps, I will probably go with a lower fuse rating of 3 amps instead of the current 6A fuse that I have fitted to the controller.

Share this post


Link to post
Share on other sites

I have moved this to Source Forge as the files are rather large and it lets me place all the code including the documentation and windows application etc there.

Share this post


Link to post
Share on other sites

Now with full ASCOM driver support, windows standalone app, and comes with two versions to satisfy user requirements.

ASCOM driver and windows app supports either version, only the circuit and arduino code changes.

LCD support

Zero positioning support

Full step/half step support

reverse direction support 

and much much more.

Share this post


Link to post
Share on other sites

Now with full ASCOM driver support, windows standalone app, and comes with two versions to satisfy user requirements.

ASCOM driver and windows app supports either version, only the circuit and arduino code changes.

LCD support

Zero positioning support

Full step/half step support

reverse direction support 

and much much more.

See the sister focuser project on Source Forge.....

Share this post


Link to post
Share on other sites

No problem

See http://sourceforge.net/projects/arduinonanodewcontrollerpro/ for the full build.

It also has links to the stepper focuser and SQM projects.

Merry Xmas

Robert

thank you, I do like the following feature a lot as this will be very handy for my remote observatory:

FULLY AUTOMATIC OPERATION - NO USER INTERVENTION REQUIRED
Can be controlled or monitored remotely via USB connection
Edited by Gonzo

Share this post


Link to post
Share on other sites

Hi Gonzo

Think you will find that the level of support for remote control operation is high.

Cheers

Robert

Share this post


Link to post
Share on other sites

Greetings

fantastic project this is one I'm going to build.

very many thanks for sharing this build it is one of the best I've seen!!

thank you !

Andy ( Mansfield Nottingham )

Share this post


Link to post
Share on other sites

Thanks Andy, all the best, if you need to ask any questions re the project please use the discussion forum on sourceforge, 

cheers

Robert

Share this post


Link to post
Share on other sites

Hi Robert,

quick question, have you tested this with negative ambient temperatures (the temperature used to calculate the dew point)?

I'm building something similar and I get really strange results for the dew point (minus 2000-ish degrees) when the temperature goes below zero).

I'm using a DHT22 and the same formula to calculate the dew point (the one you use above 50%RH).

Share this post


Link to post
Share on other sites

Hi Chris

The dew controller actually uses a more accurate calculation.

IF WORKING IN CELCIUS AND RELATIVE HUMIDITY > 50%
If you are interested in a simpler calculation that gives an approximation of dew point temperature if you know the observed temperature and relative humidity, the following formula was proposed in a 2005 article by Mark G. Lawrence in the Bulletin of the American Meteorological Society:
Td = T - ((100 - RH)/5)
The dew controller uses
  logEx = 0.66077 + 7.5 * t / (237.3 + t) + (log10(h) - 2);
  dew_point = (logEx - 0.66077) * 237.3 / (0.66077 + 7.5 - logEx);
Here is a test program using negative examples, this works perfectly
/* 
  Code test for an astronomy dew heater
  By RBB, August 2014, Serial/Windows
  For negative temperature calculations
*/  
#include <Arduino.h>
#include <math.h>
float dew_point;
void setup() {
  Serial.begin(9600);    // initialise serial port
}
// --------------------------------------------------------
void loop() {
  //calculate dew point
  Serial.print("Case 1, temp = 10c, Humidity = 50%, (Expect 0.1) DP=");
  dew_point = calc_dewpoint(10.0, 50);
  Serial.println(dew_point);
  delay(1000);
  Serial.print("Case 2, temp = 0c, Humidity = 45%, (Expect -10.5) DP=");
  dew_point = calc_dewpoint(0.0, 45);
  Serial.println(dew_point);
  delay(1000);
  Serial.print("Case 3, temp = -10c, Humidity = 50%, (Expect -18.4) DP=");
  dew_point = calc_dewpoint(-10.0, 50);
  Serial.println(dew_point);
  delay(1000);
  Serial.print("Case 4, temp = -20c, Humidity = 10%, (Expect -43.6) DP=");
  dew_point = calc_dewpoint(-20, 10);
  Serial.println(dew_point);
  delay(1000);
  Serial.print("Case 5, temp = -30c, Humidity = 75%, (Expect -33) DP=");
  dew_point = calc_dewpoint(-30, 75);
  Serial.println(dew_point);
  delay(1000);
}
// calculates dew point
// input:   humidity [%RH], temperature in C
// output:  dew point in C
float calc_dewpoint(float t, float h) {
  float logEx, dew_point;
  logEx = 0.66077 + 7.5 * t / (237.3 + t) + (log10(h) - 2);
  dew_point = (logEx - 0.66077) * 237.3 / (0.66077 + 7.5 - logEx);
  return dew_point;
}
Remember that the formula works where temperature is in C.
Also temp must be a float value,
Cheers
Robert 

Share this post


Link to post
Share on other sites

Thanks a lot, Robert! ;-)

I've been playing around with this yesterday. It seems the functions themselves (the one I was using and yours above) work fine with negative numbers. The problem must be somewhere else in my code.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.