Hi,
Fairly new to Arduino programming but not entirely new to programming I now find myself flumuxed by the inability of my program to progress after being confronted with DHT11 requirements. My code is in error all as "expected declaration before '}' token ". The code follows:
/*
Attempt to build a program that runs on an Arduino LCD shield recording ambient temperature and humidity.
FILE: sketch_may13a.ino
PURPOSE: Arduino/DHT library test sketch. TDFWellWk.
*/ #include <LiquidCrystal.h> #include <DHT.h> #define DHT11_PIN 8 #define DHTPIN 2 #define dht(DHTPIN, DHTTYPE);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
float h = dht.readHumidity(); // ERROR OCURS AS: "sketch_may13a:31: error: expected declaration before '}' token"
// & I can parse nor progress any further than this line.
float t = dht.reademperature
Serial.begin(9600);
lcd.begin(16, 2);
dht.begin;
The includes are added by clicking <Sketch <Import Library , DHT11. I sincereley hope some one can help
Cheers,
Chris S.
ChrisPSR
I have and I have substituted others code some of which must be deemed to work and none seem to work within my Anduino Environment. Is there some secret that I don't comprehend either acutely or by accident or is that my Windows 8.1 is confusing the issue OR WHY. The code in use a mixture of mine and others and frankily shouldn't the following be enough:..............
#include <DHT.h> #define dht(DHTPIN, DHTTYPE);
......................................to get it to work, after all it is the 'type' that Mr., C Arduino is grumbling about!
Thanks once again. I think I had already tried that from someone else's coding; however implanting it and commenting out the earlier statement, provides an error by halting at that line, highlighting it, and all as follows:
sketch_may13a:27: error: 'DHT_LIB_VERSION' was not declared in this scope
Terribly sorry. I'm not aware of any necessary tags, however I do wish to conform.
The code was given for well after the point the code would not parse.
David,
To the best of my knowledge there is only the one HDT11 That's;
Delta/Hotel/Tango/unaone/unaone.hotel file which is within the Arduino Library. That's the one I am using.
However I don't mind using any *.h file that functions. Thanks for your help,
Chris
How the second time tonight. The file fred.h and fred.cpp need to be in a dir called fred in the user library directory and no where else. So you find out where on your PC the arduino user libs are you create a dir called fred and then you put fred.h and fred.cpp in it. After which you must restart the IDE. That is close all IDE windows and the one new ones.
I have Arduino IDE version 1.0.5 installed and have no DHT library. So no there is no "Delta/Hotel/Tango/unaone/unaone.hotel file which is within the Arduino Library". There are lots of DHT sensor libraries out there, if you don't know where yours came from, I suggest to throw it away and use this one...
Dear David, "I have a feeling that I am asleep while you are awake as this forum note is being
written at 1100 GMT"
Firstly, many thanks for your answer which set me thinking, but firstly:
Arduino seem to have a separate Library or one that I don't understand as yet found by Googling " Arduino DHT Library" which leads you to the Arduino Playground & "Class for DHT11, DHT21 and DHT22" and consequently there are to be found (no phonetics from now on) HTML., lists of all three required files ie., *.pde; *.cpp & *.h.
The link to that page is ................ Arduino Playground - DHT11Lib...........................
I copied these files to my Arduino IDE., programs and saved them to HDT11. They all saved themselves by way of their own independent folders but when I open the Arduino IDE., and attempt to load them they or their parent folder are not apparent. So.
I duplicated the whole file in C:\Programs File 86\Arduino\Sketchbook\ Libraries ............................ & then in
...................................................................................D:\Arduino\Sketchbook\Libraries....................... this is my Arduino-Preference location.
but the files don't show there either ?????????????????????? There are some mysteries that are yet to be unravelled to me I'm quite sure. Double clicking the actual file "dht_Test1.ino" seems to parse the program but then delivers up and ERROR as follows:
Error compiling......................dht11_test1\dht11.cpp.o: In function dht11::read(int)': D:\Electronics\Arduino\Sketchbook\libraries\dht11_test1/dht11.cpp:28: multiple definition of dht11::read(int)'
dht11.cpp.o:C:\Users\HARVEY~1\AppData\Local\Temp\build7190837537871424401.tmp/dht11.cpp:28: first defined here
David does any of this make sense to you because I seem to 'beating about a bush'. Even if this file worked I couldn't possibly believe that I wrote it............how could I and the whole purpose of the Arduino Environment to me is that I learn 'how to' and this would not be the answer I'm looking for...........BUT........... why on earth does this seemingly Arduino approved program not run?
Once more I hope you can help but if you give up on me and closed your eyes to the subject then believe me I would still hold you in high regard.
Cheers,
Chris
DavidOConnor:
I have Arduino IDE version 1.0.5 installed and have no DHT library. So no there is no "Delta/Hotel/Tango/unaone/unaone.hotel file which is within the Arduino Library". There are lots of DHT sensor libraries out there, if you don't know where yours came from, I suggest to throw it away and use this one...
I tried out your link which basically is the one that I had already been using having by passed the Arduino Library file mentioned previously BUT for some really unknown reason it now parses presumably because or perhaps the dht11.h file is in some way different. What I have to do now is add the Liquid Crystal bit and get it all working just as I wish rather than the way the original author has it. Incidentally you may notice the similarity of my primary program listing and the one you directed me to, thanks for your good works. How would I #include a LiquidCrystal.h file and know it to be correct or can I do without an *.h file?
By the way what is the difference between ................. <Arduino <Sketbook <Library - & - <Arduino <Sketbook <Lib ......................... ?
My Lib directory just has a few files terminated as .jar ....................... ?
Can't thank you enough for the advice which included the all important download the three complete files from the same authority.
Thanks and cheers, from a LEARNER, hope you might help again,
Chris S.
Just now figuring out the pinouts for the Liquid Crystal shield when mounted onto say a UNO., board and I hope to be away with the birds BUT:
If I have had so much trouble with the hdt.h file might I have the same trouble with a 'LCD+Keypad_Shield.h' file? AND:
If I wanted to start and build the ambient temperature module coupled with the LCD readout would I need to write *.h files or could I simply build a straightforward program without these or this type of file?