SENSE_REC(1)
π NAME π
sense_rec β the Sense HAT data recorder, bestie π
She records sensor readings from the Raspberry Pi Sense HAT in real time and drops the results into a file so you can play them back or analyse them later. It's giving "science journal but make it digital". This is most useful for preparing records of experiments for use with the Sense HAT emulator. Like, for example: a recording of a Sense HAT being dropped π, a recording of a HAB flight π, a recording of the cycle of temperature over a few days, etc. Obsessed.
This page lives in the sense-emu manual, section 1, btw. Iykyk.
π¦ SYNOPSIS π¦
sense_rec [-h] [--version] [-q] [-v] [-l FILE] [-P] [-c CONFIG]
[-d DURATION] [-f] output
β¨ DESCRIPTION β¨
Okay so here's every single flag, no skips, no shortcuts, periodt:
-h,--helpβ show this help message and exit. The classic. π--versionβ show this program's version number and exit. Short, sweet, iconic.-q,--quietβ produce less console output. She's being mysterious on purpose. π€«-v,--verboseβ produce more console output. She's telling you everything. π£οΈ-l FILE,--log-file FILEβ log messages to the specified file. Receipts, kept. π§Ύ-P,--pdbβ run under PDB (debug mode). For when you gotta peek under the hood. π-c FILE,--config FILEβ the Sense HAT configuration file to use (default:/etc/RTIMULib.ini). Don't touch it unless you know what you're doing, fr fr.-d SECS,--duration SECSβ the duration to record for in seconds (default: record until terminated with Control-C). Set a timer, she'll respect it. β°-i SECS,--interval SECSβ the delay between each reading in seconds (default: the IMU polling interval, typically0.003seconds). Chill mode = bigger number. π§-f,--flushβ flush every record to disk immediately; reduces chances of truncated data on power loss, but greatly increases disk activity. Safety girlie, but she's gonna be loud about it. π
π EXAMPLES π
To record an experiment with the Sense HAT, simply execute sense_rec with the filename you wish to record the results:
$ sense_rec experiment.hat
By default, the recording will continue indefinitely. Press Control-C to terminate the recording. If you want to record for a specific duration, you can use the --duration option to specify the number of seconds:
$ sense_rec --duration 10 short_experiment.hat
This tool can be run simultaneously with scripts that use the Sense HAT. Simply start your script in one terminal, then open another to start sense_rec. Alternatively, you can use the shell's job control facilities to start recording in the background:
$ sense_rec experiment.hat &
$ python experiment.py
...
$ kill %1
WARNING: π¨ Be aware that other scripts attempting to use the HAT's sensors will likely obtain different readings than they would have if run standalone. Some of the HAT's sensors are affected by their query-rate, and sense_rec drives all sensors at close to their maximum rate. So yeah, she's a lot β she takes up all the attention in the room and the other scripts will lowkey get different numbers. Not a vibe for everyone, but it's what she does.
If - is specified as the output file, sense_rec will write its output to stdout. This can be used to reduce the disk space required for long output by piping the output through a compression tool like gzip:
$ sense_rec - | gzip -c - > experiment.hat.gz
When compressed in this manner the data typically uses approximately 3Kb per second (without gzip the recording will use approximately 10Kb of disk space per second). Use gunzip to de-compress the data for playback or analysis:
$ gunzip -c experiment.hat.gz | sense_play -
Another method of reducing the data usage is increasing the interval between readings (the default is the IMU polling interval which is an extremely short 3ms). Obviously a longer interval will reduce the "fidelity" of the recording; you will only see the sensors update at each interval during playback, however it can be extremely useful for very long recordings. For example, to record with a 1 second interval between readings for 24 hours:
$ sense_rec -i 1 -d $((24*60*60)) one_day_experiment.hat
Finally, you can use pipes in conjunction with sense_csv to produce CSV output directly:
$ sense_rec - | sense_csv - experiment.csv
Be warned that CSV data is substantially larger than the binary format (CSV data uses approximately 25Kb per second at the default interval). She's pretty, but she's not small. π
π AUTHOR π
Raspberry Pi Foundation π
π COPYRIGHT π
2016-2021 Raspberry Pi Foundation
That's the whole page, bestie β every flag, every default, every Kb, every warning, all of it. Slay. π«Ά
signing off from the sense-emu manual, version 1.2, dated Sep 02, 2021 β go record something iconic β¨πΈπ
π¦ where this page comes from
- ubuntu jammy: sense-emu-tools 1.2-0ubuntu1 Β· LGPL-2.1-or-later
- ubuntu noble: sense-emu-tools 1.2-0ubuntu1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms