ANI

Mock up a year of IoT Sensor Time Series Data with Mimesis

# Introduction

Sarcasm Internet of Things (IoT) sensor data. that can be difficult to collect at scale can form an important tool to facilitate analysis, projects, and pilot studies. However, it requires more than random value generation: it requires a chronological timeline, device metadata, and the need to reflect environmental fluctuations or patterns such as seasonality. Mimesis is an excellent open source tool for generating fake data, while a bit of math can be combined with a code-based solution to deal with the latter: this article shows how.

In the step-by-step guide below, I'll walk you through the process of generating a year-round value for daily temperature readings, simulating a realistic-looking seasonal curve — all combined with device-level metadata, and ready to build based on open source frameworks.

# Step by Step Guide

We'll rely on three key Python libraries to build our year-round set of IoT sensor learning: mimesis generating synthetic data, the pandas of dealing with the time series' scaffolding, and NumPy by doing math, which leads us to mimic seasonal patterns.

Keep in mind that real-world IoT time series data sets are often tied to a tangible device. A way to mimic this, aided by Mimesis, is to use Generic provider class and generate a physical hardware device profile: “our fictional sensor”, so to speak. This is done before creating the actual daily readings:

import pandas as pd
import numpy as np
from mimesis import Generic
from mimesis.locales import Locale

# Initializing a generic provider for English language
g = Generic(locale=Locale.EN, seed=101)

# Generating static metadata for our mock IoT device
device_profile = {
    'device_id': g.cryptographic.uuid(),
    'location': g.address.city(),
    'firmware_version': g.development.version(),
    'ip_address': g.internet.ip_v4()
}

print(f"Tracking Device: {device_profile['device_id']} located in {device_profile['location']}")

note that device_profile is a dictionary containing the metadata of our proposed sensor: identifier, location, firmware version, and IP address. It will look like this:

Tracking Device: e88b7591-31db-4e32-98dc-b35f94c662cd located in Paragould

Now, before generating the time series, we will define an equation to simulate the seasonal pattern needed to display temperature readings throughout the year. As you might have guessed, trigonometric functions like sine are good for showing this kind of annual pattern that looks like a sine wave, so our calculation will be based on one:

[
T

Here, (T

Next, we iterate through the year, day by day, to create a daily timeline. pandas will dominate the data creation process, while mimesis.numeric it will be used to inject not only the spatial noise mentioned above, but also the real network delay: a common feature in IoT devices. All of this goes on top of the basic mathematical equations explained earlier. The role of NumPy, meanwhile, is to use the sine function as part of the generation process.

# 1. Setting up mathematical constants for emulating daily temperature
T_base = 15.0       # Base temperature in Celsius
A = 12.0            # Fluctuates by 12 degrees up/down throughout the year
phase_shift = 80    # Shift the sine wave so the peak falls in the summer

# 2. Creating the 365-day time series starting Jan 1, 2026
dates = pd.date_range(start="2026-01-01", periods=365, freq='D')

readings = []

# 3. Looping through each day and calculating the readings
for day_index, current_date in enumerate(dates):
    
    # Calculating the seasonal curve baseline for this specific day
    seasonal_temp = T_base + A * np.sin(2 * np.pi * (day_index - phase_shift) / 365)
    
    # Using Mimesis to inject random hardware variance/noise (e.g., -2.0 to 2.0 degrees)
    sensor_noise = g.numeric.float_number(start=-2.0, end=2.0, precision=2)
    
    # Calculating final recorded temperature
    final_temp = round(seasonal_temp + sensor_noise, 2)
    
    # Compiling the daily record, mixing static metadata with dynamic Mimesis generation
    readings.append({
        'timestamp': current_date,
        'device_id': device_profile['device_id'],
        'location': device_profile['location'],
        'temperature_c': final_temp,
        'latency_ms': g.numeric.integer_number(start=12, end=145)       # Mocking network connection strength/latency fluctuations per day
    })

# Converting to a DataFrame for analysis
df = pd.DataFrame(readings)

As you can see, we use Mimesis twice in the process of generating the time series for every day of the time series: once for the noise of the sensor, and for the delay, the latter simulating the daily fluctuations of the network connection.

Time to see what the generated IoT time series looks like and confirm the seasonal pattern we tried to simulate:

print("--- January (Winter) Readings ---")
print(df[['timestamp', 'temperature_c', 'latency_ms']].head(3))

print("n--- July (Summer) Readings ---")
print(df[['timestamp', 'temperature_c', 'latency_ms']].iloc[180:183])

Output:

--- January (Winter) Readings ---
   timestamp  temperature_c  latency_ms
0 2026-01-01           3.54          61
1 2026-01-02           4.90         103
2 2026-01-03           3.18         140

--- July (Summer) Readings ---
     timestamp  temperature_c  latency_ms
180 2026-06-30          28.84         116
181 2026-07-01          25.81          62
182 2026-07-02          26.08          97

For another visual effect, why not try this:

import matplotlib.pyplot as plt

plt.figure(figsize=(12, 6))
plt.plot(df['timestamp'], df['temperature_c'])
plt.xlabel('Date')
plt.ylabel('Temperature (°C)')
plt.title('Daily Temperature Throughout the Year')
plt.grid(True)
plt.tight_layout()
plt.show()

Daily IoT temperature readings generated with Mimesis

Great if you made it this far!

# Final Words

In this article, we showed how to use Mimesis combined with pandas and NumPy to demonstrate the generation of fake but convincing IoT time series data. In particular, we demonstrate the process of creating a year-long dataset of daily temperature readings collected from an IoT sensor, including device-related metadata, random noise to simulate realistic temperature changes, and device latency. This data can be used by downstream forecasting models or dashboard solutions: they will import it and help define factors such as seasonal peaks, general sensor fluctuations, and so on.

Iván Palomares Carrascosa is a leader, author, speaker, and consultant in AI, machine learning, deep learning and LLMs. He trains and guides others in using AI in the real world.

Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button