Autnomous AI Controlling Raspberry Pi




100 Points
Learning Objectives

These instructions will show you how a Raspberry Pi can interact with the physical world and an AI using code, sensors and actuators.

This assignment assumes you have completed IOT27-using a Raspberry Pi with Sensors and Actuators.
This software and hardware allows you to collect data from sensors and send signals to actuators by Python programs running on a Raspberry Pi.

More information on the GrovePi+ system used is available online.
This system allows you to collect data from devices connected to your Raspberry Pi-such as peripherals and connected sensors that measure light level, sound level, temperature level, humidity leve and more.

After completing this assignment you will be able to:

  1. Investigate sensors and actuators
  2. Run Python programs on a Raspberry Pi that communicate with sensors and actuators
  3. Discuss uses of Raspberry Pi/Grove Pi devices to solve problems and address opportunities

Assignment Overview

When you encounter technical issues, please first review IOT00.

This assignment reviews basic computer concepts that you will need in this course and throughout your career.

You are expected to have a working knowledge of SBC hardware and software.
If you do not understand how to use an item, perform a Google Search, refer to the WSU Technology Knowledge Base,  ask a teaching assistant, or ask the instructor.


Exercise 1-Examine Sensors & Actuators
  1. These steps are performed on the Raspberry Pi.
  2. Each IoT workstation contains a Raspberry Pi, Grove Pi+ data acquistion board and 10 sensors and actuators.
    Python programs have been written that control these devices-physical connections, data gathering, data processing, data presentation and data storage, if required.
  3. Make sure that the Raspberry Pi is powered on.
    Then inspect the GrovePi board to make sure it is also powered on-the green LED in the bottom center of the board will be lit.
    Note-if the GrovePi board Red LED reset light is illuminated, you must shutdown the Raspberry Pi, turn off the power, wait five seconds and then turn the power on again.

    GrovePi reset lightGrovePi with Red Reset light on

  4. Familiarize yourself with the available sensors and actuators depicted below.

    sensors and actuators on GrovePiGrovePi with Sensors and Actuators-on top of Raspberry Pi

  5. Review the GrovePi Configuration that details how the sensors and actuators are physically connected.
  6. On the desktop, right-click the 'Grove LED Bar' icon.
    grove led icon
    Choose 'Text Editor'
  7. Mousepad opens and displays a configuration file containing the path to the xLED_bar.py file
  8. Open a Terminal Window, enter python and the path to the Python file:
    python /home/pi/Desktop/IoT_Files/xLED_bar.py
    Press Enter and the program will execute, and illuminate the LED bar segments.
  9. Alternatively, double-click the Grove LED Bar icon on the desktop and choose 'Execute in Terminal'.
  10. To view the python program, open 'File Manager' to the path indicated above, find the file xLED_bar.py, right click it and choose 'Text Editor' .
    Examine the program code.

    LED test barLED Bar test on desktop


Exercise 2-Examine System Test
  1. These steps are performed on your Raspberry Pi.
  2. Using the skills learned, examine the program behind the Grove IoT icon on the desktop.
    Hint: it is connected to the program 'xSystemTest.py'
    grove led icon
  3. The program xSystemTest.py is much more complex.
    It is designed to test the proper functioning of all the sensors, actuators and the Raspberry Pi sound system.
  4. Run the program xSystemTest.py
    Note-this program is interactive, follow the prompts on the screen.
    Note-the program will read the test results aloud, if not troubleshoot the Raspberry Pi sound system.
  5. When done, the program appends the results to SystemTest.txt on the desktop.
    Open the file, scroll to the end.

Exercise 2A-Modify System Test
  1. These steps are performed on your Raspberry Pi.
  2. Using the skills learned, modify the program behind the Grove IoT icon on the desktop.
    Hint: it is connected to the program 'xSystemTest.py'
    grove led icon
  3. Save a copy of the program xSystemTest.py as RemoteControl.py complex.
  4. As you make changes, add comments and run the program Remote Control.py
    Note-this program is interactive, follow the prompts on the screen.
    Note-the program will read the test results aloud, if not troubleshoot the Raspberry Pi sound system.
  5. You are encouraged to comment out code you do not need, instead of deleting it, in case you need the code later.
  6. When done, the program should append the results to RemoteControl.txt on the desktop.
    Open the file, scroll to the end.
    Note-you will have to create the file /home/pi/Desktop/RemoteControl.txt
    The file name is case-sensitive, and must be in that exact location.
  7. Modify the program so that when an input is received from an external AI system (think your studentwebs website, using API connected to ChatGPT) that it activates.
  8. 'Activation' entails three things.
  9. activate buzzer to turn on for one second, turn off for one second
  10. strobe 10 segment LED bar, light one bar at a time for appropriate time (try .1, .5, 1 second on)
    note-if you are in MIS492 AI, see Summative10
  11. energize the relay

Exercise 3-Screenshot

These steps are done on the Raspberry Pi, or on your laptop using VNC.

  1. Take a screenshot of the last part of the new file RemoteControl.txt, displaying the relay status and current date.
    Note: this can be done using the Snipping Tool if you are running VNC, or use the scrot command if you are connected to the Raspberry Pi with a keyboard and mouse.

    system test system test output

  2. On your laptop save the screenshot as "IOT27" in your ' ' folder.

Screenshot IOT27


Upload Screenshot

Submit to the appropriate D2L Assignment folder a screenshot that documents your work.


(50) 1. Upload your screenshot to the 'IOT27' D2L Assignment Folder.


Exercise 4-Reflections

Based on your experience in this exercise, consider the impact of IoT devices that can be controlled autonomously from an AI.
Think about what a Raspberry Pi equipped with sensors and actuators could do, and whether it could be cost-effective, ethical, or wise.
Businesses are deploying IoT 'solutions'-how can an AI controlled, sensor equipped Raspberry Pis support, derail, or automate these efforts?

References:
Grove Pi:  Grove Pi Wiki
Grove Hat:  Rasberry Pi Weekly

(20) 2. Reflections-value
List a specific problem that a GrovePi equipped Raspberry Pi could cause.

(20) 3. Reflections-content
Research the internet on any topic related to AI controlled Internet of Things sensors and actuators.
Provide one example of how an organization's product development department could use an AI controlled GrovePi system to society's benefit.

Submit Assignment

When all tasks are completed press the Submit button.


(10) 4. Assignment submission

Congratulations! You have used the GrovePi system, an interface to sensors and actuators, on a Raspberry Pi single board computer.