|
@@ -9,7 +9,6 @@
|
|
|
*/
|
|
*/
|
|
|
#include <rtthread.h>
|
|
#include <rtthread.h>
|
|
|
#include <board.h>
|
|
#include <board.h>
|
|
|
-#include <sht3x.h>
|
|
|
|
|
#include "sht30_collect.h"
|
|
#include "sht30_collect.h"
|
|
|
#include <string.h>
|
|
#include <string.h>
|
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
@@ -130,45 +129,10 @@ int UART_485_INIT(void)
|
|
|
/* 入口函数 */
|
|
/* 入口函数 */
|
|
|
static void sht30_collect_thread_entry(void *parameter)
|
|
static void sht30_collect_thread_entry(void *parameter)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
- sht3x_device_t sht3x_device;
|
|
|
|
|
static int checklightnum = 0;
|
|
static int checklightnum = 0;
|
|
|
static int checknightnum = 0;
|
|
static int checknightnum = 0;
|
|
|
- sht3x_device = sht3x_init("i2c1", 0x44);
|
|
|
|
|
- //此处需要短暂的延时,否则会出现连续读取失败的问题
|
|
|
|
|
- rt_thread_mdelay(150);
|
|
|
|
|
while (1)
|
|
while (1)
|
|
|
{
|
|
{
|
|
|
- if(sht3x_device)
|
|
|
|
|
- {
|
|
|
|
|
- if(RT_EOK == sht3x_read_singleshot(sht3x_device))
|
|
|
|
|
- {
|
|
|
|
|
- hum_value = sht3x_device->humidity;
|
|
|
|
|
- tem_value = sht3x_device->temperature;
|
|
|
|
|
- if(hum_value!=0)
|
|
|
|
|
- {
|
|
|
|
|
- rt_sprintf(device_status.humidity,"%d.%d",(int)sht3x_device->humidity, (uint)(sht3x_device->humidity * 10) % 10);
|
|
|
|
|
- rt_sprintf(device_status.tempture,"%d.%d",(int)sht3x_device->temperature, (uint)(sht3x_device->temperature * 10) % 10);
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- rt_kprintf("sht3x_read_singleshot eRR:%d",hum_value);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- sht3x_softreset(sht3x_device);
|
|
|
|
|
- }
|
|
|
|
|
-//// rt_kprintf("sht30 humidity : %d.%d ", (int)sht3x_device->humidity, (int)(sht3x_device->humidity * 10) % 10);
|
|
|
|
|
-//// rt_kprintf("temperature: %d.%d\n", (int)sht3x_device->temperature, (int)(sht3x_device->temperature * 10) % 10);
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- rt_kprintf("read sht3x fail.\r\n");
|
|
|
|
|
- //重新初始化
|
|
|
|
|
- sht3x_deinit(sht3x_device);
|
|
|
|
|
- sht3x_device = sht3x_init("i2c1", 0x44);
|
|
|
|
|
- rt_thread_mdelay(150);
|
|
|
|
|
- }
|
|
|
|
|
if(Read_Light_Voltage()>500)
|
|
if(Read_Light_Voltage()>500)
|
|
|
{
|
|
{
|
|
|
checklightnum++;
|
|
checklightnum++;
|