SENSE_REC(1) | sense-emu | SENSE_REC(1) |
sense_rec - Sense HAT data recorder
Records sensor readings from the Raspberry Pi Sense HAT in real time, outputting the results to a file for later playback or analysis. This is most useful for preparing records of experiments for use with the Sense HAT emulator. 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.
sense_rec [-h] [--version] [-q] [-v] [-l FILE] [-P] [-c CONFIG] [-d DURATION] [-f] output
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:
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).
Raspberry Pi Foundation
2016-2021 Raspberry Pi Foundation
September 2, 2021 | 1.2 |