-
Notifications
You must be signed in to change notification settings - Fork 0
Sensors
- Introduction
- The five senses
- Which page do I want
- What every sensor has in common
- Testing a sensor before you trust it
This is the overview page for everything Otto can perceive. Each sensor has its own page with the full story; this one is the map, plus the habits that apply to all of them.
| Facade | Module | Hardware | Needs enabling |
|---|---|---|---|
Eyes |
Ultrasonic |
HC-SR04 distance sensor | No |
Touch |
TouchSensor |
TTP223 touch pad, or a push button | No |
Ears |
SoundSensor |
Analog microphone | No |
| -- | LightSensor |
Photoresistor (LDR) | No |
Balance |
Mpu6050 |
MPU-6050 / GY-521 motion sensor | Yes |
Sensors on analog and digital pins need no initialisation: an unconnected pin simply returns noise, and the call is harmless. The MPU-6050 is the exception -- it speaks I2C, and must be enabled in the configuration.
- Eyes -- distance to whatever is in front: obstacle avoidance, follow-me, "is someone there".
- Touch -- a tap or a held finger: start a behaviour, toggle a mode.
- Ears -- loudness: clap detection, reacting to a room getting noisy.
- Light -- brightness: sleep in the dark, wake in the light.
- Balance -- tilt and shake: is Otto level, upside down, being picked up.
Three habits carry across all five, and each is covered in depth on its own page:
-
Prefer the question to the number.
Eyes::closerThanCm(15)andEars::hearsSoundLouderThanPercent(60)read as sentences and keep thresholds visible. Reach for the raw value when you need to compare it against several things at once. - Find thresholds empirically. Every percentage on these pages depends on your hardware, your room, and in the microphone's case a physical gain pot. Measure first in the console, then choose.
- Reading takes time. A distance ping waits for an echo; a loudness reading listens for a 50 ms window. Sensor calls are not free, and while a movement call is blocking, nothing is being sensed at all.
Do not debug a sensor from inside a behaviour. Bring it up on its own in the Serial Console:
> dist
23 cm
> touch
touched
> light
64 %
> mic
12 %
> tilt
pitch -1.4 roll 0.8
> watch mic
watch streams a sensor live and prints only when the value actually changes, so you can wave a hand or clap and watch the numbers follow. It is the fastest way to tell a miswired sensor from a badly chosen threshold -- and the two look identical from inside a sketch.
OttoFlow is licensed under GPL-3.0 and wraps OttoDIYLib. Buy the kits at ottodiy.com.
Prologue
Getting Started
The Basics
Digging Deeper
- Bench Testing
- Serial Console
- Calibration
- Bluetooth and the Otto App
- Modules
- The Driver
- Extending OttoFlow
Reference