(add text) |
(add todos and pseudocodes) |
||
Line 14: | Line 14: | ||
* Power supply 12 volts | * Power supply 12 volts | ||
* Lots of cables... | * Lots of cables... | ||
== To-Do List == | |||
* Implement stepper motor speed with AccelStepper library (based on category (CO<sub>2</sub> value)) (s. Pseudocode below) | |||
* Stabilize bubble rings holder to the stepper motor | |||
* For better and more directed air flow: add nozzle/funnel? | |||
* Make wiring diagram | |||
* Documentation | |||
== Pseudocode == | |||
Idea: assign CO<sub>2</sub> value into 3 categories; '''Low, Medium, High''' and adjust the stepper motor speed based on the category.<syntaxhighlight lang="arduino"> | |||
DEFINE constants for CO2 thresholds: | |||
LOW_MEDIUM_THRESHOLD = 500 //to be determined via trials | |||
MEDIUM_HIGH_THRESHOLD = 700 //to be determined via trials | |||
DEFINE speed settings for each category: | |||
LOW_SPEED = 400 // Steps per second | |||
MEDIUM_SPEED = 800 // Steps per second | |||
HIGH_SPEED = 1200 // Steps per second | |||
INITIALIZE variable currentCategory to -1 | |||
INITIALIZE variable lastCategory to -1 | |||
FUNCTION setup(): | |||
BEGIN | |||
SET maximum speed for stepper motor (e.g., 1200 steps/sec) | |||
SET acceleration for smoother operation (e.g., 500 steps/sec^2) | |||
START serial communication for debugging | |||
END | |||
FUNCTION loop(): | |||
BEGIN | |||
READ CO2 value from the sensor (variable CO2) | |||
DETERMINE currentCategory: | |||
IF CO2 < LOW_MEDIUM_THRESHOLD: | |||
SET currentCategory to LOW | |||
ELSE IF CO2 < MEDIUM_HIGH_THRESHOLD: | |||
SET currentCategory to MEDIUM | |||
ELSE: | |||
SET currentCategory to HIGH | |||
IF currentCategory is different from lastCategory: | |||
BEGIN | |||
SWITCH currentCategory: | |||
CASE LOW: | |||
SET stepper motor speed to LOW_SPEED | |||
CASE MEDIUM: | |||
SET stepper motor speed to MEDIUM_SPEED | |||
CASE HIGH: | |||
SET stepper motor speed to HIGH_SPEED | |||
UPDATE lastCategory to currentCategory | |||
END | |||
RUN stepper motor at the current speed (use AccelStepper's runSpeed() function) | |||
END | |||
</syntaxhighlight>Idea to determine thresholds: run trials on plants enclosed environment.<syntaxhighlight lang="arduino"> | |||
DEFINE variables: | |||
minCO2 = Infinity // Initialize to a very high value | |||
maxCO2 = -Infinity // Initialize to a very low value | |||
startTime = CURRENT_TIME | |||
trialDuration = 30 minutes (in milliseconds, e.g., 30 * 60 * 1000) | |||
FUNCTION setup(): | |||
BEGIN | |||
INITIALIZE serial communication for debugging | |||
INITIALIZE CO2 sensor | |||
PRINT "Starting 30-minute CO2 trial..." | |||
END | |||
FUNCTION loop(): | |||
BEGIN | |||
WHILE (CURRENT_TIME - startTime) < trialDuration: | |||
BEGIN | |||
READ current CO2 value from sensor (variable currentCO2) | |||
IF currentCO2 < minCO2: | |||
UPDATE minCO2 to currentCO2 | |||
IF currentCO2 > maxCO2: | |||
UPDATE maxCO2 to currentCO2 | |||
PRINT currentCO2, minCO2, and maxCO2 to serial monitor | |||
WAIT for 1 second //reduce sampling frequency | |||
END | |||
PRINT "Trial Complete." | |||
PRINT minCO2 and maxCO2 to serial monitor | |||
CALCULATE range = maxCO2 - minCO2 | |||
CALCULATE lowMediumThreshold = minCO2 + (range / 3) | |||
CALCULATE mediumHighThreshold = minCO2 + (2 * range / 3) | |||
PRINT "Thresholds:" | |||
PRINT "Low-Medium Threshold: " + lowMediumThreshold | |||
PRINT "Medium-High Threshold: " + mediumHighThreshold | |||
END | |||
</syntaxhighlight> | |||
== Gallery == | == Gallery == |
Revision as of 11:44, 19 December 2024
Project idea: https://miro.com/app/board/uXjVLBm7F8w=/?share_link_id=117991010729
Motivation
In order to observe my houseplants' respiration, a prototype of (soap) bubble maker machine is being developed. The quantity of (soap) bubbles will be in accordance to the CO2 level of the plants' (closed) environment.
Materials
- ESP32
- CO2 sensor MH-Z19C
- Stepper motor 28BYJ-48
- Stepper motor driver module ULN2003
- PWM fan AMD Ryzen 7 1700
- 10kΩ resistor
- Power supply 12 volts
- Lots of cables...
To-Do List
- Implement stepper motor speed with AccelStepper library (based on category (CO2 value)) (s. Pseudocode below)
- Stabilize bubble rings holder to the stepper motor
- For better and more directed air flow: add nozzle/funnel?
- Make wiring diagram
- Documentation
Pseudocode
Idea: assign CO2 value into 3 categories; Low, Medium, High and adjust the stepper motor speed based on the category.
DEFINE constants for CO2 thresholds:
LOW_MEDIUM_THRESHOLD = 500 //to be determined via trials
MEDIUM_HIGH_THRESHOLD = 700 //to be determined via trials
DEFINE speed settings for each category:
LOW_SPEED = 400 // Steps per second
MEDIUM_SPEED = 800 // Steps per second
HIGH_SPEED = 1200 // Steps per second
INITIALIZE variable currentCategory to -1
INITIALIZE variable lastCategory to -1
FUNCTION setup():
BEGIN
SET maximum speed for stepper motor (e.g., 1200 steps/sec)
SET acceleration for smoother operation (e.g., 500 steps/sec^2)
START serial communication for debugging
END
FUNCTION loop():
BEGIN
READ CO2 value from the sensor (variable CO2)
DETERMINE currentCategory:
IF CO2 < LOW_MEDIUM_THRESHOLD:
SET currentCategory to LOW
ELSE IF CO2 < MEDIUM_HIGH_THRESHOLD:
SET currentCategory to MEDIUM
ELSE:
SET currentCategory to HIGH
IF currentCategory is different from lastCategory:
BEGIN
SWITCH currentCategory:
CASE LOW:
SET stepper motor speed to LOW_SPEED
CASE MEDIUM:
SET stepper motor speed to MEDIUM_SPEED
CASE HIGH:
SET stepper motor speed to HIGH_SPEED
UPDATE lastCategory to currentCategory
END
RUN stepper motor at the current speed (use AccelStepper's runSpeed() function)
END
Idea to determine thresholds: run trials on plants enclosed environment.
DEFINE variables:
minCO2 = Infinity // Initialize to a very high value
maxCO2 = -Infinity // Initialize to a very low value
startTime = CURRENT_TIME
trialDuration = 30 minutes (in milliseconds, e.g., 30 * 60 * 1000)
FUNCTION setup():
BEGIN
INITIALIZE serial communication for debugging
INITIALIZE CO2 sensor
PRINT "Starting 30-minute CO2 trial..."
END
FUNCTION loop():
BEGIN
WHILE (CURRENT_TIME - startTime) < trialDuration:
BEGIN
READ current CO2 value from sensor (variable currentCO2)
IF currentCO2 < minCO2:
UPDATE minCO2 to currentCO2
IF currentCO2 > maxCO2:
UPDATE maxCO2 to currentCO2
PRINT currentCO2, minCO2, and maxCO2 to serial monitor
WAIT for 1 second //reduce sampling frequency
END
PRINT "Trial Complete."
PRINT minCO2 and maxCO2 to serial monitor
CALCULATE range = maxCO2 - minCO2
CALCULATE lowMediumThreshold = minCO2 + (range / 3)
CALCULATE mediumHighThreshold = minCO2 + (2 * range / 3)
PRINT "Thresholds:"
PRINT "Low-Medium Threshold: " + lowMediumThreshold
PRINT "Medium-High Threshold: " + mediumHighThreshold
END
Gallery
The Plant Plant Gallery (Nextcloud Bauhaus Uni), Password: theplantplant (CO2 sensor first trial pictures are inside)
References
CO2 sensor MH-Z19C
- https://www.neumueller.com/datenblatt/neumueller/MH-Z19C.pdf (Datasheet)
- https://randomnerdtutorials.com/esp32-uart-communication-serial-arduino/ (Concept, wiring, code)
PWM fan AMD Ryzen 7 1700
- Arduino Fan Control using High Frequency 25kHz PWM // 4-Wire CPU Fans - YouTube (Concept, wiring, code); adapted to ESP32
Stepper motor 28BYJ-48 and stepper motor driver module ULN2003
- https://randomnerdtutorials.com/esp8266-nodemcu-stepper-motor-28byj-48-uln2003/ (Concept, wiring, code); adapted to own implementation