Skip to main content

Dummy sensor data generator for testing IoT/ML pipelines

Project description

dummysensors

PyPI version CI License: MIT

A lightweight generator of dummy sensor data for IoT and ML testing. Provides a simple Python API and CLI, supports running multiple sensors in parallel and splitting output streams into files.

Installation

pip install -e .
# for development:
pip install -r requirements.txt

Quick Start (API)

from dummysensors import TemperatureSensor, VibrationSensor

# create sensors
temp = TemperatureSensor(min_val=18, max_val=24, noise=0.2)
vib  = VibrationSensor(base_hz=50.0, amp=1.0, noise=0.05)

print(temp.read())            # e.g. 21.3
print(vib.read(t_s=0.123))    # sinusoidal signal with noise

Quick Start (CLI)

Generate a single temperature stream to JSONL:

dummy-sensors generate --rate 5 --duration 2 --jsonl out/temp.jsonl

Run multiple sensors and devices, split by type into separate files:

dummy-sensors run \
  --rate 5 \
  --count 30 \
  --spec "device=engine-A: temp*1,vibration*2; device=room-101: temp*2" \
  --out "temp=out/temp.jsonl" \
  --out "vibration=out/vib.jsonl" \
  --out "*=stdout"

👉 Check out a full demo with live plotting and JSONL logging here:
dummysensors demo (ds-test)

Each record is a JSON line:

{
  "ts_ms": 1234,
  "device_id": "engine-A",
  "sensor_id": "temp-0",
  "type": "temp",
  "value": 21.04
}

--spec format

The --spec string describes devices and sensors:

device=<ID>: <type>*<count>[, <type>*<count> ...] ; device=<ID2>: ...

Examples:

  • device=A: temp*3 — device A with three temperature sensors
  • device=eng: temp*1,vibration*2; device=room: temp*2

As of v0.2, supported sensor types: temp, vibration. More sensors and YAML configs coming soon.

Python API

TemperatureSensor

  • Parameters: min_val=15.0, max_val=30.0, noise=0.5, period_s=86400
  • Methods:
    • read(t_s: float | None = None) -> float — one sample (random within range + Gaussian noise)

VibrationSensor

  • Parameters: base_hz=50.0, amp=1.0, noise=0.1, spike_prob=0.0
  • Methods:
    • read(t_s: float | None = None) -> float — sinusoidal signal at base_hz + noise

Sensor Registry

  • dummysensors.registry.SENSOR_REGISTRY — maps string kind → class
  • dummysensors.registry.make_sensor(kind: str, **params)

Orchestrator

  • dummysensors.orchestrator.run_stream(spec_str, rate_hz, duration_s, total_count, writer_for_type)
    • Creates instances based on spec_str, emits samples at rate_hz.
    • writer_for_type is a dict type → callable(sample_dict). * = default writer.

Output Format

JSON Lines (one record per line):

{
  "ts_ms": 171234,
  "device_id": "engine-A",
  "sensor_id": "vibration-1",
  "type": "vibration",
  "value": -0.124
}

Planned: CSV, Kafka, Redis Stream, WebSocket.

Makefile

For convenience, run with make:

make venv        # create .venv and upgrade pip
make install     # pip install -e .
make test        # pytest
make demo        # generate demo data into demo_out/
make clean       # cleanup build and cache

After make demo, check the files:

head -n 3 demo_out/temp.jsonl
head -n 3 demo_out/vibration.jsonl

Development

  • Project layout: src-layout
  • Tests: pytest -q
  • Lint/format: ruff check src tests and ruff format

Pull Requests welcome. Guidelines:

  • Simple sensor classes
  • No heavy runtime dependencies
  • Test each public feature

Example Demo

  • A complete example using dummysensors for live plotting and JSONL logging is available in the ds-test repository.

Roadmap

  • v0.2
    • CSV writer
    • partition_by=device
    • YAML config (--config config.yaml)
  • v0.3
    • AnomalyInjector (spike, dropout, drift)
    • New sensors: humidity, rpm, battery_voltage, gps (trajectory), accel 3-axis
  • v0.4
    • Outputs: Kafka, Redis Stream
    • Live preview (WebSocket demo)

Versioning and Publishing

  • Semantic versioning with tags vX.Y.Z.
  • CI​: .github/workflows/ci.yml (lint + tests + build).
  • Publish​: .github/workflows/publish.yml (Trusted Publishing to PyPI on release).

License

MIT © Mateusz Dalke

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dummysensors-0.2.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dummysensors-0.2.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file dummysensors-0.2.0.tar.gz.

File metadata

  • Download URL: dummysensors-0.2.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dummysensors-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a0797a1e79674be1a128aae0a603c22d8963670f2c53dea87dfc961d09ae74a2
MD5 9297e1010d113b1dc91aad3115fc12f4
BLAKE2b-256 1e08f577fd8c19a64b9ede7e4bb57b81711e11816bcf2e6302c92cd9b2024097

See more details on using hashes here.

Provenance

The following attestation bundles were made for dummysensors-0.2.0.tar.gz:

Publisher: publish.yml on SculptTechProject/dummysensors

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dummysensors-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dummysensors-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dummysensors-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be814d37c9fd0c666cc91b78ec18bf67fc3e75b5f05a0bb9640d34e6ba1b450e
MD5 893cef9b78f9d40f0854a8937074145f
BLAKE2b-256 37d469de9d07130c3effe5c6a8d2c211aa295798ed8dbfa9af2bab9dd74774a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for dummysensors-0.2.0-py3-none-any.whl:

Publisher: publish.yml on SculptTechProject/dummysensors

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page