151
edits
(draft) |
(wiring diagram + code) |
||
Line 1: | Line 1: | ||
=== Respiring Reflections === | === Respiring Reflections === | ||
This project is called "'''Respiring Reflections'''", a bubble machine which is connected with Pothos plants in an enclosed environment. Read below to follow the process and story behind the making of this project. | This project is called "'''Respiring Reflections'''", a bubble machine which is connected with Pothos plants (''Epipremnum aureum'') in an enclosed environment. Read below to follow the process and the story behind the making of this project. | ||
//TODO: insert pic | //TODO: insert pic | ||
Line 32: | Line 32: | ||
* Lots of cables... | * Lots of cables... | ||
=== Respiring Reflections - First Prototype === | === Wiring Diagram === | ||
[[File:The Plant Plant - Bubble Machine Wiring Diagram.png|none|thumb|400x400px|Bubble Machine Wiring Diagram]] | |||
During the process of making the bubble machine, unfortunately I fried my ESP32... I'm still not sure why, but perhaps it was due to false wiring. Thus I made this wiring diagram so that the wiring could be clear. I tried some free tools to make wiring diagram, such as but in the end I stick with EasyEDA to make this. The wiring diagram helps me a lot in reproducing the wiring I wanted to do, as well as to ask opinion from Christian or someone else for consultation. | |||
Since I wanted this installation to be a standalone one, I powered the ESP32 with the power suppy of 12 volts, through a buck converter of 5 volts, 1 Ampere. For this, I went to an electronics store in Erfurt (Bastlerland) and showed my wiring diagram for this project. The guy in that store recommended me this solution and I followed it. | |||
=== Code === | |||
To program the ESP32, I used Visual Studio Code with PlatformIO extension. Here are the codes I uploaded to the ESP32 to run the bubble machine: | |||
'''main.cpp:'''<syntaxhighlight lang="cpp"> | |||
#include <Arduino.h> | |||
#include <AccelStepper.h> // Load the AccelStepper library | |||
#include "MHZ19.h" | |||
#include <HardwareSerial.h> | |||
#define motorPin1 12 // IN1 pin on the ULN2003 driver | |||
#define motorPin2 14 // IN2 pin on the ULN2003 driver | |||
#define motorPin3 27 // IN3 pin on the ULN2003 driver | |||
#define motorPin4 26 // IN4 pin on the ULN2003 driver | |||
AccelStepper stepper(AccelStepper::HALF4WIRE, motorPin1, motorPin3, motorPin2, motorPin4); | |||
#define BAUDRATE 9600 | |||
/*CO2 sensor*/ | |||
#define RX_PIN 16 //wire green here (8) | |||
#define TX_PIN 17 //wire blue here (9) | |||
/*CO2 sensor variables*/ | |||
MHZ19 myMHZ19; | |||
HardwareSerial mySerial(2); | |||
unsigned long getDataTimer = 0; | |||
void verifyRange(int range); | |||
int CO2; | |||
int8_t Temp; | |||
int currentCategory = -1; // To store the current CO2 category | |||
int newCategory; | |||
void setup() { | |||
// put your setup code here, to run once: | |||
Serial.begin(9600); // initialize the serial monitor | |||
stepper.setMaxSpeed(1000.0); // set the max motor speed | |||
stepper.setSpeed(100); // set the current speed/initial speed | |||
mySerial.begin(BAUDRATE); // sensor serial | |||
/*CO2 sensor*/ | |||
myMHZ19.begin(mySerial); // pass to library | |||
myMHZ19.autoCalibration(); | |||
} | |||
void loop() { | |||
// put your main code here, to run repeatedly: | |||
stepper.runSpeed(); | |||
/*CO2 sensor and stepper motor speed logic*/ | |||
if (millis() - getDataTimer >= 250) //refresh rate: 250ms | |||
{ | |||
//int CO2; | |||
/* note: getCO2() default is command "CO2 Unlimited". This returns the correct CO2 reading even | |||
if below background CO2 levels or above range (useful to validate sensor). You can use the | |||
usual documented command with getCO2(false) */ | |||
CO2 = myMHZ19.getCO2(false); // Request CO2 (as ppm) | |||
Serial.print("CO2 (ppm): "); | |||
Serial.println(CO2); | |||
//int8_t Temp; | |||
Temp = myMHZ19.getTemperature(); // Request Temperature (as Celsius) | |||
Serial.print("Temperature (C): "); | |||
Serial.println(Temp); | |||
getDataTimer = millis(); | |||
// determine the category of CO2 | |||
if (CO2 < 900) { // lower threshold: 900 ppm | |||
newCategory = 0; // Low CO2 | |||
} else if (CO2 < 1000) { // higher threshold: 1000 ppm | |||
newCategory = 1; // Medium CO2 | |||
} else { | |||
newCategory = 2; // High CO2 | |||
} | |||
// switch category if the current category is no longer valid | |||
if (newCategory != currentCategory) { | |||
currentCategory = newCategory; | |||
switch (currentCategory) { | |||
case 0: | |||
stepper.setSpeed(100); // Slowest speed | |||
break; | |||
case 1: | |||
stepper.setSpeed(300); // Medium speed | |||
break; | |||
case 2: | |||
stepper.setSpeed(500); // Fastest speed | |||
break; | |||
} | |||
} | |||
} | |||
} | |||
</syntaxhighlight>'''platformio.ini:'''<syntaxhighlight lang="ini"> | |||
[env:esp32dev] | |||
platform = espressif32 | |||
board = esp32dev | |||
framework = arduino | |||
lib_deps = | |||
waspinator/AccelStepper@^1.64 | |||
wifwaf/MH-Z19@^1.5.4 | |||
</syntaxhighlight> | |||
=== Respiring Reflections - First Prototype and First Trials === | |||
For the bubble machine itself, all I needed was a fan, a rotating motor, bubble sticks and a container for the soap bubble liquid. To produce more soap bubbles, the motor needs to rotate faster. The bubble sticks need to dip into the soap bubble liquid and then they will pick up the soap liquid to be blown in front of a fan to produce bubbles. To test out this logic, I made the first prototype out of cardboard. This turned out to be helpful for consideration of measurements for the final prototype. Other than the bubble machine as a whole, I also did trials on the CO<sub>2</sub> sensor in the plants' enclosed environment and to determine the closeness of the bubble sticks to the fan to produce the bubbles. Through the trials, I found that the fan was strong enough to blow the bubbles only in specific areas, with a certain closeness. Therefore, I needed to consider and experiment with the distance and placement of the fan towards the rotating bubble sticks. | |||
//TODO: add pics of cardboard prototype + trials | |||
=== Respiring Reflections - Final Prototype (Winterwerkschau) === | === Respiring Reflections - Final Prototype (Winterwerkschau) === | ||
final prototype | final prototype | ||
=== Self-reflection === | === Self-reflection === |
edits