Hello
I have bought 2 AHT10 sensors and I want to do a small test to see if they work.
See code.
But getting a lot of errors?? I am using Arduino Uno R4 Wifi Thanks
#include <Wire.h> #include <Adafruit_AHT10.h> AHT10 myAHT(0x38); void setup() { Wire.begin(); Serial.begin(9600); Serial.println ("Initialising AHT10 Sensor"); if (!myAHT10.begin ()) Serial.println("Sensor error!"); while(1); } void loop() { float temp = myAHT10.readTemperature (); float hum = myAHT10.readHumidity(); Serial.print("Temp:"); Serial.print (temp); Serial("°C"); Serial.print("Humidity:"); Serial.print (hum); Serial("%"); delay (1000); }
Errors
M:\Arduino Sketch\AHT10 sensor\sketch_apr7a_AHT10_test_2\sketch_apr7a_AHT10_test_2.ino:4:1: error: 'AHT10' does not name a type
AHT10 myAHT(0x38);
^~~~~
M:\Arduino Sketch\AHT10 sensor\sketch_apr7a_AHT10_test_2\sketch_apr7a_AHT10_test_2.ino: In function 'void setup()':
M:\Arduino Sketch\AHT10 sensor\sketch_apr7a_AHT10_test_2\sketch_apr7a_AHT10_test_2.ino:11:8: error: 'myAHT10' was not declared in this scope
if (!myAHT10.begin ())
^~~~~~~
M:\Arduino Sketch\AHT10 sensor\sketch_apr7a_AHT10_test_2\sketch_apr7a_AHT10_test_2.ino: In function 'void loop()':
M:\Arduino Sketch\AHT10 sensor\sketch_apr7a_AHT10_test_2\sketch_apr7a_AHT10_test_2.ino:18:15: error: 'myAHT10' was not declared in this scope
float temp = myAHT10.readTemperature ();
^~~~~~~
M:\Arduino Sketch\AHT10 sensor\sketch_apr7a_AHT10_test_2\sketch_apr7a_AHT10_test_2.ino:22:14: error: no match for call to '(UART) (const char [4])'
Serial("°C");
^
M:\Arduino Sketch\AHT10 sensor\sketch_apr7a_AHT10_test_2\sketch_apr7a_AHT10_test_2.ino:25:12: error: no match for call to '(UART) (const char [2])'
Serial("%");
^
exit status 1
Compilation error: 'AHT10' does not name a type
henrik_t7 Just follow the examples in the library, your first error on line 4 is because it does not look like the following. Just copy from working code.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
@henrik_t7 Could you confirm that the fix I provided has answered your question? I plan on stepping away from the forum for perhaps a long time but want to wrap up loose ends.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
I have tried one of the built-in Sketch but the arduino could not connect to the AHT10, maybe the AHT10 is defective and the wires might also be broken But sketch works fine without errors