Hi,
I am interfacing some sensors on Arduino uno. I encountered a problem with a LPS25 pressure sensor.
When i use the test code below, I can see the temperature and pressure reading in the serial monitor but when I include the two floating variable (Operator and result), the code don't want to compile and return the following error:
" no match for 'operator*' (operand types are 'sensors_event_t' and 'float') "
How to use those data ? What is going on? I am new to this.
thank you
// Basic demo for pressure readings from Adafruit LPS2X
#include <Wire.h>
#include <Adafruit_LPS2X.h>
#include <Adafruit_Sensor.h>
// For SPI mode, we need a CS pin
#define LPS_CS 8
// For software-SPI mode we need SCK/MOSI/MISO pins
#define LPS_SCK 12
#define LPS_MISO 11
#define LPS_MOSI 9
Adafruit_LPS2X lps;
float Operator; // The variable I put to try some math transformation
float result; // The variable I put to try some math transformation
void setup(void) {
Serial.begin(57600);
while (!Serial) delay(10);
Operator = 17.52; // Random value for testing
Serial.println("Adafruit LPS2X test!");
// Try to initialize!
//if (!lps.begin_I2C()) {
//if (!lps.begin_SPI(LPS_CS)) {
if (!lps.begin_SPI(LPS_CS, LPS_SCK, LPS_MISO, LPS_MOSI)) {
Serial.println("Failed to find LPS2X chip");
while (1) { delay(10); }
}
Serial.println("LPS2X Found!");
lps.setDataRate(LPS2X_RATE_1_HZ);
}
void loop() {
sensors_event_t temp;
sensors_event_t pressure;
lps.getEvent(&pressure, &temp);
result = temp * Operator / pressure; // This is the line that return the error message
Serial.print(temp);
Serial.print(" ");
Serial.print(pressure);
Serial.print(" ");
Serial.println(result);
delay(1000);
}