Introduction
Mocking Internet of Things (IoT) sensor data that would otherwise be difficult to gather on a large scale can provide a valuable approach to facilitate experimental analyses, projects, and studies. However, this requires much more than generating random values: it requires a chronological timeline, device metadata, and the need to reflect natural environmental fluctuations or patterns like seasonality. Mimesis is a great open-source tool for generating fake data, while a pinch of math can be integrated into a code-based solution to handle the latter: this article shows how.
With the step-by-step guide below, I’ll walk you through the process of generating a year’s worth of daily temperature readings, mimicking a seasonal curve that looks real – all with device-level metadata and ready to build based on open-source frameworks.
Step by Step Guide
We will rely on three key Python libraries to create our set of IoT sensor readings throughout the year: Mimesis for generating synthetic data, pandas to manage the scaffolding of time series, and NumPy to do some calculations, leading us to mimic seasonal patterns.
Keep in mind that real-world IoT time series datasets are typically tied to a concrete device. The way to emulate this, with the help of Mimesis, is to use the generic vendor class and generate a realistic hardware device profile: our “mock 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 the English language
g = Generic(locale=Locale.EN, seed=101)
# Generating static metadata for our simulated 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 fictional sensor: ID, location, firmware version, and IP address. It will look like:
Tracking device: e88b7591-31db-4e32-98dc-b35f94c662cd located in ParagouldNow, before generating the time series, we will define an equation to emulate the seasonality pattern needed to reflect temperature readings throughout a year. As you might have guessed, trigonometric functions like sine wave are perfect for reflecting this type of sine wave-like pattern throughout the year. Our equation will therefore be based on just one:
Here, T represents the temperature, and we go through the whole year, day by day, to generate the daily timeline. Pandas will govern the data creation process, while Mimesis.numeric will be used to inject not only the aforementioned environmental noise, but also realistic network latency: a common sight in IoT devices. All of these elements add to the basic mathematical equation defined previously. NumPy’s role, on the other hand, is to apply the sine function as part of the generation process.
#1. Setting up mathematical constants to emulate daily temperature
T_base = 15.0 # Base temperature in Celsius
A = 12.0 # Fluctuates 12 degrees up and down throughout the year
phase_shift = 80 # Shifts the sine wave so that the peak falls in summer
#2. Creating the 365-day time series from the dates of January 1, 2026
dates = pd.date_range(start="2026-01-01", periods=365, freq='D')
readings = []
#3. Cycle through each day and calculate the readings
for day_index, current_date in enumerate(dates):
# Calculate the baseline of the seasonal curve for that 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)
# Calculation of the final recorded temperature
final_temp = round(seasonal_temp + sensor_noise, 2)
# Compilation of the daily recording, mixing static metadata with dynamic generation from Mimesis
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) # Mocks network connection strength/latency fluctuations per day
})
# Convert to DataFrame for analysis
df = pd.DataFrame(readings)
As you can see, we use Mimesis twice in the time series generation process for each daily instance of the time series: once for sensor noise and once for latency, the latter mimicking the fluctuations in the network connection each day.
It’s time to see what the generated IoT time series looks like and check the seasonal pattern we tried to imitate:
print("--- January readings (winter) ---")
print(df[['timestamp', 'temperature_c', 'latency_ms']].head(3))
print("n--- July Readings (Summer) ---")
print(df[['timestamp', 'temperature_c', 'latency_ms']].iloc[180:183])
Output:
--- January readings (winter) ---
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 readings (summer) ---
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 a more visual result, 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()
Congratulations if you made it this far!
Concluding Remarks
In this article, we showed how to use Mimesis combined with pandas and NumPy to illustrate the generation of fake but convincing IoT time series data. In particular, we illustrated the process of creating a year-round dataset of daily temperature readings collected from an IoT sensor, including device-related metadata, random noise to emulate realistic temperature changes, and device latency. This data can be leveraged by downstream forecasting models or even dashboard solutions: they will surely ingest it and help interpret aspects such as seasonal peaks, common sensor fluctuations, etc.
Ivan Palomares Carrascosa is a leader, writer, speaker, and advisor in AI, machine learning, deep learning, and LLM. He trains and guides others in leveraging AI in the real world.
Read more Here.
“`

