You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+78-3Lines changed: 78 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,94 @@
1
1
# RooDe
2
+
2
3
People counter working with any smart home system which supports ESPHome and therefore Home Assistamt. All necessary entities are created automatically.
The implemented Algorithm is an improved version of my own implementation which checks the direction of a movement through two defined zones. ST implemented a nice and efficient way to track the path from one to the other direction. I migrated the algorigthm with some changes into the Roode project.
13
+
The concept of path tracking is the detecion of a human:
14
+
* In the first zone only
15
+
* In both zones
16
+
* In the second zone only
17
+
* In no zone
18
+
19
+
That way we can ensure the direction of movement.
20
+
21
+
The sensor creates a 16x16 grid and the final distance is computed by taking the average of the distance of the values of the grid.
22
+
We are defining two different Region of Interest (ROI) inside this grid. Then the sensor will measure the two distances in the two zones and will detect any presence and tracks the path to receive the direction.
23
+
24
+
However, the algorithm is very sensitive to the slightest modification of the ROI, regarding both its size and its positioning inside the grid.
25
+
26
+
ST Microelectronics define the values for the parameters as default like this:
27
+
-`ROI_width = 8 //min 4`
28
+
-`ROI_height = 16 //min 4`
29
+
-`center = {167,231}`
30
+
31
+
The center of the ROI you set is based on the table below and the optical center has to be set as the pad above and to the right of your exact center:
Another crucial choice is the one corresponding to the threshold. Indeed a movement is detected whenever the distance read by the sensor is below this value. The code contains a vector as threshold, as one (as myself) might need a different threshold for each zone.
60
+
61
+
The SparkFun library also supports more formats for the threshold: for example one can set that a movement is detected whenever the distance is between two values. However, more information for the interested reader can be found on the corresponding page.
62
+
63
+
With the updated code (however only for esp32 at the moment) the threshold is automatically calculated by the sensor. To do so it is necessary to position the sensor and, after turning it on, wait for 10 seconds without passing under it. After this time, the average of the measures for each zone will be computed and the thereshold for each ROI will correspond to 80% of the average value. Also the value of 80% can be modified in the code, by editing the variable `threshold_percentage`
64
+
65
+
The calibration of the threshold can also be triggered by a MQTT message. An example for doing so is in the file `integration_with_home_assistant.md`.
66
+
67
+
68
+
69
+
## Useful links
70
+
71
+
[SparkFun library guide](https://learn.sparkfun.com/tutorials/qwiic-distance-sensor-vl53l1x-hookup-guide/all) with more information about the functions used in the code
8
72
9
73
## Hardware
10
74
There will be a specific Hardware setup (recommended brands etc.) soon!
11
-
* ESP8266 or ESP32
12
-
* 1x VL53L1X
75
+
* ESP8266 or ESP32 (Wemos D1 mini case will be available)
76
+
* 1x VL53L1X (GY-53 and cheap chinese sensors)
13
77
* Optional HC-SR501
14
78
* Optional 128x32 OLED
15
79
* Power Supply
16
80
* Encolsure (see .stl files) - will be updated soon!
81
+
Pins:
82
+
#define SDA_PIN D2
83
+
#define SCL_PIN D1
84
+
85
+
## Configuration
86
+
### ESPHome
87
+
Configue at least the secrets.yaml with your wifi SSID and password to connect. Check the peopleCounter.yaml to adapt the exposed sensors to your needs.
88
+
89
+
### Entry/Exit inverted:
90
+
Set #define INVERT_DIRECTION or comment it out to invert the direction.
91
+
17
92
18
93
## Configuration
19
94
Be sure to configure your wifi credentials and adapt the Config.h to set everyhting to your needs.
@@ -65,4 +140,4 @@ Calibration v2 calibrates both zones individually (thanks to @andrea-fox).
To make all functions of Roode work with home assistant you need to set up a few entities and automations.
2
+
Roode has endpoints to set the count value, reset the counter to 0 and to recalibrate. Unfourtunately its not possible to expose buttons via ESPHome that do just that.
3
+
4
+
```
5
+
# This automation script runs when a value is received via MQTT on retained topic: setTemperature
6
+
# It sets the value slider on the GUI. This slides also had its own automation when the value is changed.
0 commit comments