DockperPi Sensor Hub Development Board SKU: EP-0104

From 52Pi Wiki
Jump to navigation Jump to search

DockperPi Sensor Hub Development Board

Description

The Raspberry Pi module for obtaining environmental parameters in the Internet of Things.
It integrates various environmental sensors: temperature sensors, humidity sensors, air pressure sensors, lighting and thermal imaging sensors.
You can use them in smart homes.
To obtain various parameters in life, these parameters can be processed to control the home reasonably and intelligently.
For example, the temperature of the temperature sensor can be used to control the heating device or the air conditioner.
The thermal imaging sensor can detect if someone is in the living room.

Features

  • Easy to use
  • Temperature Detection, Thermistor Detection Temperature Range – 30℃~127℃ DHT11 – 20℃~60℃ Plate-borne Temperature Sensor - 40℃~80℃.
  • Humidity detection, sensor detection range 20% RH ~ 95% RH
  • Light intensity detection, detection range: 0LUX~1800LUX
  • Pressure detection, detection range: 300 ~ 1100 hPa
  • Biopsy test (biopsy test with corresponding indicator), maximum detection angle of 100 degrees, maximum distance of 12mSupply voltage 3.3V
  • Multiple Language programming

Package Includes

  • 1 x Sensor Hub development board
  • 4 x M2.5x11 + 6 copper rod
  • 8 x M2.5x5 screws and nuts
  • 1 x NTC temperature sensor (waterproof)
  • 1 x Introductions

Gallery

To be continued...

Mechanical Drawings

Dockersenserhatmech.png


How to use

  • Mount it on Raspberry Pi’s GPIO and enable I2C function.
  • Open a terminal and typing :

sudo raspi-config

Navigate to interface options and then select i2c and enable it.
  • Install smbus2 module (python3), please make sure your pi is connecting to internet.
  • Typing this command in the terminal:

sudo pip3 install smbus2

  • Download the code and run a test.
git clone https://github.com/geeekpi/dockerpi
cd dockerpi/Sensorhub/
chmod +x sensorhub.py
./sensorhub.py	
  • C code compile and running (please make sure you have wiringPi library has already installed)
gcc –o sensorhub sensorhub.c –lwiringPi 
./sensorhub


  • You will see the feedback as following picture.
Feedbacksensor.png


CODE Block

  • C code: sensorhub.c
#include <stdio.h>
#include <stdint.h>
#include <wiringPi.h>
#include <wiringPiI2C.h>

#define TEMP_REG 0x01
#define LIGHT_REG_L 0x02
#define LIGHT_REG_H 0x03
#define STATUS_REG 0x04
#define ON_BOARD_TEMP_REG 0x05
#define ON_BOARD_HUMIDITY_REG 0x06
#define ON_BOARD_SENSOR_ERROR 0x07
#define BMP280_TEMP_REG 0x08
#define BMP280_PRESSURE_REG_L 0x09
#define BMP280_PRESSURE_REG_M 0x0A
#define BMP280_PRESSURE_REG_H 0x0B
#define BMP280_STATUS 0x0C
#define HUMAN_DETECT 0x0D

uint8_t aReceiveBuf[0x0D + 1];

int main(void)
{

    int fd;
    int i = 0;
    fd = wiringPiI2CSetup(0x17);

    if (fd < 0)
        printf("Extend board Can not be initialized, please enable I2C and try again!\n", fd);

    for (i = TEMP_REG; i <= HUMAN_DETECT; i++)
    {
        aReceiveBuf[i] = wiringPiI2CReadReg8(fd, i);
    }

    if (aReceiveBuf[STATUS_REG] & 0x01)
    {
        printf("Off-chip temperature sensor overrange!\n");
    }
    else if (aReceiveBuf[STATUS_REG] & 0x02)
    {
        printf("No external temperature sensor!\n");
    }
    else
    {
        printf("Current external Sensor Temperature = %d Celsius\n", (int)aReceiveBuf[TEMP_REG]);
    }

    if (aReceiveBuf[STATUS_REG] & 0x04)
    {
        printf("Onboard brightness sensor overrange!\n");
    }
    else if (aReceiveBuf[STATUS_REG] & 0x08)
    {
        printf("Onboard brightness sensor failure!\n");
    }
    else
    {
        printf("Current onboard sensor brightness = %d Lux\n", (int)(aReceiveBuf[LIGHT_REG_H] << 8) | (aReceiveBuf[LIGHT_REG_L]));
    }

    printf("Current onboard sensor temperature = %d Celsius\n", (int)aReceiveBuf[ON_BOARD_TEMP_REG]);
    printf("Current onboard sensor humidity = %d %%\n", (int)aReceiveBuf[ON_BOARD_HUMIDITY_REG]);
    if (aReceiveBuf[ON_BOARD_SENSOR_ERROR] != 0)
    {
        printf("Onboard temperature and humidity sensor data may not be up to date!\n");
    }

    if (aReceiveBuf[BMP280_STATUS] == 0)
    {

        printf("Current barometer temperature = %d Celsius\n", (int)aReceiveBuf[BMP280_TEMP_REG]);
        printf("Current barometer pressure = %d Pascal"\n", (int)aReceiveBuf[BMP280_PRESSURE_REG_L] | (int)aReceiveBuf[BMP280_PRESSURE_REG_M] << 8 | (int)aReceiveBuf[BMP280_PRESSURE_REG_H] << 16);
    }
    else
    {
        printf("Onboard barometer works abnormally!\n");
    }

    if (aReceiveBuf[HUMAN_DETECT] == 1)
    {
        printf("Live body detected within 5 seconds!\n");
    }
    else
    {
        printf("No humans detecte!\n");
    }

    return 0;
}
  • Python3 Code: sensorhub.py
#!/usr/bin/python3

import smbus

DEVICE_BUS = 1
DEVICE_ADDR = 0x17

TEMP_REG = 0x01
LIGHT_REG_L = 0x02
LIGHT_REG_H = 0x03
STATUS_REG = 0x04
ON_BOARD_TEMP_REG = 0x05
ON_BOARD_HUMIDITY_REG = 0x06
ON_BOARD_SENSOR_ERROR = 0x07
BMP280_TEMP_REG = 0x08
BMP280_PRESSURE_REG_L = 0x09
BMP280_PRESSURE_REG_M = 0x0A
BMP280_PRESSURE_REG_H = 0x0B
BMP280_STATUS = 0x0C
HUMAN_DETECT = 0x0D

bus = smbus.SMBus(DEVICE_BUS)

aReceiveBuf = []

aReceiveBuf.append(0x00) # 占位符

for i in range(TEMP_REG,HUMAN_DETECT + 1):
    aReceiveBuf.append(bus.read_byte_data(DEVICE_ADDR, i))

if aReceiveBuf[STATUS_REG] & 0x01 :
    print("Off-chip temperature sensor overrange!")
elif aReceiveBuf[STATUS_REG] & 0x02 :
    print("No external temperature sensor!")
else :
    print("Current off-chip sensor temperature = %d Celsius" % aReceiveBuf[TEMP_REG])


if aReceiveBuf[STATUS_REG] & 0x04 :
    print("Onboard brightness sensor overrange!")
elif aReceiveBuf[STATUS_REG] & 0x08 :
    print("Onboard brightness sensor failure!")
else :
    print("Current onboard sensor brightness = %d Lux" % (aReceiveBuf[LIGHT_REG_H] << 8 | aReceiveBuf[LIGHT_REG_L]))

print("Current onboard sensor temperature = %d Celsius" % aReceiveBuf[ON_BOARD_TEMP_REG])
print("Current onboard sensor humidity = %d %%" % aReceiveBuf[ON_BOARD_HUMIDITY_REG])

if aReceiveBuf[ON_BOARD_SENSOR_ERROR] != 0 :
    print("Onboard temperature and humidity sensor data may not be up to date!")

if aReceiveBuf[BMP280_STATUS] == 0 :
    print("Current barometer temperature = %d Celsius" % aReceiveBuf[BMP280_TEMP_REG])
    print("Current barometer pressure = %d pascal" % (aReceiveBuf[BMP280_PRESSURE_REG_L] | aReceiveBuf[BMP280_PRESSURE_REG_M] << 8 | aReceiveBuf[BMP280_PRESSURE_REG_H] << 16))
else :
    print("Onboard barometer works abnormally!")

if aReceiveBuf[HUMAN_DETECT] == 1 :
    print("Live body detected within 5 seconds!")
else:
    print("No humans detected!")

Keywords

SensorHub, Docker pi, raspberry pi, humidity, temperature, airpressure, NTC, pir sensor, DHT11, DHT12, light sensor.