From 9f33e5a68b0013a1f1a7aa010e246616df74bf60 Mon Sep 17 00:00:00 2001 From: Alphara <42233094+xAlpharax@users.noreply.github.com> Date: Sat, 4 Nov 2023 15:45:12 +0000 Subject: Did some improvements, namely: - Researched some more about the pinouts - got mq135 to work with a workaround (because the library is complete CRAP) - Prepared to advance with the DSM for dust metrics - Hopefully a good enough collection of basic reads to comprise a comprehensive data bundle for the AI training, inference and public interest. --- images/ESP32 Pinout Diagram.png | Bin 0 -> 125943 bytes ...IT-DEVKIT-V1-Board-Pinout-36-GPIOs-updated.webp | Bin 52880 -> 0 bytes images/ESP32-Pinout-1.jpg | Bin 0 -> 61663 bytes .../MQ135_DHTxx_esp32_CRAP/MQ135_DHTxx_esp32.ino | 58 +++++++++++++++++++++ ...parts_per_mil_mq135_workaround_analog_esp32.ino | 10 ++++ 5 files changed, 68 insertions(+) create mode 100644 images/ESP32 Pinout Diagram.png delete mode 100644 images/ESP32-DOIT-DEVKIT-V1-Board-Pinout-36-GPIOs-updated.webp create mode 100644 images/ESP32-Pinout-1.jpg create mode 100644 learning_examples/MQ135_DHTxx_esp32_CRAP/MQ135_DHTxx_esp32.ino create mode 100644 learning_examples/parts_per_mil_mq135_workaround_analog_esp32/parts_per_mil_mq135_workaround_analog_esp32.ino diff --git a/images/ESP32 Pinout Diagram.png b/images/ESP32 Pinout Diagram.png new file mode 100644 index 0000000..eb0819d Binary files /dev/null and b/images/ESP32 Pinout Diagram.png differ diff --git a/images/ESP32-DOIT-DEVKIT-V1-Board-Pinout-36-GPIOs-updated.webp b/images/ESP32-DOIT-DEVKIT-V1-Board-Pinout-36-GPIOs-updated.webp deleted file mode 100644 index 6fd5c80..0000000 Binary files a/images/ESP32-DOIT-DEVKIT-V1-Board-Pinout-36-GPIOs-updated.webp and /dev/null differ diff --git a/images/ESP32-Pinout-1.jpg b/images/ESP32-Pinout-1.jpg new file mode 100644 index 0000000..9f041a6 Binary files /dev/null and b/images/ESP32-Pinout-1.jpg differ diff --git a/learning_examples/MQ135_DHTxx_esp32_CRAP/MQ135_DHTxx_esp32.ino b/learning_examples/MQ135_DHTxx_esp32_CRAP/MQ135_DHTxx_esp32.ino new file mode 100644 index 0000000..51b14f1 --- /dev/null +++ b/learning_examples/MQ135_DHTxx_esp32_CRAP/MQ135_DHTxx_esp32.ino @@ -0,0 +1,58 @@ +#include +#include + +/* MQ135 + DHT Temp Sensor + + Combination of the MQ135 air quality sensor and a DHT11/22 temperature sensor to accurately measure ppm values through the library correction. + Uses the Adafruit DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library + + Written by: https://github.com/NuclearPhoenixx/MQ135 +*/ + +#define PIN_MQ135 15 // MQ135 Analog Input Pin +#define DHTPIN 23 // DHT Digital Input Pin +#define DHTTYPE DHT11 // DHT11 or DHT22, depends on your sensor + +MQ135 mq135_sensor(PIN_MQ135); +DHT dht(DHTPIN, DHTTYPE); + +float temperature, humidity; // Temp and Humid floats, will be measured by the DHT + +void setup() { + Serial.begin(9600); + + dht.begin(); +} + +void loop() { + // Serial.println("aaaaaaaaaaaaaaaaaa"); + humidity = dht.readHumidity(); + temperature = dht.readTemperature(); + + // Check if any reads failed and exit early (to try again). + if (isnan(humidity) || isnan(temperature)) { + Serial.println(F("Failed to read from DHT sensor!")); + return; + } + + float rzero = mq135_sensor.getRZero(); + float correctedRZero = mq135_sensor.getCorrectedRZero(temperature, humidity); + float resistance = mq135_sensor.getResistance(); + float ppm = mq135_sensor.getPPM(); + float correctedPPM = mq135_sensor.getCorrectedPPM(temperature, humidity); + + Serial.print("MQ135 RZero: "); + Serial.print(rzero); + Serial.print("\t Corrected RZero: "); + Serial.print(correctedRZero); + Serial.print("\t Resistance: "); + Serial.print(resistance); + Serial.print("\t PPM: "); + Serial.print(ppm); + Serial.print("ppm"); + Serial.print("\t Corrected PPM: "); + Serial.print(correctedPPM); + Serial.println("ppm"); + + delay(300); +} \ No newline at end of file diff --git a/learning_examples/parts_per_mil_mq135_workaround_analog_esp32/parts_per_mil_mq135_workaround_analog_esp32.ino b/learning_examples/parts_per_mil_mq135_workaround_analog_esp32/parts_per_mil_mq135_workaround_analog_esp32.ino new file mode 100644 index 0000000..dc2ed08 --- /dev/null +++ b/learning_examples/parts_per_mil_mq135_workaround_analog_esp32/parts_per_mil_mq135_workaround_analog_esp32.ino @@ -0,0 +1,10 @@ +void setup() { + Serial.begin(9600); + // put your setup code here, to run once: + Serial.println("begin"); +} + +void loop() { + Serial.println(analogRead(15)); // ppm metrics (raw (i think)) + // put your main code here, to run repeatedly: +} -- cgit v1.2.3