Temperature and Humidity Sensor

1. Let's try the AHT20 temperature and humidity sensor. You'll need:

2. Make sure your device is not powered

Hook your sensor as shown on the left. It doesn't matter which end of the sensor you hook to the cable, however, the cable only plugs into each of the sockets in one direction.

3. Using Mu, try this code. Remember the following:

  • You must name your code "code.py"

  • Make sure to save the code to the microcontroller, not your computer

  • Ensure you have the required library (adafruit_ahtx0) saved to the microcontroller's lib folder. (download all libraries here)

Challenges:

  • Find a formula that prints the temperature in Fahrenheit. Print both F and C temperatures.

  • You know how to control the internal LED (or you can look back at the getting started page). Make the internal LED only light up when the temperature rises by a degree or two (from the current room temp).

  • Have a cute message print to the debug window, only when it's humid.

  • Create a "for loop" that measures the temperature five or more times over at least 10 seconds, then prints the average of the readings.