DockerPi Sensor Hub Development Board SKU: EP-0106

From 52Pi Wiki
Jump to navigation Jump to search

Docker Pi Sensor Hub Development Board

Sensorhub2.jpg

Description

The DockerPi SensorHub for obtaining environmental parameters in the Internet of Things.
It integrates various environmental sensors: temperature sensors, humidity sensors, air pressure sensors, lighting and thermal infrared 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 infrared sensor can detect if someone is in the living room.

Features

  • DockerPi Series
  • Programmable
  • Read directly(without programming)
  • Extend the GPIO Pins
  • Ext. Temperature Detection, Thermistor Detection Temperature Range -30℃~127℃
  • OnBoard Temperature DHT11 -20℃~60℃
  • P. 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 Pa ~ 1100 hPa
  • Biopsy test (biopsy test with corresponding indicator), maximum detection angle of 100 degrees, maximum distance of 12m
  • Can Stack with other Stack board
  • Independent of the mainboard hardware (require I2C support)

Official Compatibility Test

Not only support the following development boards, other development boards can be compatible if they have I2C peripherals. (Note: some software changes may be required)

Platform DockerPi Sensor Hub Notes
Raspberry Pi All Platform Not Include CM Series & EOL Platform
Banana Pi M3 Python 3 & Modify DEVICE_BUS to 2
Orange Pi Zero Python 3 & Modify DEVICE_BUS to 0

Package Includes

  • 1 x Sensor Hub development board
  • 4 x M2.5x12 copper stick
  • 8 x M2.5x6 screws and nuts
  • 1 x NTC temperature sensor (waterproof)
  • 1 x Introductions
Sensorhub9.jpg


Gallery

Sensorhub1.jpg
Sensorhub2.jpg
Sensorhub3.jpg
Sensorhub4.jpg
Sensorhub5.jpg
Sensorhub6.jpg
Sensorhub7.jpg
Sensorhub8.jpg
Sensorhub9.jpg

Mechanical Drawings

Mechanical sensorhub0.png


Register Map

All registers are Read Only.

Register Address Function Value
0x01 TEMP_REG Ext. Temperature [Unit:degC]
0x02 LIGHT_REG_L Light Brightness Low 8 Bit [Unit:Lux]
0x03 LIGHT_REG_H Light Brightness High 8 Bit [Unit:Lux]
0x04 STATUS_REG Status Function
0x05 ON_BOARD_TEMP_REG OnBoard Temperature [Unit:degC]
0x06 ON_BOARD_HUMIDITY_REG OnBoard Humidity [Uinit:%]
0x07 ON_BOARD_SENSOR_ERROR 0(OK) - 1(Error)
0x08 BMP280_TEMP_REG P. Temperature [Unit:degC]
0x09 BMP280_PRESSURE_REG_L P. Pressure Low 8 Bit [Unit:Pa]
0x0A BMP280_PRESSURE_REG_M P. Pressure Mid 8 Bit [Unit:Pa]
0x0B BMP280_PRESSURE_REG_H P. Pressure High 8 Bit [Unit:Pa]
0x0C BMP280_STATUS 0(OK) - 1(Error)
0x0D HUMAN_DETECT 0(No Active Body) - 1(Active Body)
STATUS_REG 0x04
Default Value 0 0 0 0 0 0 0 0
Description Reserved Reserved Reserved Reserved L_FAIL L_OVR T_FAIL T_OVR
  • T_OVR(Read Only)
  1. Read 1 means Ext. Temperature Overflow.
  2. Read 0 means Ext. Temperature works well.
  • T_FAIL(Read Only)
  1. Read 1 means Ext. Temperature Not Found.
  2. Read 0 means Ext. Temperature works well.
  • L_OVR(Read Only)
  1. Read 1 means Light Brightness Overflow.
  2. Read 0 means Light Brightness works well.
  • T_FAIL(Read Only)
  1. Read 1 means Light Brightness Not Found.
  2. Read 0 means Light Brightness works well.

Configuring I2C(Raspberry Pi)

Run sudo raspi-config and follow the prompts to install i2c support for the ARM core and linux kernel
Go to Interfacing Options

Raspi-config-1.png

then I2C

Raspi-config-2.png

Enable!

Raspi-config-3.png

Done!

Raspi-config-4.png

Program in Language C(Raspberry Pi)

  • Create source code and name it "sensor.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;
}

Compile!

gcc sensor.c -lwiringPi -o sensor

Exec It!

./sensor

Program in Language Python(Raspberry Pi)

The following code is recommended to be executed using Python 3 and install the smbus library:

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!")

Program in Language Java(Raspberry Pi)

Creat a new file named :SensorHub.java and paste following codes:

import java.io.IOException;
import java.util.Arrays;

import com.pi4j.io.i2c.I2CBus;
import com.pi4j.io.i2c.I2CDevice;
import com.pi4j.io.i2c.I2CFactory;
import com.pi4j.io.i2c.I2CFactory.UnsupportedBusNumberException;
import com.pi4j.platform.PlatformAlreadyAssignedException;
import com.pi4j.util.Console;

public class SensorHub {
	
	//SensorHub Address
	public static final int DOCKERPI_SENSORHUB_BOARD = 0x17;
	
	//SensorHub's functions
	public static final byte TEMP_REG = (byte) 0x01;	
	public static final byte LIGHT_REG_L = (byte) 0x02;
	public static final byte LIGHT_REG_H = (byte) 0x03;
	public static final byte STATUS_REG = (byte) 0x04;
	public static final byte ON_BOARD_TEMP_REG = (byte) 0x05;
	public static final byte ON_BOARD_HUMIDITY_REG = (byte) 0x06;
	public static final byte ON_BOARD_SENSOR_ERROR = (byte) 0x07;
	public static final byte BMP280_TEMP_REG = (byte) 0x08;	
	public static final byte BMP280_PRESSURE_REG_L = (byte) 0x09;
	public static final byte BMP280_PRESSURE_REG_M = (byte) 0x0A;
	public static final byte BMP280_PRESSURE_REG_H = (byte) 0X0B;
	public static final byte BMP280_STATUS = (byte) 0x0C;
	public static final byte HUMAN_DETECT = (byte) 0x0D;
	
	public static void main(String[] args)
			throws InterruptedException, PlatformAlreadyAssignedException, IOException, UnsupportedBusNumberException {
				
				final Console console = new Console();
				
				I2CBus i2c = I2CFactory.getInstance(I2CBus.BUS_1);
				I2CDevice device = i2c.getDevice(DOCKERPI_SENSORHUB_BOARD);
				
				int i = 0;
				
				if(device.read(DOCKERPI_SENSORHUB_BOARD) < 0)
					console.println("External board Can not be initialized, please enable I2C and try again!",device.read(DOCKERPI_SENSORHUB_BOARD));
				else
					console.println("External board has been initialized");
				
				if((device.read(STATUS_REG) & 0x01) == 0x01)
					console.println("off-chip temperature sensor overrange!");
				else if((device.read(STATUS_REG) & 0x02) == 0x02)
					console.println("No external temperature sensor!");
					
				else {
					console.println("the temp of air is :" + device.read(TEMP_REG) + "centigrade");
				}				
				
				if((device.read(STATUS_REG) & 0x04) == 0x04) {
					console.println("Onboard brightness sensor overrange!");
				}
				else if((device.read(STATUS_REG) & 0x08) == 0x08) {
					console.println("Onboard brightness sensor failure!");
				}
				else {
					console.println("Current onboard sensor brightness is :" + (device.read(LIGHT_REG_L) | device.read(LIGHT_REG_H) << 8) + "lux");
				}
				
				if(device.read(ON_BOARD_SENSOR_ERROR) == 1)
					console.println("Onboard temperature and humidity sensor data may not be up to date!");
				
				console.println("the temp of sensor on board is :" + device.read(ON_BOARD_TEMP_REG) + "centigrade");
				console.println("the humidity of sensor is :" + device.read(ON_BOARD_HUMIDITY_REG) + "%");
	
				if(device.read(BMP280_STATUS) == 0) {
					console.println("the temp of air pressure sensor is :" + device.read(BMP280_TEMP_REG) + "centigrade");	
					console.println("the air pressure is :" + (device.read(BMP280_PRESSURE_REG_L) | device.read(BMP280_PRESSURE_REG_M) << 8 | device.read(BMP280_PRESSURE_REG_H) << 16) + "pa");
				}
				else
					console.println("Onboard barometer works abnormally!");
				
				if(device.read(HUMAN_DETECT) == 1) {
					console.println("Live body detected within 5 seconds!");
				}
				else {
					console.println("No humans detecte!");
				}
			}
	
}
  • Compile it and running :
javac SensorHub.java -classpath .:classes:/opt/pi4j/lib/'*'
sudo java -classpath .:classes:/opt/pi4j/lib/'*' SensorHub

Keywords

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