element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Errors AHT10
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 2 replies
  • Subscribers 387 subscribers
  • Views 666 views
  • Users 0 members are here
  • arduino uno r4 wifi
Related

Errors AHT10

Henrik_t2
Henrik_t2 over 1 year ago

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

The code

#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

  • Sign in to reply
  • Cancel

Top Replies

  • misaz
    misaz over 1 year ago +3
    You declared myAHT at line 4, but later use myAHT 10 . Change AHT10 myAHT(0x38); to AHT10 myAHT10(0x38);
  • JWx
    0 JWx over 1 year ago

    which library do you use? there is Adafruit_AHTX0 library, but the include file is named Adafruit_AHTX0.h and the class is named the same (Adafruit_AHTX0)

    have you tried using any examples provided with your library?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • misaz
    0 misaz over 1 year ago

    You declared myAHT at line 4, but later use myAHT10. Change

    AHT10 myAHT(0x38);

    to

    AHT10 myAHT10(0x38);

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube