example program to demonstrate usage of sensirion ess with ublox-c030

Dependencies:   Sensirion ESS

Files at this revision

API Documentation at this revision

Comitter:
Haseeb Khalid
Date:
Fri Dec 21 17:41:16 2018 +0500
Commit message:
Example program to demonstrate the usage of sensirion-ess with ublox-c030

Changed in this revision

Sensirion-ESS.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 4fd0369caf7e Sensirion-ESS.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sensirion-ESS.lib	Fri Dec 21 17:41:16 2018 +0500
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/haseeb63/code/Sensirion-ESS/
diff -r 000000000000 -r 4fd0369caf7e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Dec 21 17:41:16 2018 +0500
@@ -0,0 +1,48 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2018 u-blox AG
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mbed.h"
+#include "sensirion_ess.h"
+I2C i2c(D14,D15);
+SensirionESS  sensirionESS(&i2c);
+int main()
+{
+	 printf("u-blox C030 Demo with Sensirion Environmental Sensor Shield\r\n");
+
+     if (sensirionESS.initSensors() != 0) {
+       printf("Error while initializing sensors: %s\n",sensirionESS.getError());
+       return -1;
+     }
+     sensirionESS.setLedRYG(1,1,1);
+     printf("Sensirion ESS initialized successfully..\r\n");
+     printf("Detected sensor %s on kit\r\n", sensirionESS.getProductType()  ? "SGPC3" : "SGP30");
+     wait(3);
+
+     while (1){
+         if (sensirionESS.measureIAQ() !=0){
+             printf("Error reading IAQ: %s\r\n",sensirionESS.getError());
+        	 return -1;
+         }
+         if (sensirionESS.measureRHT()!=0) {
+             printf("Error reading RHT: %s\n",sensirionESS.getError());
+        	 return -1;
+         }
+         printf("Temperature: %.2f		Humidity: %.2f\n"
+        		 "tVOC  Concentration: %.2fppb	CO2eq Concentration: %.2fppm\r\n",sensirionESS.getTemperature(),sensirionESS.getHumidity(),\
+				 sensirionESS.getTVOC(),sensirionESS.getECO2());
+         wait(1);
+     }
+}
diff -r 000000000000 -r 4fd0369caf7e mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Fri Dec 21 17:41:16 2018 +0500
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#6a0a86538c0b9b2bfcc4583b1e2b7fea8f4e71e9
\ No newline at end of file