From cfa844f0877ce72dd17a0bf89d418631573af070 Mon Sep 17 00:00:00 2001 From: Bilal Hassan <bilal.hassan@student.uibk.ac.at> Date: Tue, 2 Aug 2022 11:53:06 +0200 Subject: [PATCH] small improvments --- client/client/.gitignore | 1 - client/client/.gitkeep | 0 client/client/lib/scd30/scd30.cpp | 17 ++++++++++++----- client/client/lib/scd30/scd30.hpp | 2 ++ client/client/src/main.cpp | 22 ++++++++++++++++++++++ 5 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 client/client/.gitkeep diff --git a/client/client/.gitignore b/client/client/.gitignore index 6dea820..89cc49c 100644 --- a/client/client/.gitignore +++ b/client/client/.gitignore @@ -3,4 +3,3 @@ .vscode/c_cpp_properties.json .vscode/launch.json .vscode/ipch -!lib/ diff --git a/client/client/.gitkeep b/client/client/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/client/client/lib/scd30/scd30.cpp b/client/client/lib/scd30/scd30.cpp index 326de88..5a27e24 100644 --- a/client/client/lib/scd30/scd30.cpp +++ b/client/client/lib/scd30/scd30.cpp @@ -11,9 +11,16 @@ void Forte_SCD30 :: setup(){ } float* Forte_SCD30 :: read_data(){ - float data[3]; - data[0] = airSensor.getCO2(); - data[1] = airSensor.getTemperature(); - data[2] = airSensor.getHumidity(); - return data; + + + if(airSensor.dataAvailable()==true) + { + data[0] = airSensor.getCO2(); + data[1] = airSensor.getTemperature(); + data[2] = airSensor.getHumidity(); + return data; + } +else + return 0; + } \ No newline at end of file diff --git a/client/client/lib/scd30/scd30.hpp b/client/client/lib/scd30/scd30.hpp index 396e311..cdcf377 100644 --- a/client/client/lib/scd30/scd30.hpp +++ b/client/client/lib/scd30/scd30.hpp @@ -4,6 +4,7 @@ #include <pinout.hpp> #include <SparkFun_SCD30_Arduino_Library.h> + class Forte_SCD30 : public Forte_Sensor{ public: void setup(); @@ -11,6 +12,7 @@ class Forte_SCD30 : public Forte_Sensor{ private: SCD30 airSensor; + float data[3]; }; #endif \ No newline at end of file diff --git a/client/client/src/main.cpp b/client/client/src/main.cpp index 58b344c..4426128 100644 --- a/client/client/src/main.cpp +++ b/client/client/src/main.cpp @@ -1,9 +1,31 @@ #include <Arduino.h> +#include <scd30.hpp> + +Forte_SCD30 sensor1; //without adding frte_sensor + to the local lib/scd30 i error appears void setup() { // put your setup code here, to run once: + Serial.begin(9600); + sensor1.setup(); + } void loop() { // put your main code here, to run repeatedly: + + float* data; + + data=sensor1.read_data(); + if(data!=0) + { + Serial.println("C02"); Serial.println(data[0]); + Serial.println("Temperatur"); Serial.println(data[1]); + Serial.println("Humidity"); Serial.println(data[2]); + Serial.println(); + } + else + Serial.println("waiting for data"); + + delay(3000); + } \ No newline at end of file -- GitLab