Hey guys!
Ive got a mind blank that I figure someone could maybe help me out with:
Im working on a project that detects rapid air pressure changes using a BME280 and would "trigger" an external device to "do something" for a film prop whenever it detects a spike. Ive posted a screenshot and some descriptors that would describe when I want it to trigger.
I cant work out a good way of filtering this to get a "fire now" case. If I just go "fire after the sensor detects higher than this number" it would be unstable with any drift (and i'm getting a bit over time). If I also said just detect the next highest value in a time array of the graph, then I would get 2 firing points from the peak rising and falling. Also this has to be real-time, or close too.
I might have over explained it a bit, my apologies.
Any ideas? It doesn't have to happen immediately at the peak, but somewhere close.
Here is my current code ("val" in the loop being the number I'm sampling to get the spikes):
#include <Wire.h>
#include "BlueDot_BME280.h"
BlueDot_BME280 bme280 = BlueDot_BME280();
//
//
void setup() {
Serial.begin(250000);
//0: Set to 0 for I2C (default value)
//1: Set to 1 for Software SPI
//2: Set to 2 for Hardware SPI
bme280.parameter.communication = 0; //Choose communication protocol
bme280.parameter.I2CAddress = 0x76; //Choose I2C Address
//Set the pins for SPI Communication
//Or ignore this, if you're using I2C Communication instead
bme280.parameter.SPI_cs = 10; //Are you using either Software SPI or Hardware SPI? Then you need to define the Chip Select Pin.
bme280.parameter.SPI_mosi = 13; //If you are using Software SPI, then you need to define the MOSI line. For Hardware SPI you can leave this line commented.
bme280.parameter.SPI_miso = 11; //If you are using Software SPI, then you need to define the MISO line. Just comment this out for Hardware SPI.
bme280.parameter.SPI_sck = 12; //If you are using Software SPI, then you need to define the SCK line. Same as before. For Hardware SPI, just comment this out.
//0b00: In sleep mode no measurements are performed, but power consumption is at a minimum
//0b01: In forced mode a single measured is performed and the device returns automatically to sleep mode
//0b11: In normal mode the sensor measures continually (default value)
bme280.parameter.sensorMode = 0b11; //Choose sensor mode
//0b000: factor 0 (filter off)
//0b001: factor 2
//0b010: factor 4
//0b011: factor 8
//0b100: factor 16 (default value)
bme280.parameter.IIRfilter = 0b000; //Setup for IIR Filter
//0b000: factor 0 (Disable humidity measurement)
//0b001: factor 1
//0b010: factor 2
//0b011: factor 4
//0b100: factor 8
//0b101: factor 16 (default value)
bme280.parameter.humidOversampling = 0b000; //Setup Humidity Oversampling
//0b000: factor 0 (Disable temperature measurement)
//0b001: factor 1
//0b010: factor 2
//0b011: factor 4
//0b100: factor 8
//0b101: factor 16 (default value)
bme280.parameter.tempOversampling = 0b000; //Setup Temperature Ovesampling
//0b000: factor 0 (Disable pressure measurement)
//0b001: factor 1
//0b010: factor 2
//0b011: factor 4
//0b100: factor 8
//0b101: factor 16 (default value)
bme280.parameter.pressOversampling = 0b001; //Setup Pressure Oversampling
if (bme280.init() != 0x60)
while(1);
}
void loop() {
float mesure_2 = bme280.readPressure();
delayMicroseconds(500);
float mesure_1 = bme280.readPressure();
float val = 0;
val = (mesure_2 * mesure_1);
Serial.println(val);
}
A screenshot of the spikes id like it to fire on attached.
Cheers!
Tim
