flucto-gmbh / motion-sensor-box

Creative Commons Attribution Share Alike 4.0 International
4 stars 1 forks source link

Motion Sensor Box

motion sensor box

Overview

The Motion Sensor Box is a simple, open-source sensor box available under the CC BY-SA 4.0 license. The sensor box is based on a Raspberry Pi Zero W and ships a variety of sensors as well as a number of interfaces to incorporate the sensor box into a huge variety of measurement projects.

Architecture

Hardware

motion sensor box is build around a Raspberry Pi Zero and several external sensors.

The following lists the electronic components:

The mechanical structure consists of:

Software

The software needed to run the motion sensor box is subdivided into a number of systemd service units. The reasoning behind this architecture is the following:

  1. complexity: dissecting the software into pieces, each focusing on one single task allows for compartmentalization of the overall complexity
  2. robustness: implementing each task as single service that communicates with the broker will increase overall robustness. If a service fails, it will (hopefully) not impair other services (except for the ones directly depending on the failed service)
  3. extensibility: adding or removing a serivce is much easier

All interprocess communication between services is implemented using zeroMQ

software_architecture

List of Services

Data structure for interprocess-communication

Each process must provide its data in the form of a pickled list via the zmq protocol. The first three elements of the list are set to be a timezone aware datetime object, the actual epoch and the uptime. The rest of the elements are left for whatever payload.

As an example, the data structure from the imu service is shown. Please note, that the number of elements in the list must match the element names, defined in the motion sensor box config file

import datetime
import uptime
import time
# inertial measurement unit
[ 
  datetime.datetime.fromtimestamp(ts := time.time(), tz=datetime.timezone.utc),
  ts,
  uptime.uptime(),
  acc_x,
  acc_y,
  acc_z,
  rot_x,
  rot_y,
  rot_z,
  mag_x,
  mag_y,
  mag_z,
  temp,
]

The data is serialized using pickles and send as a multipart-message onto the zmq bus. To identify the data in other services, each serialized data package is designated with a topic string. Here is a list of the topic strings used by the motion sensor box software:

Setup

motion sensor box runs the latest version of Raspberry OS

Hardware assembly

Two sub assemblies need to be prepared before general assembly starts

After the subassemblies have been prepared general assembly can start:

1) Mount the camera glass 2) Mount the round camera holder 3) Mount the camera on the camera holder 4) Mount the four Distanzbolzen 5) Insert the camera cable into the base plate's camera canal 6) Mount the base plate by fixing it with two M3x8 screws 7) Connect the camera with the camera cable 8) Insert the hammer head screw into the base plate and fix it using a M6 nut 9) Insert the battery into the base plate's battery compartment 10) Mount the battery lid using four M3x12 screws 11) To be continued: integration of the electronics stack

Assembly of electronics

Preparation of the electronics

1) Use Raspberry Pi Imager to flash the SD card with Raspberry Pi OS lite. Reinsert the SD card afterwards.

2) open the partition named rootfs and from the motion sensor box github repository copy the following files (on linux):

sudo cp /path-to-motion-sensor-box-repository/cfg/hosts /path-to-SD/rootfs/etc
sudo cp /path-to-motion-sensor-box-repository/cfg/hostname /path-to-SD/rootfs/etc
sudo cp /path-to-motion-sensor-box-repository/cfg/rtunnel.service /path-to-SD/rootfs/etc/systemd/system

sudo cp /path-to-motion-sensor-box-repository/cfg/wpa_supplicant.conf /path-to-SD/boot

3) in the boot partition, create an empty file called ssh to enable ssh login:

touch /path-to-SD/boot/ssh

4) afterwards, please open the file /path-to-SD/rootfs/etc/hostname and /path-to-SD/Arootfs/etc/hosts and edit the serial number of the motion sensor box to the corresponding value

5) open the file /path-to-SD/rootfs/etc/systemd/system/rtunnel.service and replace '[REMOTE PORT]' to 65000 + the serial number, e.g. 0014 (65000 + 0014 = 65014)

6) Sense hat's long pins must be removed: Use a screwdriver to lift the yellow part and then cut the pins.

cut_sensehat_pins

7) Prepare the cables (see cable documentation)

Electronics Assembly

Assemble the stack starting from the bottom to the top:

electronic stack

The following schematics shows how the external hardware is connected to the pi's header:

pinout

Software Setup

Connect the Electronics to power, either through a dedicated USB cable or through the Bulgin power connector. Wait 30 s for the raspberry pi to boot.

Login to the box using SSH (replace XXX with the last 3 digits of the serial number and "location-of-key-on-local-machine"):

ssh pi@flucto.tech -p 65XXX -i "location-of-key-on-local-machine"

Alternatively, if you are in the same WLAN you can login locally (replace XXX with the last 3 digits of the serial number):

ssh pi@msb-0XXX-a.local -i "location-of-key-on-local-machine"

Install git:

sudo apt-get update
sudo apt-get install git

Then clone the git repository to the box' home/pi folder:

git clone https://github.com/flucto-gmbh/motion-sensor-box.git --recursive

To finish the setup, please follow through with system Setup.

Software debugging

To access a motion sensor box via a bluetooth serial console, follow these steps

Sensing

Waveshare's SenseHat

To provide a good basis for measurements, motion sensor box includes Waveshare's SenseHat. A TL;DR regarding the senseHat for motion sensor box can be found under doc/waveshare_sense_hat/tldr_sense_hat.

It packs a number of sensors, all connecting to a Raspberry Pi via I2C:

Camera

An official Raspberry Pi PiCam Noir (v2) is planned. It will allow low resolution live streams or high resolution imaging at fixed intervals.

GNSS

motion sensor box features a Navilock NL-852ETTL GNSS receiver. This modern GNSS receiver is based on the ublox8 chipset. It allows to receive navigation signal from any two GNSS systems simultaneously. The Chip supports all currently available GNSS Systems.

Additional Interfaces

Four analog inputs are available via the SenseHat. Additionally, I2C piuns are also exposed, allowing for easy connection to other embedded devices. For more high level applications, three USB-A port are available, allowing additional devices, such as cameras or network interfaces.

History of motion sensor box

The original motion sensor box was jointly developed by Uni Bremen and Flucto GmbH. Its development was inspired by a sensor box that was designed for a research project by Uni Bremen's Institute for Integrated Product Development (BIK) where measurements during the installation of "Trianel Windpark Borkum" were conducted.