pfodWeb Display for C1001 Human Detection Sensor via Serial,BLE or HTTP

Introduction
Introduction
The Dfrobot C1001 mmWave Human Detection Sensor provides two modes of operation, Fall Detection mode and Sleep Detection mode. This project provides a web page display of the Sleep Detection mode. pfodWeb.html is used to display the simple GUI designed by pfodWebDesigner. The pfod messages that define the display are very compact and can be served to pfodWeb.html via Serial, BLE or HTTP connections. The Serial connection and the simple code needed to create the GUI means that even an Arduino Mega can used the microprocessor connection to the C1001.
Here a FireBeetle ESP32-E V1.0 is used as the microprocessor because the ESP32 supports BLE and HTTP connections as well at the Serial connection.
This project is also on-line at Web Display for the Dfrobot C1001 mmWave Human Detection Sensor
Quick Overview of pfodWeb and pfodWebDesigner
pfodWeb is a free web based partial replacement for the paid Android app, pfodApp. pfodWeb runs in a browser and connects to your Arduino board via either Serial or BLE or HTTP. Using Serial you can connect to any Arduino board and display the interactive controls it serves. pfodWeb runs competely off-line. No internet connection is needed. Just install the pfodParser library and open the index.html in the pfodWeb sub-directory of the pfodParser library. The interactive controls are completely defined by the code (generated by pfodWebDesigner) in your Arduino. Very compact pfod messages are used to send the controls and receive the user's commands.
If your Arduino board supports HTTP and has a file system of 200Kb, then you can load the all pfodWeb files onto your microprocessor and serve them directly from there.
pfodWebDesigner is a free web based replacement for the free Android app, pfodGUIdesigner. pfodWebDesigner allows you to design interactive and responsive user interfaces for your microprocessor. pfodWebDesigner generates Arduino code that works with all pfodDevices that connect via Serial, Bluetooth, BLE, SMS and WiFi, not just those that have WiFi support. See how to install pfodWebDesigner and Using pfodWebDesigner to Create GUI's. Individual pfodWebDesigner controls are stored as JSON files which you can duplicate, modify and reuse in other designs. Each reused control can be individually scaled and positioned in the final design.
Quick Start
Install Arduino IDE V2 – For Windows, use the "Windows ZIP" or plain "Windows" executable (EXE) downloaded direct from https://arduino.cc. and allow it to install any device drivers it suggests.
Install the latest pfodParser and SafeString libraries from the library manager OR unzip the libraries.zip to your Arduino libraries dir
Install the DFRobot_HumanDetection-master library (included in the libraries.zip)
Install the board support for ESP32, ESP32 by Express Systems V3.3.2 from the Arduino IDE Boards Manager
Wire up the C1001 board to the ESP. See below for the connection details
Unzip the C1001_Presence_serial.zip to your Arduino Sketch directory and upload the sketch to the ESP32
The pfodWebDesigner also generates BLE and HTTP versions. C1001_Presence_ble.zip and C1001_Presence_http.zip are the completed sketches
In a recent version of Chrome or Edge or Opera browser, open the pfodWeb.html page from the pfodParser library sub-directory pfodWeb and select Serial and Connect to your ESP32.
Edge and Opera just work for Serial. Chrome needs a flag changed. See Compatible Browers
Remember to close the Arduino Serial Monitor first. BLE and HTTP sketches are also provided. HTTP will work with any browser.
From the pfodParse library, in sub-directory pfodWeb, open pfodWeb.html in a Chrome or Edge browser (>V141) and selected Serial connection, 115200 baud, and click Connect and Pair your board's serial port.
Note: This will fail if the Arduino IDE or other application already has that port open. Close the Arduino Serial Monitor.
The C1001 takes over 20secs to start up so if the Serial connection times out just reconnect.
There is a Raw Message Viewer, you can open by a right click, which shows all the message sent by your board, include debugging output.
Wiring up the Sensor

The connections depend on your Arduino board. The code here has setting for FireBeetle 2 ESP32 V1
See C1001_basics.cpp
Serial1.begin(115200, SERIAL_8N1, /*rx =*/D10, /*tx =*/D11);
// for this project using FireBeetle 2 ESP32 V1

Designing the Presence GUI
The Presence Detection GUI is very simple. Install the pfodWebDesigner, open it and load the C1001_Presence.json drawing file and Edit it.
From there you can edit the display as you wish. See the detailed tutorials on the pfodWebDesigner
When you have finished, go back to the Control Panel and use Arduino Export to generate a complete Arduino Sketch. You can choose either Serial or BLE or HTTP connections.
Serial is the simplest sketch, any print debug msg are sent along with the pfod messages and can be viewed in the Raw Message View, but you need a recent version of Chrome, Edge or Opera browser to connect via Serial.
HTTP is the most universal connection. Any browser will connect and the sketch also includes a tcp/ip server on port 4989 that pfodApp Android app will connect to. However you need a WiFi capable board and you need to connect to the local network.
BLE is the third option, if your Arduino board supports a Nordic UART connection. The pfodWebDesigner generates complete BLE sketches for the ESP32. Recent versions of Chrome and Edge browsers will connect using pfodWeb and the pfodApp Android will also connect.
Adding the C1001 Code
The generated code needs to be modified to insert the readings from the C1001. The files C1001_basics.cpp / .h are a thin wrapper around the C1001 library. In the Dwg_C1001_Presence, the sendIndexedItems() sends the latest values when requested. The generated code has the typical values used to in the pfodWebDesigner
void Dwg_C1001_Presence::sendIndexedItems() {
dwgsPtr->label().idx(idx_presence).color(dwgsPtr->BLACK_WHITE).text("Yes").offset(0,10).left().decimals(2).send();
dwgsPtr->label().idx(idx_movement).color(dwgsPtr->BLACK_WHITE).text("Active").offset(0,14).left().decimals(2).send();
dwgsPtr->label().idx(idx_range).color(dwgsPtr->BLACK_WHITE).text("3").offset(0,18).left().decimals(0).send();
dwgsPtr->label().idx(idx_respiration).color(dwgsPtr->BLACK_WHITE).text("24").offset(0,22).left().decimals(0).send();
dwgsPtr->label().idx(idx_heartRate).color(dwgsPtr->BLACK_WHITE).text("80").offset(0,26).left().decimals(0).send();
}
This method needs to be updated to use the current values as provided by the C1001_basic.cpp file get...() methods
void Dwg_C1001_Presence::sendIndexedItems() {
dwgsPtr->label().idx(idx_presence).color(dwgsPtr->BLACK_WHITE).text(getPresence()).offset(0,10).left().decimals(2).send();
dwgsPtr->label().idx(idx_movement).color(dwgsPtr->BLACK_WHITE).text(getMovement()).offset(0,14).left().decimals(2).send();
dwgsPtr->label().idx(idx_range).color(dwgsPtr->BLACK_WHITE).text(getMovementRange()).offset(0,18).left().decimals(0).send();
dwgsPtr->label().idx(idx_respiration).color(dwgsPtr->BLACK_WHITE).text(getRespiration()).offset(0,22).left().decimals(0).send();
dwgsPtr->label().idx(idx_heartRate).color(dwgsPtr->BLACK_WHITE).text(getHeartRate()).offset(0,26).left().decimals(0).send();
}
The other edits are needed is to the .ino file. The C1001 needs to be initialized, a timer is need to request a new set of reading periodically. Also each C1001 reading takes about 0.6sec, so reading all 5 values at once would delay the loop and connection code by ~2.5sec. To avoid the 2.5sec delay to processing the requests from pfodWeb, the reading are taken one at a time and the handle_pfodParser() method called between each C1001 read to process and request received.
See the C1001_Presence_serial.ino for the code changes
Conclusion
This project used pfodWeb to display the output of the C1001 Human Detection Sensor. The GUI was designed using pfodWebDesigner and served via Serial. The Serial connection allows any Arduino board to serve its own custom GUI to control its operation and display its measurements. BLE and HTTP versions (generated by pfodWebDesiger) were also provided.
