Some checks failed
Arduino Library CI / build (push) Has been cancelled
- Add hardware and software SPI interface support via BusIO - Implement FIFO test example with correct 23-bit sign extension fix - Add calculateTemperature() and calculatePressure() functions for raw data - Refactor existing read functions to use calculation functions - Fix SPI mode to MODE3 and rename fulltest example directory 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
60 lines
No EOL
1.6 KiB
C++
60 lines
No EOL
1.6 KiB
C++
/*!
|
|
* @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
|
|
} |