Detect temperature changes with our Arduino-based Stroopwafel detection system, featuring sensors, an LCD display, and auditory/visual alert.
Software apps and online services
- Arduino IDE
Story
Introduction
This report details the functionalities and components of a Stroopwafel detection system implemented using an Arduino. The system uses various sensors and outputs to detect specific conditions and respond accordingly.
The primary components include a temperature sensor (LM35), a DHT11 temperature and humidity sensor, an LCD display, a buzzer, and an LED. Additionally, a linear regression model was used to validate the system's performance through multiple tests. I created a full video on this as well on YouTube where I go through the tests and ideas around the project.
Components and Setup
LCD Display (LiquidCrystal_I2C)
- Purpose: To display temperature readings.
- Pin Configuration: I2C address is set to 0x27 for a 16x2 character display.
- Initialization: Initialized in the setup() function and configured to display text at specific cursor positions.
Temperature Sensor (LM35)
- Purpose: To measure the ambient temperature.
- Pin Configuration: Connected to analog pin A3.
- Reading Mechanism: Analog readings are converted to voltage, then to temperature in Celsius.
DHT11 Sensor
- Purpose: To measure temperature and humidity.
- Pin Configuration: Connected to digital pin 2.
- Library Used: The DHT sensor library is used for easy interfacing.
- Reading Mechanism: Uses the library’s function to get temperature readings.
Buzz
- Purpose: To play a melody (Tetris theme) under certain conditions.
- Pin Configuration: Connected to analog pin A1.
- Functionality: The buzzer plays the Tetris theme using predefined note frequencies and durations.
LED
- Purpose: To indicate a condition visually.
- Functionality: Turns on when a certain number of serial messages are received.
- Pin Configuration: Connected to digital pin 13.
Purpose: To receive messages that trigger specific actions.
Configuration: Initialized at 9600 baud rate.
Code Functionality
Setup Function
- Initializes the LCD display, sets up the buzzer and LED pins, and waits for sensors to stabilize.
Loop Function
- Continuously reads temperatures from both the LM35 and DHT11 sensors.
- Displays these temperatures on the LCD.
- Checks for a 20% reduction in the initial temperature reading from the LM35 sensor and plays the Tetris theme if detected.
- Monitors the serial input for incoming messages, counting them, and triggers the buzzer and LED if more than 20 messages are received.
Temperature Reading Functions
- readTemperature(): Reads and converts the analog value from the LM35 sensor to a temperature value.
- readDHTTemperature(): Reads the temperature from the DHT11 sensor using its library functions.
Music Playback
- playTetrisTheme(): Contains the sequence of notes and durations for the Tetris theme. It plays the melody using the buzzer.
Serial Message Handling
- Counts the number of messages received via the serial port.
- If the count exceeds 20, the system plays the Tetris theme and blinks the LED for visual indication.
Web Cam Movement Detection system
This Python script uses OpenCV to capture video from a webcam and detect movement by comparing consecutive frames. When movement is detected, it sends a signal ('1') to an Arduino via serial communication at a baud rate of 9600. The script processes video frames in grayscale, applies Gaussian blur to reduce noise, computes the difference between frames, and uses contour detection to identify movement. This allows the Arduino to respond only when movement is detected, making the system efficient and responsive.
Testing and Validation
To ensure the accuracy and reliability of the detection system, a linear regression model was employed. The model was used to analyze data collected from multiple tests performed on a YouTube channel. The tests were conducted five times to monitor the system's response to the following conditions:
Temperature Reduction
- The system tracks the percentage change in temperature from an initial reading.
- A 20% reduction in temperature triggers the buzzer to play the Tetris theme.
Serial Message Count
- The system counts the number of serial messages received.
- Upon receiving more than 20 messages, the buzzer plays the Tetris theme and the LED blinks
results are shown below:
Conclusion
The Stroopwafel detection system is a multifaceted project combining temperature monitoring, user feedback via an LCD, and auditory/visual alerts. The integration of multiple sensors and outputs showcases the capability to create an interactive and responsive system. The core functionality is based on monitoring temperature changes and reacting to external inputs through serial communication, ensuring robust detection and alert mechanisms.
The use of a linear regression model to validate the system's performance adds a layer of reliability. By testing the code five times and analyzing the results, the system's effectiveness in detecting the specified conditions was confirmed. This rigorous testing approach ensures that the Stroopwafel detection system operates accurately and consistently in real-world applications. Full Video is available here
Schematics
arduino configuration
Code
This article was first published on Hackster on July 27, 2024
cr: https://www.hackster.io/eamonmagd/waffle-detection-system-the-perfect-time-to-leave-a-stroop-70a6cc
Author: Eamon Magd