Difference between revisions of "MCU/SensorBox"

From ESS-WIKI
Jump to: navigation, search
Line 168: Line 168:
  
 
= How to porting new sensor into sensor box =
 
= How to porting new sensor into sensor box =
 +
<div style="margin-left:0.75cm;margin-right:0cm;">
 +
Content.
 +
</div>
 +
 +
== Add new configuration with the model name and sensor data ==
 +
= How to porting new sensor into sensor box =
 +
<div style="margin-left:0.75cm;margin-right:0cm;">
 +
When the user intends to add new sensor into sensor box, the user needs to find the configuration file "sensor_box.cfg" located at the folder "sensor_api/", then opens it and follows the below for how to do.<br/>
 +
</div>
 +
 +
== Add new configuration with the model name and sensor data ==
 +
<div style="margin-left:0.75cm;margin-right:0cm;">
 +
*For the model name:
 +
:Please based on naming rule of macro "SN_MN" + "DRIVER_FOLDER" define the model name.
 +
:#"SB_MN_" is fixed string as prefix.
 +
:#"DRIVER_FOLDER" is the directory of specified sensor driver and it's located at the directory of sensor driver.
 +
:For example as below:
 +
 +
:<syntaxhighlight lang="C">
 +
#define SB_MN_HDC1080              Hdc1080
 +
#define SB_MN_DS18B20              Ds18b20
 +
</syntaxhighlight>
 +
 +
*For the sensor data:
 +
:Please define the macro "SB_" + "DRIVER_FOLDER" + "_DATA" + N + "_NAME".
 +
:#"SB_" is fixed string as prefix.
 +
:#"DRIVER_FOLDER" is the directory of specified sensor driver and it's located at the directory of sensor driver.
 +
:#"_DATA" is fixed string.
 +
:#N is the serial number of this sensor.
 +
:#"_NAME" is fixed string as postfix.<div style="margin-left:0.75cm;margin-right:0cm;">
 +
Content.
 +
</div>
 +
 +
== Add new HAL instance ==
 +
<div style="margin-left:0.75cm;margin-right:0cm;">
 +
Content.
 +
</div>
 +
 +
== Add new sensor driver ==
 
<div style="margin-left:0.75cm;margin-right:0cm;">
 
<div style="margin-left:0.75cm;margin-right:0cm;">
 
Content.
 
Content.
 
</div>
 
</div>

Revision as of 07:47, 22 August 2019

Introduction

Sensor Box has general interface to collect sensor data and it benefits the user easy to use.

Architecture

Content.

Source tree

Content.

Directory Description
sensor_api The source code of API of Sensor Box.
sensor_driver The source code of sensor driver.
sensor_lib_cfg.sh The script used to configure which sensor we enable/disable.

Sensor list

Currently, these sensors are ported into sensor box as default.

  • HDC1080 - Digital Temperature/Humidity Sensor
Item Description
Vendor Texas Instruments
Interface I2C
Pin-defined Check

  • DS18B20 - 1-Wire Digital Thermometer
Item Description
Vendor Maxim
Interface GPIO
Pin-defined Check


  • VL53L0X - Time-of-Flight ranging sensor
Item Description
Vendor STMicroelectronics
Interface I2C
Pin-defined Check

  • HPMA215S0-XXX - Particle Sensor
Item Description
Vendor Honeywell
Interface I2C
Pin-defined Check


API

Content.

int SBox_iInit(void);
  • Brief
Initialize sensor box
  • Parameters
None
  • Return
On success, eSErr_None is returned.
On error, other is returned.


int SBox_iUnInit(void);
  • Brief
Uninitialize sensor box
  • Parameters
None
  • Return
On success, eSErr_None is returned.
On error, other is returned.


int SBox_iGetAllData(TSBDataFmt *_ptDataSet);
  • Brief
Update all sensors and get all data of sensors
  • Parameters
_ptDataSet: the pointer to data buffer that is used to get sensor data back.
  • Return
On success, eSErr_None is returned.
On error, other is returned.


int SBox_iGetData(int _iModelName, TSBDataFmt *_ptData);
  • Brief
Update only one sensor and get data
  • Parameters
_iModelName: the index of model name to specify which sensor will be updated.
_ptData: the pointer to data that is used to get sensor data back.
  • Return
On success, eSErr_None is returned.
On error, other is returned.



Get sensor box

Content.

Example

Content.

How to porting new sensor into sensor box

Content.

Add new configuration with the model name and sensor data

How to porting new sensor into sensor box

When the user intends to add new sensor into sensor box, the user needs to find the configuration file "sensor_box.cfg" located at the folder "sensor_api/", then opens it and follows the below for how to do.

Add new configuration with the model name and sensor data

  • For the model name:
Please based on naming rule of macro "SN_MN" + "DRIVER_FOLDER" define the model name.
  1. "SB_MN_" is fixed string as prefix.
  2. "DRIVER_FOLDER" is the directory of specified sensor driver and it's located at the directory of sensor driver.
For example as below:
#define SB_MN_HDC1080               Hdc1080
#define SB_MN_DS18B20               Ds18b20
  • For the sensor data:
Please define the macro "SB_" + "DRIVER_FOLDER" + "_DATA" + N + "_NAME".
  1. "SB_" is fixed string as prefix.
  2. "DRIVER_FOLDER" is the directory of specified sensor driver and it's located at the directory of sensor driver.
  3. "_DATA" is fixed string.
  4. N is the serial number of this sensor.
  5. "_NAME" is fixed string as postfix.

Content.

Add new HAL instance

Content.

Add new sensor driver

Content.

Retrieved from "https://ess-wiki.advantech.com.tw/wiki/index.php?title=MCU/SensorBox&oldid=17365"