English
Language : 

SI7013EVB-UDP-M3L1 Datasheet, PDF (8/26 Pages) Silicon Laboratories – Si7013EVB-UDP-M3L1 Users Guide
Si7013EVB-UDP-M3L1
4. Source Code for the Demo Software
The source code for the demo software consists of six components:
Main
Sensor
Timeout
Button
LCD Driver
I2C Driver
4.1. Main
The Main component is the entry point for the demo software and it calls routines in the other components to run
the application. The Main component is implemented in the “main.c” file.
The main() routine calls enter_default_mode_from_reset() and Sensor_enter_default_mode_from_reset() to
initialize the hardware and to initialize the sensor. The main() routine then enters an infinite loop where it reads the
temperature and humidity from the sensor, and then displays them on the LCD.
The main component contains the PutTemperataure() and PutHumidity() routines which display the temperature
and humidity on the LCD.
4.2. Sensor
The Sensor component provides routines for reading temperature and humidity from a Si7013 device. The Sensor
component is implemented in the “mySensor_Si70xx.c” file.
The Sensor component provides the routines Sensor_ReadTemperature(), Sensor_ReadThermistor(), and
Sensor_ReadHumidity(). These routines call the Sensor_Measure() routine to take a measurement and return the
value from the Si7013's Data register. The Sensor_ReadTemperature() and Sensor_ReadThermistor() routines
convert the returned value to deci-degrees Celsius. The Sensor_ReadHumidity() routine converts the returned
value to deci-percent relative humidity.
The Si7013 must contain a thermistor correction coefficient table before the thermistor can be read. The Sensor
component contains the routines, Sensor_ReadCoefficient() and Sensor_WriteCoefficient(), for reading and writing
coefficients in the Si7013. The Sensor_enter_default_mode_from_reset() routine calls the
Sensor_ReadCoefficient() routine to check if the Si7013 contains the thermistor correction coefficient table. If the
table has not been programmed, the Sensor_enter_default_mode_from_reset() routine calls the
Sensor_WriteCoefficient() routine to write the coefficients to the Si7013. The coefficient table only needs to be
programmed once.
The Sensor component also provides the Sensor_Sleep() and Sensor_WakeUp() routines. These routines are now
needed by the Si7013 because the Si7013 automatically sleeps between commands.
The demo software does not use floating point numbers because the floating point library is large and slow. The
demo software avoids floating point numbers by using deci-units.
A deci-unit is one tenth of a unit. The Sensor_ReadHumidity() routine returns the humidity in deci-percent RH and
the Sensor_ReadTemperature() routine returns the temperature in deci-degrees Celsius. For example, 43.7
percent RH is 437 deci-percent RH. Likewise, 25.4 degrees Celsius is 254 deci-degrees Celsius.
The demo software uses equations that are derived from the equations in the Si7005 data sheet. The derived
equations are modified to use deci-units.
8
Rev. 0.2