Mission
Build this
Build a small courtroom for PIR, tilt, and GY-6500 evidence, with a display for raw clues and a gesture for the combined verdict.
Borrowed parts are labelled below and have a fallback. The registered device ID is fixed; sensing and behaviour decisions remain yours.
Bill of materials
Parts
| Source | Part | Fallback |
|---|---|---|
| ● kit | PIR sensor | — |
| ● kit | Tilt switch | — |
| ● kit | GY-6500 module | — |
| ● kit | OLED | — |
| ● kit | SG90 servo | — |
Disconnect USB before rewiring. Motors, the relay, and the servo need appropriate power and a shared ground. Never drive an actuator from the ESP32 3V3 pin.
Your invitation
Three witnesses watch the same movement and tell different stories
One notices a warm body crossing its view. One notices that the device tipped. One feels acceleration and rotation in its own frame. Ask “did something move?” and all three may answer differently—without any of them being broken.
Your laboratory will stage repeatable motions, record who noticed, and invent a fair rule for combining their testimony.
PIR
Notices changing patterns of warm infrared light.
Tilt switch
Notices a change in orientation or a physical knock.
GY-6500
Notices acceleration and rotation of the device itself.
The central idea
A sensor does not detect “motion.” It detects its own clue.
A person walking past can trigger the PIR while leaving the table perfectly still. A tap can wake the tilt switch and motion module while the PIR sees no warm body crossing. A slow tilt may change orientation without creating a sharp acceleration.
PIR: likely · tilt: no · module: no
PIR: maybe · tilt: likely · module: likely
PIR: should not · tilt: no · module: no
PIR: maybe · tilt: likely · module: likely
Predictions, not answers. Your trials decide what “likely” means for your setup.
What does “sensor fusion” mean without the buzzword?
It means using more than one clue to make one decision. An OR rule believes any witness and catches more events, but also accepts more false alarms. AnAND rule demands agreement and is cautious, but misses motions only one sensor can see.
You can also give each scene its own rule: PIR alone may mean “someone crossed nearby,” while tilt plus GY-6500 may mean “the device was disturbed.”
Design the courtroom
Define the event before judging the sensor
“Motion happened” is too vague for a fair test. Mark where the person walks, how the table is tapped, how far the sensor sits, and when each trial begins and ends.
This four-box record is a confusion table. Its purpose is not to confuse you. It stops one impressive success from hiding five quiet failures.
Wiring
Introduce the witnesses one at a time
Read the PIR first, then the tilt switch, then the GY-6500. Let the OLED show each raw witness before your combined rule replaces them with one verdict.
The power rule: The GY-6500 and OLED use 3V3. The common PIR module uses 5 V but returns 3.3 V logic. The servo uses a separate 5 V supply. Join all grounds.
Bench referenceOpen the exact wiring map
| ESP32 pin | Part | Part marking | Carries |
|---|---|---|---|
5V / VIN | PIR sensor | VCC | 5V power — common HC-SR501 module supply |
GPIO 27 | PIR sensor | OUT | Digital in/out — module output is 3.3 V logic |
GND | PIR sensor | GND | Ground |
GPIO 32 | Tilt switch | one leg | Digital in/out — configure INPUT_PULLUP |
GND | Tilt switch | other leg | Ground |
3V3 | GY-6500 | VCC | 3V3 power — safe supply for the sensor module |
GND | GY-6500 | GND | Ground |
GPIO 21 | GY-6500 | SDA | I²C bus — shares the display data bus |
GPIO 22 | GY-6500 | SCL | I²C bus — shares the display clock bus |
3V3 | OLED (SSD1306) | VCC | 3V3 power |
GND | OLED (SSD1306) | GND | Ground |
GPIO 21 | OLED (SSD1306) | SDA | I²C bus |
GPIO 22 | OLED (SSD1306) | SCL | I²C bus |
GPIO 18 | SG90 servo | signal (orange) | PWM to actuator — shows the agreement state |
external 5 V | SG90 servo | power (red) | 5V power — separate supply |
GND | SG90 servo | ground (brown) | Ground — join servo and ESP32 grounds |
Confirm the exact labels on your PIR and GY-6500 boards before powering them. Never send 5 V into an ESP32 GPIO, and never power the servo from 3V3.
- 5V power
- Digital in/out
- Ground
- 3V3 power
- I²C bus
- PWM to actuator
The GY-6500 and OLED share GPIO 21 and 22 because I²C devices have different addresses. Test each alone before combining the bus.
Give agreement a body
One clue should not look like three clues
No witness currently reports its clue.
One witness noticed something. Hold judgement.
Several clues agree—or your scene-specific rule is satisfied.
Your team decides:
- Which sensor combinations deserve different names?
- How close in time must two clues arrive to count as agreement?
- Does the servo show confidence, motion type, or a short reaction?
Your trial programme
Rehearse both movement and stillness
- Write four scenes.
Include at least two motions and two no-motion conditions that could fool a sensor.
- Predict the witnesses.
Write which sensors you expect before running the trial.
- Run twenty repetitions per scene.
Keep placement and timing fixed. Record every witness, delay, and final verdict.
- Tune once, then stop.
Use one run to design the rule and a fresh run to evaluate it. Do not keep moving the goalposts.
| Scene | Expected | PIR | Tilt | GY-6500 | Verdict |
|---|---|---|---|---|---|
| walk past | motion | ___ | ___ | ___ | ___ |
| table bump | disturbed | ___ | ___ | ___ | ___ |
| quiet minute | still | ___ | ___ | ___ | ___ |
When witnesses behave strangely
Disagreement is often the result you need
The PIR stays silent for nearly a minute after startup
Many PIR modules need a warm-up period. Keep the scene still and exclude that time from the trials.
The PIR fires while nobody moves
Sun, heaters, or moving warm air can change its infrared pattern. Turn or shield it and record the environment.
The tilt switch chatters during one tip
The metal contact bounces. Treat several rapid edges inside a short window as one event.
The GY-6500 reports motion while sitting on the desk
Its raw values include gravity and electrical noise. Measure the resting spread before choosing a threshold.
The servo or display makes the motion module fire
The device is sensing its own movement or power disturbance. Separate the servo supply and ignore a short known window after your own gesture.
Choose your laboratory
What kind of motion scientist will you become?
The fair judges
Compare AND, OR, and scene-specific rules on the same untouched evaluation trials.
The motion choreographers
Design a varied set of repeatable gestures and discover which sensor has the clearest vocabulary.
The travelling testers
Keep one rule fixed and move the laboratory to a second environment to see what stops transferring.
A calm way through the build
Collect four small wins
mb-01says hello.Prove the garden connection first.
- Each witness has a raw display.
Test PIR, tilt, and GY-6500 separately.
- One fixed scene produces a repeatable record.
Build the trial loop before inventing the fusion rule.
- The verdict survives fresh trials.
Freeze the rule, add the servo gesture, and evaluate it without retuning.
The garden handshake
Share what you found
These names are the rigid part of the project. They let another team find your work without knowing what you called the variables in your code.
Motion verdict
garden/workshop/motion-node/mb-01/motionUnit: enum
Accepted events
garden/workshop/motion-node/mb-01/countUnit: events
Listen beyond your own device.
garden/entrance/counter/gk-01/countThe entrance counter supplies another aggregate event stream. Compare busy and quiet periods, but do not pretend the same event was seen by both devices.
Finish line
Ready to introduce to the garden
mb-01 stays online and publishes motion verdict and event count.
The reject feed stays clear after the final code starts.
The device reads the Gate Keeper count topic.
The display and servo distinguish raw clues from the combined verdict without blocking messages.
The build log contains defined scenes, at least twenty trials per condition, delays, misses, false alarms, and an untouched evaluation run.
All sensors are fixed, the servo is safely powered, and the device label can be scanned.
The goal is not to make three sensors agree. It is to understand what each witness can see, then build a rule that deserves its confidence.