Return to the Cloudy Nights Telescope Reviews home pageAstronomics discounts for Cloudy Nights members
· Get a Cloudy Nights T-Shirt · Submit a Review / Article

Click here if you are having trouble logging into the forums

Privacy Policy | Please read our Terms of Service | Signup and Troubleshooting FAQ | Problems? PM a Red or a Green Gu… uh, User

Equipment Discussions >> Equipment

Pages: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | (show all)
ThadeusB
member


Reged: 11/14/12

Loc: Somerset, UK
Re: How to make an automatic dew controller - Arduino new [Re: Pauls72]
      #5539925 - 11/26/12 08:27 AM

Paul,
Odd you say about typing up and then losing it; my last message suffered a similar fate, typed, clicked on continue and it dissapears - annoying.

However, Thanks again! Putting in delays doea nothing bu cause the LCD to freeze for around 15 secs; as might be expected. The DHT readings still the same.

So, I'm starting to look at your suggestion re- tweaking the dht11 files.

lcd.print(((int)DHT11.fahrenheit()+correctionDHT), DEC); I had assumed this to be a tweak to correct DHT measured T, to correct it to actual T. I may be wrong.

I would appreciate some info on the basics. When writing up long messages, I tend to do it my word processor first, then paste into whatever forum; less chance of losing things that way.

I like Textpad. Good because it can be set up with line numbers - very useful. I had been trying to find this kind of text editor. Thanks for the link.

Phil


Post Extras: Print Post   Remind Me!   Notify Moderator  
ThadeusB
member


Reged: 11/14/12

Loc: Somerset, UK
Re: How to make an automatic dew controller - Arduino new [Re: Pauls72]
      #5540095 - 11/26/12 11:01 AM

Hi Paul,
Well, I've had a long read of the Arduino article, have opened the h and cpp files, but I remain in the dark.

I understand bits and bytes etc. However, in this extra from the cpp file we are using, I can't relate anything to byte quantity or how many bytes in the data string:

// READ OUTPUT - 40 BITS => 5 BYTES or TIMEOUT
for (int i=0; i<40; i++)
{
loopCnt = 10000;
while(digitalRead(pin) == LOW)
if (loopCnt-- == 0) return -2;

unsigned long t = micros();

loopCnt = 10000;
while(digitalRead(pin) == HIGH)
if (loopCnt-- == 0) return -2;

if ((micros() - t) > 40) bits[idx] |= (1 << cnt);
if (cnt == 0) // next byte?
{
cnt = 7; // restart at MSB
idx++; // next byte!
}
else cnt--;
}

The comment refers to 5 bytes, but that's the only bit that I understand.

The upshot is that I have no idea how to go about sorting this out. Except, perhaps I should buy a DHT11 and accept the lower specification.
Very frustrating.

Phil


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pauls72
professor emeritus
*****

Reged: 10/28/07

Loc: LaPorte, IN
Re: How to make an automatic dew controller - Arduino new [Re: ThadeusB]
      #5540296 - 11/26/12 01:22 PM

Well if you get a DHT11 you can be up and running right away. You can always upgrade to the DHT22 later. I see you can get them on Amazon for £3.50 ($5.60 USD).

I take a look at converting the library, but it won't be for a few days. I don't have a DHT22. I have no local electronics stores anymore other than Radio Shack (If you can call them an electronics store). So currently I would no way to test it.


Post Extras: Print Post   Remind Me!   Notify Moderator  
ThadeusB
member


Reged: 11/14/12

Loc: Somerset, UK
Re: How to make an automatic dew controller - Arduino new [Re: Pauls72]
      #5540450 - 11/26/12 02:48 PM

Paul,
I've just ordered a DHT11 from ebay; £2.70.

What I haven't done is to try to analyse the DHT22 testing sketches, they may give me some clues.

I'll keep on messing with this and let you know the outcome.

Again, I very much appreciate your help with this, but I don't want you to go to too much trouble.

If it comes to it and I can't sort out the DHT22 issues, I could buy one and have it sent to you: what do you think?

The other way is to find out why the DHT22 librairies won't compile with my sketch, when everything changed to 22 from 11. That must be in the *.h and/or *.cpp files. I' will take a look at this too.

I will get there, I do not give up easily.

Regards

Phil


Post Extras: Print Post   Remind Me!   Notify Moderator  
ThadeusB
member


Reged: 11/14/12

Loc: Somerset, UK
Re: How to make an automatic dew controller - Arduino new [Re: ThadeusB]
      #5540598 - 11/26/12 04:17 PM

Paul,
Another option: when I get the DHT11 and presumably will have it working, I could mail the DHT22 to you, for you to play with, keep and use for yourself. If a resolution to the problem if found by you, I then buy another one for myself.
Phil


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pauls72
professor emeritus
*****

Reged: 10/28/07

Loc: LaPorte, IN
Re: How to make an automatic dew controller - Arduino new [Re: ThadeusB]
      #5540745 - 11/26/12 06:05 PM

Phil,
No need to send me one. I will order a couple of DHT22's for myself.
To get them cheap (under $5) and with free shipping requires I get them from Hong Kong or other parts of China. Which means 10-14 days shipping.

To order one from someplace in the US is at least $10 or more plus shipping and handling. So your looking at $15 - $30 for just one. Then people wonder why we buy stuff from China.

Regards,
Paul


Post Extras: Print Post   Remind Me!   Notify Moderator  
ThadeusB
member


Reged: 11/14/12

Loc: Somerset, UK
Re: How to make an automatic dew controller - Arduino new [Re: Pauls72]
      #5540814 - 11/26/12 06:54 PM

If you're sure Paul, its very good of you to do this.

It never ceases to amaze me how cheap stuff is from China and, often with no postal charge for small items. It has to be done on retirement money!

I'm still trying to crack the problem.

Regards
Phil


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pauls72
professor emeritus
*****

Reged: 10/28/07

Loc: LaPorte, IN
Re: How to make an automatic dew controller - Arduino new [Re: Pauls72]
      #5540815 - 11/26/12 06:54 PM

Phil,

If I am starting out to basic for you I apologize.
Lets start with the Arduino reference, it contains a list of all the reserved words and what they do.
http://arduino.cc/en/Reference/HomePage

Libraries
When you include a library in your program, the whole library and any external libraries or files that it references become part of your program.
#include <EEPROM.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#include <dht11.h>
#include <math.h>

Variables and Constants
This is a space in memory that you allocate to contain a value of data. How it's defined, it's size and what you can do with it all depends on how you define it.
int is a signed integer number and is 16 bits or 2 bytes in size, it can contain any whole number between 32,768 and 32,767.
unsigned int is an unsigned integer number and is also 16 bits or 2 bytes in size, it can contain any whole number between 0 and 65,535.
long a signed integer number and is 32 bits or 4 bytes in size, it can contain any whole number between -2,147,483,648 and 2,147,483,647.
No decimals or fractions are used or allowed in integer or long type variables.
float is a floating point or decimal number and it is a 32 bit or 4 bytes in size, it can contain and number between 3.4028235E+38 and -3.4028235E+38. It is accurate to 6 or 7 decimal places.
double is a floating point or decimal number and it is a 64 bit or 8 bytes in size on some processors and allows for greater accuracy and larger numbers. However on the Arduino Uno it is treated exactly the same a a float.
So the big advantages of these are you can cram large numbers into small spaces in memory. When you define some thing as a char (character) or byte you need to declare an array of them (group) to store a value. They can each only hold one character or digit of a number.
So in int form the value 32,767 takes 2 bytes to store, float takes 4 bytes and in the form of a byte or char would take 5 bytes.
Computers are very good and fast at performing integer math. They are not nearly as fast or accurate at performing floating point math.
String is an special object, it is an array or group of bytes all in a row, and it allows you to access them all as one variable instead of a a group of characters one at a time.

Reserve words and inbuilt functions
So lets start with something simple and partially explain one of these reserved words.
Serial.print();
Serial is a reserved word and it performs a series of functions depending on what comment you put after it. The print tells the system to output the data between the prentices () to the USB serial port. You can open the serial port monitor with in the Arduino compiler and see what is being sent. This is a good tool to use when debugging.
http://arduino.cc/en/Reference/Serial

Serial.print("ABC123 This is a test"); Will send 'ABC123 This is a test' out the USB serial port. The text data must be enclosed by double quotes.

String MyString = "ABC123 This is a test"; This creates a string variable in memory named MyString and loads it with 'ABC123 This is a test'.
serial.print(MyString); Will send 'ABC123 This is a test' out the USB serial port.
So you say why bother. Well if you use the same string of data over and over, every time you have it in our source code it uses up a bunch of memory. When you define it as a variable or constant it only take a few of bytes memory to reference that variable or constant, thus saving you memory.

Serial.printnl(MyString); This sends the same data to the serial port and it sends a carriage return and line feed characters after the data to move the cursor down and to the beginning of the next line.

Serial.println(); This acts just like you have pressed the enter key and just moves the cursor down to the start of the next line.

Math, passing values and Cast
So lets do a little bit of passing values and math.
long MyLong;
float MyFloat="33.999";

MyLong = MyFloat; The compiler will generate a warning or error because the variables are of different types.
MyLong = ((long)MyFloat); This will tell the compiler to take the value in MyFloat and treat it as a long type variable instead of a float and copy it to the MyLong variable throwing away the fractional part of the number. It is called a "cast". It tells the compiler you are aware the variables are different types and are the aware of the consequences. It is commonly used to convert one type of number into to a different form. A kind of converting on the fly.
MyLong = ((long)MyString); This will will not work and you can not convert a string to a any number this way.

Serial.printnl(MyFloat); This will output '33.999' to the serial port.
Serial.printnl((long)MyFloat); This will output '34' to the serial port.

Class or Function
A class or a function is just a part of a program that you call to perform a specific task or set of tasks. In olden days it was know as a subroutine. Either of these can programed to accept variables or pointers passed to it and they can also be programed to return results or variables too. Both of these can be in your main code or in an included library.
So lets suppose we create a function called DoubleIt. It's job in life would be to take what ever you passed to it and double it and return the results to you.

We will declare some variables:
int MyIntResults;
float MyFloatResults;
String MyStringResults;

So we will call our function and place the results in the variable to the left of the equal sign. We also will pass the function a parameter to tell it what type of variable we are sending it. I for int, F for float or S for String.
MyIntResults = DoubleIt(2,I); Would give you a '4'
MyIntResults = DoubelIt(DoubleIt(2,I)); Would give you a '8'. Yes we can call a function from within a function.
MyFloatResults = DoubleIt(2.222,F); Would give you a '4.444'
MyStringResults = DoubleIt(2,S); Would give you '22'

Now if we are a good programer we could write the DoubleIt function figure out on it's own what type of variable you are passing to it. You could even program your DoubleIt function to accept a picture or file name and double it and return the results too. The possibilities are almost endless.

int x = 3;
int MyIntResults;
MyIntResults = x+1; Would give you a 4 and x still contains 3.

int x = 3;
int MyIntResults;
MyIntResults = ++x; Would also give you a 4 and x now contains a 4. ++ and -- tells the compiler to increment or decrement the number. It make a difference if you place it to the right or left of the value as to when it does it.

int x = 3;
int MyIntResults;
MyIntResults = x++; Would give you a 3, but x now contains a 4.

Finally Something Practical
So lets finally get to this:
lcd.print(((int)DHT11.fahrenheit()+correctionDHT), DEC);

lcd.print(); Calls the print function in the lcd library and tells it to output the data inside the prentices ().
lcd.print((), DEC); Calls the print function in the lcd library and tells it to output the data inside the first set of prentices () as a decimal number.
DHT11.fahrenheit(); Calls the Fahrenheit function inside the DHT11 library, and after reading the results of the DHT11 it is returned in Fahrenheit as a floating point number.
(int)DHT11.fahrenheit(); Calls the Fahrenheit function inside the DHT11 library and treat the results as an integer instead of a floating point number.
+correctionDHT Tells the compiler to add the varable 'correctionDHT' to the results. I do this because my DHT11 is always off by about 2 degrees, so I add '-2' to lower the results by 2 degrees.

Something else practical
// ********************LX200 tests********************
if(sensors.getAddress(LX200, 0)) {
if (ts0 >= 1){
sensorStorage(p1, 11, 21);
//if(Meade <= 80) { //This line used for testing
if(Meade <= DEW+dewAdjust1) {
digitalWrite(5,HIGH);
}
else
{
digitalWrite(5,LOW);
}
}
else
digitalWrite(5,LOW);
}
***************************************************************
If the first Dallas OneWire Sensor #0 is present, call the function I wrote to store off the high and low values for the sensor readings to EEPROM memory. I pass 3 values to the function, the temperature, the storage locations for the high and then the low values. This allows me to use the same function for any sensor, no matter how many I have, including both the OneWire and DHT sensor.

If the OneWire temperature is less than 5 degrees above the dew point, turn the output to the transistor on.

If the OneWire temperature is greater than 5 degrees above the dew point, turn the output to the transistor off.

If the OneWire temperature is not present turn the output to the transistor off.

Anything after // is a comment and can be ignored.
Anything between /* and */ is also just a comment.

The Arduino language is very similar to C++. Both are OOP type languages (Object Oriented Programing). You can pass variables, pointers to variables, functions, classes and the results of classes and functions all over the place. It makes it very powerful, but it makes it difficult to read and understand.

Hopefully I have given you enough information so you can read and understand some of the code.

Regards,
Paul


Post Extras: Print Post   Remind Me!   Notify Moderator  
ThadeusB
member


Reged: 11/14/12

Loc: Somerset, UK
Re: How to make an automatic dew controller - Arduino new [Re: Pauls72]
      #5540818 - 11/26/12 06:56 PM

Ye Gods! I didn't expect all that; basic is good for this leaner.

Thank you.

Phil


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pauls72
professor emeritus
*****

Reged: 10/28/07

Loc: LaPorte, IN
Re: How to make an automatic dew controller - Arduino new [Re: ThadeusB]
      #5541237 - 11/26/12 10:51 PM

Phil,
If you have specific questions just ask an I'll do my best to explain it, if I can. I didn't go too deep into any one piece, just touched on a lot of stuff. I could probably spend a easy half of day on just variables and constants.

One other thing you need to understand is arrays. You can declare array of any type of variable. So lets say I want to store 5 sets of sensor results, I could declare the following as variables.
int sensorResults0;
int sensorResults1;
int sensorResults2;
int sensorResults3;
int sensorResults4;

or you can also do the following:
int sensorResults0, sensorResults1, sensorResults2, sensorResults3, sensorResults4;

Both of these do the exact same thing, they declare 5 variable in memory of type integer.

So lets make an array of integers to store the same 5 values:
int sensorResults[5];

So now there is an array of 5 instances of sensorResults. To access them you use an index value.
sensorResults[0]; This is the first occurrence of sensorResults.
sensorResults[4]; This is the last occurrence of sensorResults.

So then instead of putting a value in the index, you can put a numeric variable in the index.

int sensorResults[5];
for (int MyIndex = 0; MyIndex < 5; MyIndex++){
sensorResults[MyIndex] = MyIndex;
}

So we have a small loop that loads the array with 0 to 4.
sensorResults[0] will have 0
sensorResults[4] will have 4

You need to understand this is close to a machine language and zero is a valid number and all counting starts at zero. Zero is a real number.

Paul


Post Extras: Print Post   Remind Me!   Notify Moderator  
ThadeusB
member


Reged: 11/14/12

Loc: Somerset, UK
Re: How to make an automatic dew controller - Arduino new [Re: Pauls72]
      #5541896 - 11/27/12 11:22 AM

Hi Paul,
So far so good with the first set of info you sent, all very understandable. I'll read the second one tonight. Many thanks.

I should have the DHT11 tomorrow. I am just finishing the wiring now, so I should have the build finished tomorrow too. I'll take a couple of photo's to send when complete. Its very neat and should be reliable.

I should also have a couple books on Arduino programming in a couple of days. What I want to know now is exactly how the .h and .cpp libraries work. I've closely compared the adafruit and Arduino.cc DHT libraries, and can see the differences between them and your files, but its not yet clear what controls the bits and bytes. If bits and bytes are the only real difference then, it shouldn't be hard to tweak your libraries. I'm experimenting, but without success yet. It will come.

My wife looked up your location on the USA map; she was curious to know where you live. Not a million miles from where all my relatives live in and around Toronto!

As a matter of interest, what is your background?

Best regards

Phil


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pauls72
professor emeritus
*****

Reged: 10/28/07

Loc: LaPorte, IN
Re: How to make an automatic dew controller - Arduino new [Re: ThadeusB]
      #5542410 - 11/27/12 04:23 PM Attachment (29 downloads)

Phil,

I ordered a DHT22, I should have it in about 10 days.

I tried to modify the working DHT11 library to work with a DHT22 instead.
I have no way to test it, so you will need to do that.
Go back to the set of programs and libraries that kind of worked but gave you crazy results. Everything in your main program should point to DHT11 for now, we will fix that later.

In the Libraries/DHT11 folder, replace the dht11.cpp with the attached one. Compile and upload and see if your temperature and humidity results are right.

If you open up the Serial Monitor in the Arduino Compiler/IDE (Interactive Developer Environment) make sure it's set to 9600 baud, you should something like the following. Just to remind you all the background math and debugging to the serial port is in Fahrenheit.

Paul



Post Extras: Print Post   Remind Me!   Notify Moderator  
ThadeusB
member


Reged: 11/14/12

Loc: Somerset, UK
Re: How to make an automatic dew controller - Arduino new [Re: Pauls72]
      #5542610 - 11/27/12 06:41 PM

Hi Paul,
I've only just picked up your last post, as I've been busy buiding the box and wiring it. Its at on my desk reading out the Dallas temperatures. It looks good.

I've used the serial monitor quite a lot in fact for doing precisely what you say.

So now, its back to the IDE and try your new cpp file. Fingers crossed. I'll report back shortly.

Phil


Post Extras: Print Post   Remind Me!   Notify Moderator  
ThadeusB
member


Reged: 11/14/12

Loc: Somerset, UK
Re: How to make an automatic dew controller - Arduino new [Re: ThadeusB]
      #5542627 - 11/27/12 06:55 PM

Paul, you are a genius, its worked!!!

The reading are believable. My digital thermometer reads 21.4C, the DHT returns Temp=19C; hum=61%, Dew=13

It responds to me blowing on it, again, believable.
Amazing; so the next thing is get all the heaters hooked up and see if the whole thing behaves as it should - no reason why not I think.

As we say here, you're a good bloke.

So, no need to mess about with the DHT11 now - good stuff.

Paul, I can't thank you enough for what you have done, I am so grateful.

Best regards

Phil


Post Extras: Print Post   Remind Me!   Notify Moderator  
ThadeusB
member


Reged: 11/14/12

Loc: Somerset, UK
Re: How to make an automatic dew controller - Arduino new [Re: ThadeusB]
      #5542673 - 11/27/12 07:25 PM

Paul,
I'm still checking it out; I have two heaters connected which do warm when the DHT temperature is raised a few degrees. So, it seems that it works correctly. So tomorrow I'll have all 4 connected and run some quantitative tests to determine actual temperatures and transistor switching points.

Paul I am delighted!

Best regards

Phil


Post Extras: Print Post   Remind Me!   Notify Moderator  
ThadeusB
member


Reged: 11/14/12

Loc: Somerset, UK
Re: How to make an automatic dew controller - Arduino new [Re: ThadeusB]
      #5542681 - 11/27/12 07:29 PM

Also, I'll closely monitor temperature comparison between DHT and external digi thermometer. I should see then whether the correctionDHT needs to be changed.

Phil


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pauls72
professor emeritus
*****

Reged: 10/28/07

Loc: LaPorte, IN
Re: How to make an automatic dew controller - Arduino new [Re: ThadeusB]
      #5542910 - 11/27/12 09:50 PM

Phil,

Great, glad to here it works.
Since correctionDHT is a variable, you can just set it to 0 (zero) if you don't need to do any correction.

I sent you a PM with my background.

Regards,
Paul


Post Extras: Print Post   Remind Me!   Notify Moderator  
ThadeusB
member


Reged: 11/14/12

Loc: Somerset, UK
Re: How to make an automatic dew controller - Arduino [Re: Pauls72]
      #5543167 - 11/28/12 01:02 AM

Hi Paul,
I have just had all 4 outputs running. I have tested it such that I can see each output switching individually, with the '^' beside an enabled output. I can follow the rise in temperature and see the switch off point, which coincides with the differential. The precision is better than I can see with my thermometer. Accuracy I not sure of yet, since all 4 Dallas sensors and the DHT22 disagree with my thermometer, as does the DHT22. The screen shot reveals all. Its possible that my DHT also reads about 2 degrees low.

All looking very good. So the next thing is to get it up on the scopes and run it for real.

Photo's following.

Best regards

Phil


Post Extras: Print Post   Remind Me!   Notify Moderator  
ThadeusB
member


Reged: 11/14/12

Loc: Somerset, UK
Re: How to make an automatic dew controller - Arduino [Re: ThadeusB]
      #5543170 - 11/28/12 01:03 AM Attachment (27 downloads)

The attachment didn't do so, so here goes again

Post Extras: Print Post   Remind Me!   Notify Moderator  
ThadeusB
member


Reged: 11/14/12

Loc: Somerset, UK
Re: How to make an automatic dew controller - Arduino [Re: ThadeusB]
      #5543202 - 11/28/12 01:38 AM Attachment (28 downloads)

Photo's attached.

Phil


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | (show all)


Extra information
7 registered and 14 anonymous users are browsing this forum.

Moderator:  cbwerner, tecmage, rflinn68 

Print Thread

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled


Thread views: 22286

Jump to

CN Forums Home


Cloudy Nights LLC
Cloudy Nights Sponsor: Astronomics