First Commit

This commit is contained in:
MindCreeper03
2025-02-27 19:31:50 +01:00
parent bcbb6aff9a
commit e490df1715
2470 changed files with 1479965 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
// Basic demo for readings from Adafruit SCD30
#include <Adafruit_SCD30.h>
Adafruit_SCD30 scd30;
void setup(void) {
Serial.begin(115200);
while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("Adafruit SCD30 test!");
// Try to initialize!
if (!scd30.begin()) {
Serial.println("Failed to find SCD30 chip");
while (1) { delay(10); }
}
Serial.println("SCD30 Found!");
// if (!scd30.setMeasurementInterval(10)){
// Serial.println("Failed to set measurement interval");
// while(1){ delay(10);}
// }
Serial.print("Measurement Interval: ");
Serial.print(scd30.getMeasurementInterval());
Serial.println(" seconds");
}
void loop() {
if (scd30.dataReady()){
Serial.println("Data available!");
if (!scd30.read()){ Serial.println("Error reading sensor data"); return; }
Serial.print("Temperature: ");
Serial.print(scd30.temperature);
Serial.println(" degrees C");
Serial.print("Relative Humidity: ");
Serial.print(scd30.relative_humidity);
Serial.println(" %");
Serial.print("CO2: ");
Serial.print(scd30.CO2, 3);
Serial.println(" ppm");
Serial.println("");
} else {
//Serial.println("No data");
}
delay(100);
}

View File

@@ -0,0 +1,76 @@
// A simple CO2 meter using the Adafruit SCD30 breakout and the Adafruit 128x32 OLEDs
#include <Adafruit_SCD30.h>
#include <Adafruit_SSD1306.h>
Adafruit_SCD30 scd30;
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &Wire);
void setup(void) {
Serial.begin(115200);
while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("SCD30 OLED CO2 meter!");
// Try to initialize!
if (!scd30.begin()) {
Serial.println("Failed to find SCD30 chip");
while (1) { delay(10); }
}
Serial.println("SCD30 Found!");
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
if (!scd30.setMeasurementInterval(2)){
Serial.println("Failed to set measurement interval");
while(1) {delay(10);}
}
Serial.print("Measurement Interval: ");
Serial.print(scd30.getMeasurementInterval());
Serial.println(" seconds");
display.display();
delay(500); // Pause for half second
display.setTextSize(2);
display.setTextColor(WHITE);
display.setRotation(0);
}
void loop() {
if (scd30.dataReady()) {
display.clearDisplay();
display.setCursor(0,0);
display.setTextSize(2);
Serial.println("Data available!");
if (!scd30.read()){
Serial.println("Error reading sensor data");
display.println("READ ERR");
display.display();
return;
}
Serial.print("CO2: ");
Serial.print(scd30.CO2, 3);
Serial.println(" ppm");
Serial.println("");
display.println("CO2:");
display.print(scd30.CO2, 2);
display.setTextSize(1);
display.setCursor(100, 20);
display.println(" ppm");
display.display();
}
delay(100);
}

View File

@@ -0,0 +1,133 @@
// Demo of the available settings for the SCD30
#include <Adafruit_SCD30.h>
Adafruit_SCD30 scd30;
void setup(void) {
Serial.begin(115200);
while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("Adafruit SCD30 Sensor adjustment test!");
// Try to initialize!
if (!scd30.begin()) {
Serial.println("Failed to find SCD30 chip");
while (1) { delay(10); }
}
Serial.println("SCD30 Found!");
/***
* The code below will report the current settings for each of the
* settings that can be changed. To see how they work, uncomment the setting
* code above a status message and adjust the value
*
* **Note:** Since Automatic self calibration and forcing recalibration with
* a reference value overwrite each other, you should only set one or the other
***/
/*** Adjust the rate at which measurements are taken, from 2-1800 seconds */
// if (!scd30.setMeasurementInterval(5)) {
// Serial.println("Failed to set measurement interval");
// while(1){ delay(10);}
// }
Serial.print("Measurement interval: ");
Serial.print(scd30.getMeasurementInterval());
Serial.println(" seconds");
/*** Restart continuous measurement with a pressure offset from 700 to 1400 millibar.
* Giving no argument or setting the offset to 0 will disable offset correction
*/
// if (!scd30.startContinuousMeasurement(15)){
// Serial.println("Failed to set ambient pressure offset");
// while(1){ delay(10);}
// }
Serial.print("Ambient pressure offset: ");
Serial.print(scd30.getAmbientPressureOffset());
Serial.println(" mBar");
/*** Set an altitude offset in meters above sea level.
* Offset value stored in non-volatile memory of SCD30.
* Setting an altitude offset will override any pressure offset.
*/
// if (!scd30.setAltitudeOffset(110)){
// Serial.println("Failed to set altitude offset");
// while(1){ delay(10);}
// }
Serial.print("Altitude offset: ");
Serial.print(scd30.getAltitudeOffset());
Serial.println(" meters");
/*** Set a temperature offset in hundredths of a degree celcius.
* Offset value stored in non-volatile memory of SCD30.
*/
// if (!scd30.setTemperatureOffset(1984)){ // 19.84 degrees celcius
// Serial.println("Failed to set temperature offset");
// while(1){ delay(10);}
// }
Serial.print("Temperature offset: ");
Serial.print((float)scd30.getTemperatureOffset()/100.0);
Serial.println(" degrees C");
/*** Force the sensor to recalibrate with the given reference value
* from 400-2000 ppm. Writing a recalibration reference will overwrite
* any previous self calibration values.
* Reference value stored in non-volatile memory of SCD30.
*/
// if (!scd30.forceRecalibrationWithReference(400)){
// Serial.println("Failed to force recalibration with reference");
// while(1) { delay(10); }
// }
Serial.print("Forced Recalibration reference: ");
Serial.print(scd30.getForcedCalibrationReference());
Serial.println(" ppm");
/*** Enable or disable automatic self calibration (ASC).
* Parameter stored in non-volatile memory of SCD30.
* Enabling self calibration will override any previously set
* forced calibration value.
* ASC needs continuous operation with at least 1 hour
* 400ppm CO2 concentration daily.
*/
// if (!scd30.selfCalibrationEnabled(true)){
// Serial.println("Failed to enable or disable self calibration");
// while(1) { delay(10); }
// }
if (scd30.selfCalibrationEnabled()) {
Serial.print("Self calibration enabled");
} else {
Serial.print("Self calibration disabled");
}
Serial.println("\n\n");
}
void loop() {
if (scd30.dataReady()) {
if (!scd30.read()){
Serial.println("Error reading sensor data");
return;
}
Serial.print("Temperature: ");
Serial.print(scd30.temperature);
Serial.println(" degrees C");
Serial.print("Relative Humidity: ");
Serial.print(scd30.relative_humidity);
Serial.println(" %");
Serial.print("CO2: ");
Serial.print(scd30.CO2, 3);
Serial.println(" ppm");
Serial.println("");
}
delay(100);
}

View File

@@ -0,0 +1,45 @@
// Unified sensor demo for readings from Adafruit SCD30
#include <Adafruit_SCD30.h>
#include <Adafruit_Sensor.h>
Adafruit_SCD30 scd30;
void setup(void) {
Serial.begin(115200);
while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("Adafruit SCD30 Temperature and humidity unified sensor test!");
// Try to initialize!
if (!scd30.begin()) {
Serial.println("Failed to find SCD30 chip");
while (1) { delay(10); }
}
Serial.println("SCD30 Found!");
}
void loop() {
if(scd30.dataReady()){
Serial.println("Data available!");
sensors_event_t temp;
sensors_event_t humidity;
if (!scd30.getEvent(&humidity, &temp)){
Serial.println("Error reading sensor data");
return;
}
Serial.print("Temperature: ");
Serial.print(temp.temperature);
Serial.println(" degrees C");
Serial.print("Relative Humidity: ");
Serial.print(humidity.relative_humidity);
Serial.println(" %");
Serial.println("");
}
delay(100);
}