Real degrees. Real humidity. Your desk becomes a tiny weather station reporting on your actual room.
Enter the access code from the card inside your Beginner Kit (or from your GAMERIFT order email). Your name appears on every page and printout as the licensee.
Don't have a kit yet? Get the Beginner Kit, the code ships inside. Lost your code? Contact us with your order number.
Your photoresistor mumbled a raw number and left you to figure out what it meant. Today's sensor is a different creature. The DHT11 measures temperature and humidity and reports them in real units: degrees Celsius, percent humidity. The same family of sensor lives inside air conditioners, incubators and greenhouses. By the end of this lesson your room will have its own weather report, updating live on your screen.
Time: 45–60 minutes · Difficulty: 3/5 · You need: Lesson 06 done (Serial Monitor habits).
The DHT11 speaks a fussy timing language, signals measured in microseconds. You could learn it... or you could use the code someone already wrote and tested for the whole world. A library is exactly that: expert code you download once and command with easy words like readTemperature(). Professional engineers use libraries every single day. Knowing when not to reinvent is a skill.
Sensors sometimes fail to answer, a loose wire, a too-hasty question. When that happens the library hands you a special not-a-number value called NaN. Good programs check for it and say something useful instead of printing garbage. Today you write your first error handling, which is the moment your code starts becoming trustworthy.
Unplug the USB. Push the module's three pins into the breadboard and wire from its rows. Check the tiny letters printed next to the pins, most kits mark them S (signal), middle (power), and − (ground), but trust the letters on YOURS over any diagram.
| From | To | Why |
|---|---|---|
| Module S pin | R3 pin 2 | The data line, where the sentences arrive |
| Module middle pin | R3 5V | Power for the sensor's tiny brain |
| Module − pin | R3 GND | Loop complete |
// GAMERIFT Beginner Kit, Lesson 09: Weather Desk // A live weather report for one small room. #include <DHT.h> // invite the library in const int dhtPin = 2; DHT dht(dhtPin, DHT11); // our sensor, by name and type void setup() { Serial.begin(9600); dht.begin(); Serial.println("Weather Desk starting..."); } void loop() { float temp = dht.readTemperature(); // degrees C, with decimals float hum = dht.readHumidity(); // percent if (isnan(temp) || isnan(hum)) { // did the sensor not answer? Serial.println("Sensor not answering. Check the three wires."); } else { Serial.print(temp); Serial.print(" C | "); Serial.print(hum); Serial.println(" % humidity"); } delay(2000); // the DHT11 needs 2 seconds between questions }
Screenshot your weather report (bonus: the breath spike) for your lesson log. Stuck? Contact us with a photo of the three wires.
Your machines can feel light and air. Next they get ears: a sound sensor and a lamp you switch on by clapping, the classic sci-fi gadget, real, on your desk.