Chapter 9: Builders Paradise

Day 25: A very old friend

Day 25: A very old friend

The crew of the Nebula Raider is always looking for ways to improve efficiency and ease their workload. As a cadet, you are tasked with developing an AI assistant named Astrid. This assistant will monitor the environment, adjust lighting based on ambient light levels, control other onboard systems, and communicate with the crew through the serial monitor.


Components Needed:


  • Raspberry Pi Pico WH Microcontroller
  • LDR (Light Dependent Resistor)
  • DHT11 Digital Temperature and Humidity Sensor
  • SRD-05VDC-SL-C Power Relay
  • LEDs (to indicate AI status)
  • 5V Active Buzzer (for alerts)
  • Resistors
  • Breadboard
  • Jumper wires


Instructions:


Set Up the Circuit:


  1. Connect the LDR to an analog input pin on the Raspberry Pi Pico (e.g., GP26) using a voltage divider with a resistor.
  2. Connect the DHT11 sensor to a GPIO pin on the Raspberry Pi Pico (Data pin to GP2).
  3. Connect the relay module to a GPIO pin on the Raspberry Pi Pico (e.g., GP3) to control a light or another onboard system.
  4. Connect the active buzzer to a GPIO pin on the Raspberry Pi Pico (e.g., GP4) for alert sounds.
  5. Connect the LEDs to GPIO pins on the Raspberry Pi Pico (e.g., GP5 for green LED and GP6 for red LED) with appropriate resistors to indicate the AI status.
  6. Use jumper wires to make all necessary connections on the breadboard, ensuring a secure and organized setup.

Write the Code:


Open your coding environment and write the following Python code to create the onboard AI assistant named Astrid with basic communication:


Test the System:


  1. Upload the code to the Raspberry Pi Pico and run it.
  2. Open the Thonny IDE’s serial monitor.
  3. Type “help” to see the available commands and start interacting with Astrid.
  4. Test the LDR by varying the ambient light conditions and observing the light level readings.
  5. Test the DHT11 sensor by measuring temperature and humidity in different conditions.
  6. Ensure the relay correctly controls the light based on the light levels.
  7. Verify that the buzzer and LEDs provide accurate feedback on the temperature and light conditions.


Learning Outcomes: