CLEON  Version 1
Cloud-Offloaded GPS Receiver
sys_sensors.c File Reference

Sensors related functions. More...

#include "cleon_conf.h"
#include "app_define.h"
#include "sys_define.h"
#include "hal_define.h"
#include "fs_define.h"
Include dependency graph for sys_sensors.c:

Go to the source code of this file.

Functions

void SYS_SENSORS_S1087_Init (void)
 Initializing light sensor S1087 (PAR)
 
unsigned int SYS_SENSORS_S1087_Read (void)
 Read sensor value of S1087 (PAR)
 
void SYS_SENSORS_S108701_Init (void)
 Initializing light sensor S1087-01 (TSR)
 
unsigned int SYS_SENSORS_S108701_Read (void)
 Read sensor value of S1087-01 (TSR)
 
void SYS_SENSORS_Init (void)
 Initializing sensors.
 
void SYS_SENSORS_SHT11_Init (void)
 Initializing SHT11 (Humidity & Temperature sensor)
 
unsigned int SYS_SENSORS_SHT11_ReadTemperature (void)
 Read SHT11 temperature.
 
unsigned int SYS_SENSORS_SHT11_ReadHumidity (void)
 Read SHT11 humidity.
 
void SYS_SENSORS_SHT11_On (void)
 Turn SHT11 on.
 
void SYS_SENSORS_SHT11_Off (void)
 Turn SHT11 off.
 
void SYS_SENSORS_SHT11_Start (void)
 Start SHT11.
 
void SYS_SENSORS_SHT11_Reset (void)
 Reset SHT11.
 
bool SYS_SENSORS_SHT11_Write (unsigned char ucCommand)
 Write to SHT11.
 
unsigned char SYS_SENSORS_SHT11_Read (bool bAckRequested)
 Read from SHT11.
 
unsigned int SYS_SENSORS_SHT11_Command (unsigned char ucCommand)
 Transmit command to SHT11.
 

Detailed Description

Sensors related functions.

Definition in file sys_sensors.c.

Function Documentation

void SYS_SENSORS_Init ( void  )

Initializing sensors.

Returns
void
Parameters
void

Definition at line 126 of file sys_sensors.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void SYS_SENSORS_S108701_Init ( void  )

Initializing light sensor S1087-01 (TSR)

Returns
void
Parameters
void

Definition at line 73 of file sys_sensors.c.

Here is the caller graph for this function:

unsigned int SYS_SENSORS_S108701_Read ( void  )

Read sensor value of S1087-01 (TSR)

Returns
void
Parameters
void

Definition at line 88 of file sys_sensors.c.

{
double dLight = 0;
// Sensor value (in 12-bit ADC-representation)
dLight = (double) ADC12MEM1;
// Voltage difference (in 12-bit ADC-representation) 3890
dLight = 4096 - dLight;
// For S1087-01, it gives 10nA upon sensing 1 lux
// It means that 5mV appears across 500k resistor
// Therefore, light intensity (lux) = Vsense (V) * 1 (lux) / 5m (V)
// That is, Vsense * 200;
dLight = dLight / 4096 * 2.88 * 200;
// Manually found calibration factor
dLight = dLight * 8;
#if (DEBUG_MODE) && (DUMP_SENSOR_VALUE_VIA_USB)
SYS_USB_Printf("Light2(TSR): %.4d \r\n", (unsigned int)dLight);
#endif
return (unsigned int) dLight;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SYS_SENSORS_S1087_Init ( void  )

Initializing light sensor S1087 (PAR)

Returns
void
Parameters
void

Definition at line 24 of file sys_sensors.c.

Here is the caller graph for this function:

unsigned int SYS_SENSORS_S1087_Read ( void  )

Read sensor value of S1087 (PAR)

Returns
void
Parameters
void

Definition at line 39 of file sys_sensors.c.

{
double dLight = 0;
// Sensor value (in 12-bit ADC-representation)
dLight = (double) ADC12MEM0;
// Voltage difference (in 12-bit ADC-representation)
dLight = 4096 - dLight;
// For S1087, it gives 1nA upon sensing 1 lux
// It means that 0.5mV appears across 500k resistor
// Therefore, light intensity (lux) = Vsense (V) * 1 (lux) / 0.5m (V)
// That is, Vsense * 2000;
dLight = dLight / 4096 * 2.88 * 2000;
#if (DEBUG_MODE) && (DUMP_SENSOR_VALUE_VIA_USB)
SYS_USB_Printf("Light1(PAR): %.4d \r\n", (unsigned int) dLight);
#endif
return (unsigned int) dLight;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int SYS_SENSORS_SHT11_Command ( unsigned char  ucCommand)

Transmit command to SHT11.

Returns
uiReceivedData - data received from SHT11 or FAIL if command is unsuccessful
Parameters
ucCommand- command to be transmitted

Definition at line 352 of file sys_sensors.c.

{
unsigned long n;
if(!SYS_SENSORS_SHT11_Write(ucCommand)) {
return _FAIL_;
}else{
for(n = 0; n < 250000; n++) {
#pragma diag_suppress = Pe550
unsigned char t0, t1, rcrc;
return (t0 << 8) | t1;
}
}
}
#pragma diag_suppress = Pe940
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SYS_SENSORS_SHT11_Init ( void  )

Initializing SHT11 (Humidity & Temperature sensor)

      - SHT11 requires 11ms after power on
Returns
void
Parameters
void

Definition at line 142 of file sys_sensors.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void SYS_SENSORS_SHT11_Off ( void  )

Turn SHT11 off.

Returns
void
Parameters
void

Definition at line 217 of file sys_sensors.c.

Here is the caller graph for this function:

void SYS_SENSORS_SHT11_On ( void  )

Turn SHT11 on.

Returns
void
Parameters
void

Definition at line 200 of file sys_sensors.c.

{
SENSOR_SHT11_PORT(OUT) &= ~(BV(SENSOR_SHT11_SDA_PIN) | BV(SENSOR_SHT11_SCL_PIN)); // Set pull-up register for DATA and SCK pins
SENSOR_SHT11_PORT(DIR) |= BV(SENSOR_SHT11_PWR_PIN) | BV(SENSOR_SHT11_SCL_PIN); // SHT11 power on & Set SCK pin as output
SHT11_TIMING_DELAY(20); // wait about 20ms for SHT11 stabilization
}

Here is the caller graph for this function:

unsigned char SYS_SENSORS_SHT11_Read ( bool  bAckRequested)

Read from SHT11.

Returns
ucReceivedData - data received from SHT11
Parameters
ucCommand- command to be transmitted

Definition at line 314 of file sys_sensors.c.

{
unsigned char ucReceivedData = 0x00;
for(int i = 0; i < 8; i++) {
ucReceivedData <<= 1;
ucReceivedData |= 0x1;
}
}
if(bAckRequested) {
}
return ucReceivedData;
}

Here is the caller graph for this function:

unsigned int SYS_SENSORS_SHT11_ReadHumidity ( void  )

Read SHT11 humidity.

Returns
void
Parameters
void

Definition at line 177 of file sys_sensors.c.

{
unsigned int uiRelativeHumidity = 0;
unsigned int uiHumidity = 0;
uiRelativeHumidity = SYS_SENSORS_SHT11_Command(MEASURE_HUMI);
uiHumidity = (unsigned int)( -4 + 0.0405 * uiRelativeHumidity - 2.8e-6 * (uiRelativeHumidity * uiRelativeHumidity));
#if (DEBUG_MODE) && (DUMP_SENSOR_VALUE_VIA_USB)
SYS_USB_Printf("Humidity : %.4d \r\n", (unsigned int) uiHumidity);
#endif
return uiHumidity;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int SYS_SENSORS_SHT11_ReadTemperature ( void  )

Read SHT11 temperature.

Returns
void
Parameters
void

Definition at line 155 of file sys_sensors.c.

{
unsigned int uiTemp = 0;
// Read temperature in Fahrenheit
uiTemp = (unsigned int) (-40.00 + 0.018 * SYS_SENSORS_SHT11_Command(MEASURE_TEMP));
#if (DEBUG_MODE) && (DUMP_SENSOR_VALUE_VIA_USB)
SYS_USB_Printf("Temp(F) : %.4d \r\n", (unsigned int) uiTemp);
#endif
return uiTemp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SYS_SENSORS_SHT11_Reset ( void  )

Reset SHT11.

Returns
void
Parameters
void

Definition at line 258 of file sys_sensors.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void SYS_SENSORS_SHT11_Start ( void  )

Start SHT11.

Returns
void
Parameters
void

Definition at line 232 of file sys_sensors.c.

Here is the caller graph for this function:

bool SYS_SENSORS_SHT11_Write ( unsigned char  ucCommand)

Write to SHT11.

Returns
bAck - return true if received OK otherwise false
Parameters
ucCommand- command to be transmitted

Definition at line 279 of file sys_sensors.c.

{
bool bAck;
for(int i = 0; i < 8; i++, ucCommand <<= 1) {
if(ucCommand & 0x80) {
}else{
}
}
return bAck;
}

Here is the caller graph for this function: