Add auto-configuration for highest precision and new simpletest example

- Configure begin() for highest precision (128x oversampling, 200Hz rate)
- Enable temperature and pressure ready interrupts automatically
- Add simpletest example with data-driven updates
- Update library.properties with Adafruit Unified Sensor dependency

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ladyada 2025-08-26 20:53:24 -04:00
parent 5d58b347f9
commit 90888d0e86
3 changed files with 70 additions and 1 deletions

View file

@ -91,6 +91,18 @@ bool Adafruit_SPA06_003::begin(uint8_t i2c_addr, TwoWire *wire) {
return false;
}
// Configure for highest precision and sample rate
// Set pressure to highest oversampling (128x) and highest rate (200 Hz)
setPressureOversampling(SPA06_003_OVERSAMPLE_128);
setPressureMeasureRate(SPA06_003_RATE_200);
// Set temperature to highest oversampling (128x) and highest rate (200 Hz)
setTemperatureOversampling(SPA06_003_OVERSAMPLE_128);
setTemperatureMeasureRate(SPA06_003_RATE_200);
// Enable interrupts for temperature and pressure ready
setInterruptSource(false, true, true); // FIFO=false, temp_ready=true, pres_ready=true
// Set measurement mode to continuous both
setMeasurementMode(SPA06_003_MEAS_CONTINUOUS_BOTH);

View file

@ -0,0 +1,57 @@
/*!
* @file simpletest.ino
*
* A simple test for the SPA06_003 pressure and temperature sensor.
* This example shows basic pressure and temperature readings using the sensor.
*
* The begin() function automatically configures the sensor for:
* - Highest precision (128x oversampling)
* - Highest sample rate (200 Hz)
* - Continuous measurement mode
*
* Designed specifically to work with the Adafruit SPA06_003 Breakout
* ----> https://www.adafruit.com/products/xxxx
*
* These sensors use I2C to communicate, 2 pins are required to interface.
*
* Written by Limor 'ladyada' Fried with assistance from Claude Code
* for Adafruit Industries.
* MIT license, check license.txt for more information
* All text above must be included in any redistribution
*/
#include <Adafruit_SPA06_003.h>
Adafruit_SPA06_003 spa;
void setup() {
Serial.begin(115200);
while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("Adafruit SPA06_003 Simple Test");
// Try to initialize!
if (!spa.begin()) {
Serial.println("Failed to find SPA06_003 chip");
while (1) { delay(10); }
}
Serial.println("SPA06_003 Found!");
}
void loop() {
// Only read and print when new data is available
if (spa.isTempDataReady() || spa.isPresDataReady()) {
float temperature = spa.readTemperature();
float pressure = spa.readPressure();
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print(" °C");
Serial.print("\tPressure: ");
Serial.print(pressure);
Serial.println(" hPa");
}
delay(10); // Short delay to avoid overwhelming the sensor
}

View file

@ -7,4 +7,4 @@ paragraph=Arduino library for the SPA06_003 miniaturized digital barometric air
category=Sensors
url=https://github.com/adafruit/Adafruit_SPA06_003
architectures=*
depends=Adafruit BusIO
depends=Adafruit BusIO, Adafruit Unified Sensor