How do you feel about this article? Help us to provide better content for you.
Thank you! Your feedback has been received.
There was a problem submitting your feedback, please try again later.
What do you think of this article?
This is the first look at the DockerPi SensorHub Development Board, this SensorHub is an environmental sensor ideal for IoT. It includes a wealth of sensors: temperature sensors, humidity sensors, air pressure sensors, lighting, and thermal infrared sensors. This article will be divided into two parts, hardware setup, and software setup.
The Hardware Part
To begin with, the hardware part, let's have a look at what is inside the box! We have one SensorHub development board, 4 M2.5x12 copper sticks, 4 pairs of M2.5x6 screws and nuts, one NTC temperature sensor (waterproof).
Inside the box...
Now let's move to the hands-on part.
First, we have to use the copper sticks and M2.5*6 nuts to set up the SensorHub.
And now we attach the SensorHub to the Raspberry Pi, finish as below:
Then, we secure the Raspberry Pi to the SensorHub, using the 4 M2.5x6 screws.
Finish as below:
Finally, we have to plug in the NTC temperature sensor
Finish as below:
The Software Part
I created an ep0106.py with the following code on the desktop of my Raspberry Pi, here is the software part.
The program as below
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!")
The program just runs once so we need to type the Linux command to compute it up to every 10 seconds to renew a script.
watch -n 10 python3 ep0106.py
You will find the data shown like this.