Forum #5: UNO Q & Grove Starter Kit V3
Hello fellow challengers
Building on my Forum #4 post—where I outlined using the Arduino UNO Q's AI vision capabilities to detect safety gear (glasses/vests) and Red Zone incursions—it’s time to bring that system into the physical world. Detection is only half the battle; we need to instantly alert operators when a safety breach occurs.
For this phase, I will be using the Grove Starter Kit V3 by connecting (piggybacking) its Base Shield onto our Arduino UNO Q. Here is my extensive, step-by-step novice-friendly guide to designing, coding, and implementing this alert system using the Arduino App Lab.
1. Hardware Integration: Piggybacking the Base Shield on the UNO Q
What does "piggybacking" mean? The Grove Base Shield V3 is an expansion board (a "shield"). The Arduino UNO Q maintains the classic UNO form factor and pin layout. "Piggybacking" simply means we align the male pins on the bottom of the Grove Base Shield with the female headers on the top of the UNO Q, and press them firmly together.
Why use the Base Shield?
Instead of dealing with messy wires, resistors, and breadboards, the Base Shield gives us neat, plug-and-play "Grove connectors." We just use the provided 4-pin cables to snap our sensors and output devices into the board.
2. Selecting the Ideal "Alert" Modules
While the Grove Kit is known for its "sensors" (which take data in), for an alert system, we need "actuators" (which put data out). To create a robust, multi-sensory alert system, I have selected the following components from the Grove Starter Kit V3:
-
Grove - Red LED (Visual Beacon): A flashing red light is the universal sign of danger. This will catch the operator's eye immediately.
-
Grove - Buzzer (Audio Siren): Factories and workspaces can be distracting. A loud, piercing auditory alarm ensures the alert is heard even if the operator isn't looking at the system.
-
Grove - LCD RGB Backlight (Status Display): We need to tell the operator why the alarm is going off. Is it a missing vest? A Red Zone incursion? This screen will display the exact text and change its backlight color to red during an emergency.
-
Grove - Button (Reset Sensor): A physical input sensor. Once the operator acknowledges the alarm and corrects the safety issue, they press this button to silence the system.
3. Data Flow & System Architecture
Before we code, it helps to visualize how information travels through our system. The UNO Q is special because it has a "Dual-Brain": a Qualcomm processor (for AI) and an STM32 microcontroller (for hardware).
Here is the flowchart of our logic:
========================================================================
SYSTEM DATA FLOW DIAGRAM
========================================================================
[ USB Camera ] --> Captures video feed of the work zone
|
v
+---------------------------------------------------+
| ARDUINO UNO Q |
| |
| 1. QUALCOMM MPU (Python via App Lab) |
| - Runs AI Object Detection (Glasses/Vest) |
| - Detects "Red Zone" Incursion |
| | |
| v (Arduino Bridge API triggers alert) |
| | |
| 2. STM32 MCU (C++ Sketch via App Lab) |
| - Receives "ALERT" signal |
| - Controls the Grove hardware pins |
+---------------------------------------------------+
| (Signals sent through Base Shield)
v
+---------------------------------------------------+
| GROVE BASE SHIELD V3 |
+---------------------------------------------------+
| | | |
(Port D2) (Port D3) (Port I2C) (Port D4)
| | | |
v v v v
[Grove LED] [Grove Buzzer] [Grove RGB LCD] [Grove Button]
(Visual Alert) (Audio Siren) (Text Warning) (Reset Input)
========================================================================
4. Step-by-Step Implementation Instructions
Step 1: Connect the Hardware
-
Unplug your UNO Q from power.
-
Align and press the Grove Base Shield V3 onto the top of the UNO Q.
-
Using the Grove cables, connect the Grove LED (with a Red bulb) to port D2.
-
Connect the Grove Buzzer to port D3.
-
Connect the Grove Button to port D4.
-
Connect the Grove RGB LCD to any of the I2C ports.
Step 2: Open Arduino App Lab
-
Connect the UNO Q to your computer via USB-C.
-
Launch Arduino App Lab.
-
Create a new "App". App Lab will open a dual-pane window. We will be working in the C++ Sketch pane, which controls the Base Shield hardware.
5. Coding Examples: Sketches for Each Sensor/Module
Below are the beginner-friendly C++ sketches for each individual module so you can understand how they work in isolation. Note: In App Lab, these are standard Arduino C++ commands.
A. The Visual Beacon (Grove LED)
// --- GROVE LED SKETCH ---
// This sketch flashes the LED to simulate an emergency beacon.
// 1. Define the pin where the LED is connected
const int ledPin = 2; // Port D2 on the Base Shield
void setup() {
// setup() runs once when the board turns on.
// We tell the UNO Q that the ledPin is an OUTPUT (sending electricity out)
pinMode(ledPin, OUTPUT);
}
void loop() {
// loop() runs over and over forever.
digitalWrite(ledPin, HIGH); // Turn the LED ON (HIGH = electricity flowing)
delay(500); // Wait for 500 milliseconds (half a second)
digitalWrite(ledPin, LOW); // Turn the LED OFF (LOW = no electricity)
delay(500); // Wait for 500 milliseconds
}
B. The Audio Siren (Grove Buzzer)
// --- GROVE BUZZER SKETCH ---
// This sketch sounds a repeating alarm tone.
const int buzzerPin = 3; // Port D3 on the Base Shield
void setup() {
pinMode(buzzerPin, OUTPUT); // The buzzer receives signals, so it's an OUTPUT
}
void loop() {
digitalWrite(buzzerPin, HIGH); // Turn buzzer ON (makes a loud beep)
delay(200); // Wait 0.2 seconds
digitalWrite(buzzerPin, LOW); // Turn buzzer OFF
delay(200); // Wait 0.2 seconds
}
C. The Status Display (Grove RGB LCD)
// --- GROVE RGB LCD SKETCH ---
// This sketch changes the screen color to Red and prints a warning.
// We need to include special libraries (instruction manuals) for the screen and I2C communication.
#include <Wire.h>
#include "rgb_lcd.h"
rgb_lcd lcd; // Create an LCD object to control the screen
void setup() {
// Initialize the screen: 16 columns and 2 rows of characters
lcd.begin(16, 2);
// Set the backlight color to RED (Red, Green, Blue values from 0-255)
lcd.setRGB(255, 0, 0);
// Print our warning message on the top row
lcd.print("! ALARM ACTIVE !");
// Move the invisible cursor to the start of the bottom row (column 0, row 1)
lcd.setCursor(0, 1);
lcd.print("RED ZONE BREACH");
}
void loop() {
// Nothing needs to loop here, the text stays on the screen!
}
D. The Alarm Reset (Grove Button)
// --- GROVE BUTTON SKETCH ---
// This sketch reads the physical world (sensor input) to check if a button is pressed.
const int buttonPin = 4; // Port D4 on the Base Shield
void setup() {
pinMode(buttonPin, INPUT); // The button sends data IN to the board
Serial.begin(9600); // Open a communication line to our computer screen
}
void loop() {
// Read the state of the button (HIGH = pressed, LOW = unpressed)
int buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
Serial.println("Reset Button Pressed!"); // Send a message to the computer
}
delay(100); // Small delay to prevent reading the button too fast
}
6. The Final Implementation: Bringing it All Together
In a real-world scenario on the UNO Q, the AI camera detects the missing safety glasses and flips an internal variable to true. Here is the combined App Lab C++ sketch that pulls all our modules together into one cohesive safety system!
// ====================================================================
// FULL SAFETY ALERT SYSTEM SKETCH (Arduino App Lab C++)
// ====================================================================
#include <Wire.h>
#include "rgb_lcd.h"
// Define Hardware Pins
const int ledPin = 2;
const int buzzerPin = 3;
const int buttonPin = 4;
// Initialize LCD
rgb_lcd lcd;
// This variable acts as our system state.
// In a full App Lab project, the Python AI script would change this variable
// via the Arduino Bridge when it detects a missing hardhat or Red Zone breach.
bool alarmTriggered = true;
void setup() {
// Configure Pins
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(buttonPin, INPUT);
// Start LCD and default to a Green "Safe" state
lcd.begin(16, 2);
setSafeState();
}
void loop() {
// Check if the operator pressed the reset button
int buttonState = digitalRead(buttonPin);
if (buttonState == HIGH && alarmTriggered == true) {
// If button pressed during an alarm, clear the alarm
alarmTriggered = false;
setSafeState();
}
// If the alarm is active, flash the lights and sound the buzzer
if (alarmTriggered == true) {
triggerAlarmCycle();
}
}
// Custom function to handle the "All Clear" state
void setSafeState() {
digitalWrite(ledPin, LOW); // Turn off LED
digitalWrite(buzzerPin, LOW); // Turn off Buzzer
lcd.setRGB(0, 255, 0); // Set LCD to Green
lcd.clear(); // Clear old text
lcd.print("SYSTEM SECURE"); // Print safe message
lcd.setCursor(0, 1);
lcd.print("Monitoring...");
}
// Custom function to handle the flashing/beeping of the alarm
void triggerAlarmCycle() {
// Set LCD to Red and display warning
lcd.setRGB(255, 0, 0);
lcd.setCursor(0, 0);
lcd.print("! SAFETY ALERT !");
lcd.setCursor(0, 1);
lcd.print("ZONE BREACH ");
// Flash ON
digitalWrite(ledPin, HIGH);
digitalWrite(buzzerPin, HIGH);
delay(300);
// Flash OFF
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
delay(300);
}
Conclusion
By utilizing the Grove Base Shield V3, we bypass complex wiring and focus strictly on logic and implementation. The dual architecture of the UNO Q allows the heavy lifting of AI detection to occur behind the scenes, seamlessly triggering our STM32 microcontroller to fire off real-world visual, auditory, and textual alerts using our Grove actuators.
I'd love to hear feedback from other challengers! Have any of you experimented with adding the Grove Smart Relay to actually shut down machinery during a Red Zone incursion?
Looking forward to your comments!