example program to demonstrate usage of sensirion ess with ublox-c030
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2018 u-blox AG 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #include "mbed.h" 00018 #include "sensirion_ess.h" 00019 I2C i2c(D14,D15); 00020 SensirionESS sensirionESS(&i2c); 00021 int main() 00022 { 00023 printf("u-blox C030 Demo with Sensirion Environmental Sensor Shield\r\n"); 00024 00025 if (sensirionESS.initSensors() != 0) { 00026 printf("Error while initializing sensors: %s\n",sensirionESS.getError()); 00027 return -1; 00028 } 00029 sensirionESS.setLedRYG(1,1,1); 00030 printf("Sensirion ESS initialized successfully..\r\n"); 00031 printf("Detected sensor %s on kit\r\n", sensirionESS.getProductType() ? "SGPC3" : "SGP30"); 00032 wait(3); 00033 00034 while (1){ 00035 if (sensirionESS.measureIAQ() !=0){ 00036 printf("Error reading IAQ: %s\r\n",sensirionESS.getError()); 00037 return -1; 00038 } 00039 if (sensirionESS.measureRHT()!=0) { 00040 printf("Error reading RHT: %s\n",sensirionESS.getError()); 00041 return -1; 00042 } 00043 printf("Temperature: %.2f Humidity: %.2f\n" 00044 "tVOC Concentration: %.2fppb CO2eq Concentration: %.2fppm\r\n",sensirionESS.getTemperature(),sensirionESS.getHumidity(),\ 00045 sensirionESS.getTVOC(),sensirionESS.getECO2()); 00046 wait(1); 00047 } 00048 }
Generated on Fri Jul 15 2022 11:25:11 by
1.7.2