Project 10:Presence-Activated Billboard

So far, we basically mastered the use of the UNIHIKER K10’s onboard sensors. This class , we’ll connect external modules for further in-depth practice—we’ll link a mmwave presence sensor to build an automatic induction billboard, which senses humans and triggers its automatic switching.


Project Objectives


Knowledge Objectives


1.Understand the I2C Protocol.
2.Learn the principle of human detection with the mmwave presence sensor.
3.Understand the pin distribution of UNIHIKER K10 and expansion boards.


Practical Objective


When the mmwave presence sensor detects someone approaching, the UNIHIKER K10 can automatically switch the billboard.


Materials List

HARDWARE LIST
1 UNIHIKER K10
1 mmwave presence sensor
1 USB Cable
1 Module Cable(4pin)

Preparations


Hardware


(1) Set the dip switches on the back of the mmwave presence sensor to the I2C and 0x2A positions respectively.

Note: Knowledge about the I2C Protocol (or IIC Protocol) can be found in the Knowledge Base.
(2) Connect the mmwave presence sensor to the I2C interface of the UNIHIKER K10 via a module cable, then connect the UNIHIKER K10 to a computer with a USB cable.

The mmwave presence sensor is sensitive to installation methods; improper placement will affect its performance and functions. Common mounting types include top, bottom, horizontal and downward-tilted installation (see the figure below). It has a horizontal detection angle of about 100° and a detection range of up to 8m, so it should be fixed in an open and stable environment during use.

Note: The introduction to the mmwave presence sensor can be found in the Knowledge Base.


Software


Open Mind+ v2, switch to“Upload Mode”, connect the UNIHIKER K10 as shown in the figure below, and load the UNIHIKER K10 library.

 

Hands-on Practice


Next, we will learn how to use the mmwave presence sensor to detect obstacles (human bodies) and automatically switch billboards.
Task 1: Reading Data from the Mmwave Presence Sensor
First, we will use the mmwave presence sensor for real-time monitoring and output test results via the serial port.
Task 2: Automatic Switching of Billboards
Then, we will use the mmwave presence sensor to monitor human movement and realize automatic switching of billboards when someone approaches.


Task 1: Reading Data from the Mmwave Presence Sensor


Code 


1.Loading and Parameter Configuration of the Mmwave Presence Sensor
 

STEP1: Load the mmwave radar sensor
Click "Extension", enter "Module" to search for and add the "Millimeter Wave Radar Sensor" to complete the loading of the corresponding module.

STEP2:Parameter Configuration
Use the relevant blocks under the "setmodel" module of the mmwave radar sensor to perform initial configuration for the communication address, detection mode, range and sensitivity, as shown in the figure below:

Among them, to better achieve the target function, set the trigger sensitivity to a value between 5 and 7, and set the keep sensitivity to 1 or 2.
The complete program code is shown below:

2.Serial Port Output Data


For the detection results of the mmwave presence sensor, we will make judgments based on the data output via the serial port.
To read the output data of the sensor, we will use the"Obstacle detected?" block under the "getdata" module of the mmwave radar sensor. The specific location is as follows:

Then, combine it with the "(serial0) write (string) ("hello") (Wrap)" block under the "serialport operation" module in the UNIHIKER K10 Library. The specific location is as follows:

The complete program code is shown below:

Run the Code


Click the“Upload”button, wait for the upload to complete,then open the serial port.

When no obstacles (human) appear in front of the sensor, the Serial Monitor interface outputs 0 at a 1-second cycle; when a person approaches the sensor, it outputs 1 at a 1-second cycle.

Code Review

Category

Blocks

Function

Initialize the I2C communication mode of the mmwave radar, specify the communication address, and lay the foundation for data transmission between the sensor and the UNIHIKER K10.
Configure the working mode of the mmwave radar sensor, which can be selected as "Existence Detection" (whether there is an object within the detection range) or "Speed Measurement" (measure the moving speed of objects).
Set the effective detection range of the mmwave radar sensor, specify the min/max detection distance and trigger distance, and only perform detection response for objects within this range.
Adjust the sensitivity of the mmwave radar sensor when detecting objects (value range 0-9). The higher the value, the easier the sensor can identify objects within the detection range.
Adjust the stability of the mmwave radar sensor in maintaining the detection state after detecting an object (value range 0-9), which affects the continuity of detection results.
Read the detection data of the mmwave radar sensor in real time, determine whether there are obstacles in the detection range, return 1 if obstacles exist, and return 0 if not.


Task 2: Automatic Switching of Billboards


Code


To realize the switching of billboards, we can set a variable (picture), combine it with the "if()then()else()" block, and achieve this by using the method of conditional judgment.
Among them, the condition filled in after "if" should consist of two parts: it is necessary to detect that a person is approaching and at the same time use the value of the variable to display the corresponding billboard.

To detect whether a person is close to the sensor, we need to use the " Obstacle detected?" block under the "getdata" module of the mmwave radar sensor.
The complete program code is shown below:


Run the Code


Click the“Upload”button, and wait for the upload to complete. When a person approaches the billboard, it switches automatically; when a person moves away from the billboard, the billboard stops switching.


Knowledge Base


Next, let's learn and summarize the hardware knowledge used in this lesson.
 

IIC Protocol


1.Definition of IIC Protocol


The IIC protocol is a short-range communication method used for data transmission between chips on circuit boards, relying mainly on SCL (Serial Clock Line) and SDA (Serial Data Line). It supports the simultaneous connection of multiple devices: SCL uniformly coordinates the sending and receiving rhythm of all devices, while SDA, combined with each device's unique address, ensures accurate data transmission.

2.General Communication Process Between IIC Master Device (UNIHIKER K10) and Slave Device (mmwave presence sensor)


(1)UNIHIKER K10 sends/writes data to the sensor (to configure sensor parameters):
UNIHIKER K10: Send "Ready to Transmit Data" (START) → Send sensor address (0x2A, confirm target) → Wait for sensor's "Ready" (ACK) → Send configuration parameters one by one → After sending each parameter, wait for "Parameter Received" (ACK) → All parameters sent → Send "End Communication" (STOP).

(2) UNIHIKER K10 receives/reads data from the sensor (to obtain detection results):
UNIHIKER K10: Send "Ready to Read Data" (START) → Send sensor address (0x2A, confirm target) → Wait for sensor's "Ready" (ACK) → Sensor sends detection result (No one=0, Someone=1) → UNIHIKER K10 replies "Received" (ACK) after receiving result → After reading last result, reply "No More Data" (NACK) → Send "End Communication" (STOP).

3.The Concept of the UART Protocol


UART is a common way for short-distance data transmission between devices, such as information exchange between microcontrollers, computers and sensors. It does not use a dedicated line to coordinate transmission speed, but pre-agrees on the same transmission speed with the other party to ensure error-free data transmission.


4.The Differences Between IIC and UART Protocols

Comparison Dimension

IIC Protocol

UART Protocol

Key Feature

Multiple devices can share a single bus for communicationOnly two devices can communicate via one-to-one direct connection

Digital Quantity Transmission

Shared bus for multi-device communication, suitable for digital quantity interconnection among multiple digital devicesSuitable for point-to-point digital quantity transmission between two devices

Analog Quantity Transmission

Supports analog quantity transmission after conversion by a shared ADC (Analog-to-Digital Converter) for multiple analog sensorsSuitable for point-to-point transmission of converted signals from a single analog sensor

Transmission Rate

Relatively low (100kbps for standard version, etc.)Wide rate range (9600bps ~ several Mbps)

Application Scenario

Communication between multiple chips on a circuit boardPoint-to-point data transmission between two devices

Key Advantage

Cost-effective, compatible with multi-device, high space utilizationSimple and direct connection, stable and reliable point-to-point communication


Mmwave Presence Sensor


1.Definition of mmwave presence sensor


Mmwave presence sensors are non-contact hardware devices based on millimeter wave radar technology. They transmit signals in the 24GHz~300GHz frequency band, and accurately obtain the distance, speed and angle information of target objects through active detection. 
Mmwave radar technology is a sensing technology system that takes millimeter waves as the signal carrier. It achieves accurate detection of target parameters such as distance, speed and angle by actively transmitting and receiving electromagnetic waves and analyzing echo signals.


2.The ranging principle of the mmwave presence sensor


Mmwave presence sensor ranging mainly uses the time delay td between transmitted and echo signals, and infers the relative distance R between the sensor and the detected target based on the millimeter wave propagation speed c and the relative speed vr between the target and the radar.

 

When electromagnetic waves are transmitted from the sensor and reflected back by the target, a fixed time delay td (round-trip time) occurs. In an ideal static scenario (no relative motion between the target and the sensor), the distance R has a simple linear relationship with td and c: the round-trip distance is 2R=c×td, i.e.,

In practical scenarios, targets are mostly in motion (with a radial relative speed vr). During the time delay td, the target moves a certain distance along the beam direction, causing deviations in the static formula. Dynamic correction is therefore required: the displacement of the target within td is vr×td, which changes the actual round-trip distance of electromagnetic waves, and the final dynamic ranging formula is:

This measurement method offers high distance resolution and ranging accuracy, and millimeter-level precise ranging can be achieved through backend algorithms.


3.C4001(12m)Mmwave presence sensor


The sensor adopted in this project is the C4001 mmwave presence sensor. Its relevant parameters are introduced as follows:
This sensor features I2C and UART communication modes and is equipped with a Gravity (PH2.0) interface (pinout defined below). It supports 8m human presence detection and 12m motion detection, with a distance detection range of 1.2~12m and a speed detection range of 0.1~10m/s. It boasts strong anti-interference capability, a compact size and easy integration.

Compared with other human presence sensors such as infrared sensors, the C4001 (12m) mmwave presence sensor can detect both static and dynamic human states with strong anti-interference capability, and is less susceptible to temperature, ambient light, environmental noise and other factors. Whether a person is sitting still, sleeping or moving, the sensor can detect human presence quickly and sensitively.


Challenge Task


Bird strikes pose a risk to aircraft takeoff and landing , yet manual monitoring is exhausting and has blind spots. So we can make a "bird prevention device" with a mmwave presence sensor: reset the sensor's detection range, and once it detects birds' movement, it will trigger the LED light to turn on to alert the flocks, safeguarding the safety of aircraft takeoff and landing.
Tip: Connect an LED light to UNIHIKER K10, use“If() then() else()”block for judgment: the LED lights up when an obstacle is detected, otherwise it turns off.
The reference code is as follows:

icon project 10.zip 754KB Download(0)
License
All Rights
Reserved
licensBg
0