Indoor Air Quality Sensor Module

Dependents:   Sensor_iAQ_core Sensor_iAQ_sgp30_bme_si7051 POCBreath_V2_smd_commercial

Files at this revision

API Documentation at this revision

Comitter:
mcm
Date:
Fri Jun 08 15:59:01 2018 +0000
Parent:
1:9245bbbcbc40
Child:
3:53c56ce59c29
Commit message:
The driver is ready to be tested

Changed in this revision

iAQ_Core.cpp Show annotated file Show diff for this revision Revisions of this file
iAQ_Core.h Show annotated file Show diff for this revision Revisions of this file
--- a/iAQ_Core.cpp	Fri Jun 08 15:48:43 2018 +0000
+++ b/iAQ_Core.cpp	Fri Jun 08 15:59:01 2018 +0000
@@ -0,0 +1,76 @@
+/**
+ * @brief       iAQ_Core.c
+ * @details     Indoor air quality module, I2C interface.
+ *              Functions file.
+ *
+ *
+ * @return      N/A
+ *
+ * @author      Manuel Caballero
+ * @date        8/June/2018
+ * @version     8/June/2018    The ORIGIN
+ * @pre         N/A.
+ * @warning     N/A
+ * @pre         This code belongs to Nimbus Centre ( http://www.nimbus.cit.ie ).
+ */
+
+#include "iAQ_Core.h"
+
+
+iAQ_Core::iAQ_Core ( PinName sda, PinName scl, uint32_t addr )
+    : _i2c            ( sda, scl )
+    , _iAQ_Core_Addr  ( addr )
+{
+    _i2c.frequency( 100000 );
+}
+
+
+iAQ_Core::~iAQ_Core()
+{
+}
+
+
+
+/**
+ * @brief       iAQ_Core_GetNewReading ( iAQ_Core_vector_data_t* )
+ *
+ * @details     It performs a new parameters reading from the sensor.
+ *
+ * @param[in]    N/A
+ *
+ * @param[out]   myData:            All parameters: Prediction + Status Flag + Resistance + Tvoc.
+ *
+ *
+ * @return       Status of iAQ_Core_GetNewReading.
+ *
+ *
+ * @author      Manuel Caballero
+ * @date        8/June/2018
+ * @version     8/June/2018     The ORIGIN
+ * @pre         Measurement interval ( continuous ): 1s | Measurement interval ( pulsed ): Max. 11s.
+ * @warning     First functional reading after start up is 5 minutes.
+ */
+iAQ_Core::iAQ_Core_status_t  iAQ_Core::iAQ_Core_GetNewReading ( iAQ_Core_vector_data_t* myData )
+{
+    char     cmd[9]    =   { 0 };
+    uint32_t aux       =   0;
+
+
+    /* Get the data */
+    aux = _i2c.read ( _iAQ_Core_Addr, &cmd[0], sizeof( cmd )/sizeof( cmd[0] ) );
+
+
+    /* Update the parameters    */
+    myData->pred         =  ( ( cmd[0] << 8 ) + cmd[1] );                           // Prediction = ( byte0 * 2^8 ) + byte1
+    myData->status       =  ( iAQ_Core_status_flag_t )cmd[2];
+    myData->resistance   =  ( ( cmd[4] << 16 ) + ( cmd[5] << 8 ) + cmd[6] );        // Resistance = ( byte4 * 2^16 ) + ( byte5 * 2^8 ) + byte6
+    myData->Tvoc         =  ( ( cmd[7] << 8 ) + cmd[8] );                           // Tvoc       = ( byte7 * 2^8 ) + byte8
+
+
+
+
+    if ( aux == I2C_SUCCESS )
+        return   iAQ_Core_SUCCESS;
+    else
+        return   iAQ_Core_FAILURE;
+}
\ No newline at end of file
--- a/iAQ_Core.h	Fri Jun 08 15:48:43 2018 +0000
+++ b/iAQ_Core.h	Fri Jun 08 15:59:01 2018 +0000
@@ -87,9 +87,8 @@
       * @param sda     I2C data pin
       * @param scl     I2C clock pin
       * @param addr    I2C slave address
-      * @param freq    I2C frequency in Hz.
       */
-    iAQ_Core ( PinName sda, PinName scl, uint32_t addr, uint32_t freq );
+    iAQ_Core ( PinName sda, PinName scl, uint32_t addr );
 
     /** Delete iAQ_Core object.
      */