From 131e7e44074afe1d2c1d4ae620523b3558cef98b Mon Sep 17 00:00:00 2001 From: aurora Date: Wed, 22 Jul 2026 13:06:52 +0200 Subject: [PATCH] Add Library and Code --- Library-and-Code.md | 81 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Library-and-Code.md diff --git a/Library-and-Code.md b/Library-and-Code.md new file mode 100644 index 0000000..720f1d1 --- /dev/null +++ b/Library-and-Code.md @@ -0,0 +1,81 @@ +# Library and Code +The prototype firmware was developed using the Arduino IDE together with the ESP32 board support +package and the corresponding sensor libraries. Each sensor requires a specific library to simplify hardware +configuration, communication, and data acquisition. The following sections summarize the main software +components and execution flow for each supported sensor. + +## GP2Y1010AU0F Dust Sensor +### Required Libraries and Object Definitions +The GP2Y1010AU0F does not require a dedicated Arduino library because it provides an analog output. +The firmware uses the standard Arduino library: +``` +#include +``` +The sensor is accessed directly through an ADC-capable GPIO and a GPIO used to control the internal +infrared LED. +### Important Pin Definitions +The firmware defines: +* One ADC pin connected to the sensor output. +* One digital output pin connected to the LED control input. +These pins are initialized during the setup phase before measurements begin. + +### Data Processing +The ADC reading is converted into sensor voltage and then into an estimated dust concentration using the +calibration equation implemented in the firmware. The calculated value may be displayed on the Serial +Monitor or transmitted to another system. + +## LMV324-Based Sound Detector +### Required Libraries and Object Definitions +The Sound Detector also provides an analog output and therefore does not require a dedicated Arduino +library. +``` +#include +``` +### Important Pin Definitions +The firmware defines an ADC input connected to the module Envelope output. +### Data Acquisition +Sound intensity is measured using +``` +analogRead() +``` +which samples the analog voltage generated by the Sound Detector. +### Data Processing +The measured ADC value is converted into voltage and used as an indication of the detected sound level. +Since the module is not factory calibrated in dB SPL, the measured voltage represents relative sound +intensity. +## Sensirion SCD30 Sensor +### Required Libraries and Object Definitions +The SCD30 requires the following Arduino libraries: +``` +#include +#include +``` +The sensor object is created as: +``` +SensirionI2cScd30 scd30_sensor; +``` +### Important Pin Definitions +The I²C interface is configured using: +``` +#define I2C_SDA_PIN 20 +#define I2C_SCL_PIN 21 +``` +These GPIOs provide the SDA and SCL communication lines between the ESP32 and the SCD30. + +### Data Acquisition +The firmware first verifies that new data is available using: +``` +scd30_sensor.getDataReady() +``` +When data is ready, the measurements are retrieved using: +``` +scd30_sensor.readMeasurementData() +``` +### Data Processing +The library returns calibrated values directly in engineering units: +* CO₂ (ppm) +* Temperature (°C) +* Relative Humidity (%RH) +No additional ADC conversion or mathematical processing is required before the values are displayed or +transmitted. +