Finding signal in noisy street recording over 2 weeks

amlucas1 pts0 comments

blog - raspberry-pi-listener

Rhythms of a street

June 23, 2026

I bought a Raspberry Pi, a tiny computer that people have used for fun little robotic projects, house automation, game emulators or weather stations.<br>This isn't my first experience with this kind of device: in 2024 I used a toolkit from AMD as part of a robot that moves particles with fluids.

As a computational scientist, I usually see computers as tools for simulation and data analysis.<br>What attracted me here was a different use: turning a computer into an instrument that continuously observes the physical world.<br>I also bought a USB microphone for a few dollars, and wrote a short program to record the noise intensity in my bedroom for about two weeks.<br>Let's see if we find anything interesting.

The root-mean-square sound intensity over 10s and 1h intervals against time, in arbitrary units.

The signal is very noisy, partly because of the low-quality microphone, but mostly because the street under my window is a noisy place.<br>Nevertheless, a simple moving average reveals some expected patterns.<br>There are clear peaks in the morning and evenings, corresponding to rush hours, when the traffic is the heaviest.<br>It is also easy to distinguish the nighttime, when it is a lot quieter.<br>The large peak in the night of May 21st corresponds to my AC unit fighting the particular high heat of that day.

We can observe this daily repetition when we look at the autocorrelation of the signal:

There is again a clear peak around 24 hours, although the correlation is relatively weak.<br>(By the way, computing an autocorrelation is very similar to a convolution, which can be done efficiently using FFTs.)<br>The autocorrelation still looks noisy.<br>Let's zoom in:

Surprisingly, among all the apparent noise, we see very clear oscillations.<br>Their period is around 85 seconds.<br>This was actually the time scale I was hoping to find: the traffic light cycle around the block.<br>I measured it on my walk home and the agreement is surprisingly good.

This was the first experiment with my Raspberry Pi.<br>I had no specific questions other than: how noisy is my street when I am not paying attention?<br>Despite the relatively cheap microphone, I found surprisingly rich dynamics at multiple time scales.<br>Right now my Raspberry Pi isn't listening anymore, but I might make it watch soon...

The figures were produced with the following scripts:

Show code

#!/usr/bin/env python

import argparse<br>import matplotlib.pyplot as plt<br>import matplotlib.dates as mdates<br>from matplotlib.lines import Line2D<br>import numpy as np<br>import pandas as pd

def main():<br>parser = argparse.ArgumentParser()<br>parser.add_argument('audio_csv', type=str, help='rms data')<br>parser.add_argument('--save', type=str, default=None)<br>args = parser.parse_args()

tz = "America/New_York"

df = pd.read_csv(args.audio_csv)

rms_scale = df["rms_mean"].mean()<br>df["rms_mean"] /= rms_scale<br>df["rms_max"] /= rms_scale<br>df["peak_max"] /= rms_scale

df["time"] = pd.to_datetime(df["interval_start_utc"], utc=True, format='ISO8601').dt.tz_convert(tz)<br>df = df.sort_values("time")<br>df = df.set_index("time")

df["rms_30m"] = df["rms_mean"].rolling("30min", center=True).mean()<br>df["rms_1h"] = df["rms_mean"].rolling("1h", center=True).mean()

fig, ax = plt.subplots()

ax.plot(df.index, df["rms_mean"], '.', ms=0.1, c='C0', label='10s window')<br>ax.plot(df.index, df["rms_1h"], '-', lw=1, c='C1', label='1h window')

ax.xaxis.set_major_locator(mdates.AutoDateLocator())<br>ax.xaxis.set_major_formatter(<br>mdates.DateFormatter("%b %d")<br>plt.setp(<br>ax.get_xticklabels(),<br>rotation=45,<br>ha="right",<br>ax.set_ylabel("RMS energy")<br>ax.set_ylim(0.0, 5)

legend_elements = [<br>Line2D(<br>[0], [0],<br>marker='.',<br>linestyle='None',<br>color='C0',<br>markersize=6,<br>label='10s window'<br>),<br>Line2D(<br>[0], [0],<br>color='C1',<br>lw=1,<br>label='1h window'<br>),

ax.legend(handles=legend_elements)

plt.tight_layout()<br>if args.save:<br>plt.savefig(args.save)<br>else:<br>plt.show()

if __name__ == '__main__':<br>main()

Show code

#!/usr/bin/env python

import argparse<br>import matplotlib.pyplot as plt<br>import numpy as np<br>import pandas as pd

def main():<br>parser = argparse.ArgumentParser()<br>parser.add_argument("audio_csv", type=str, help="rms data")<br>parser.add_argument("--max-lag-hours", type=float, default=24.0)<br>parser.add_argument("--minutes", action="store_true", help="show x axis in minutes instead of hours")<br>parser.add_argument("--save", type=str, default=None)<br>args = parser.parse_args()

df = pd.read_csv(args.audio_csv)

df["time"] = pd.to_datetime(df["interval_start_utc"], utc=True, format="ISO8601")<br>df = df.sort_values("time").set_index("time")

x = df["rms_mean"] / df["rms_mean"].mean()

dt = "10s"<br>x = x.resample(dt).mean().interpolate()

dt_seconds = pd.to_timedelta(dt).total_seconds()<br>max_lag_samples = int(args.max_lag_hours * 3600 / dt_seconds)

y = x.to_numpy()<br>y -= y.mean()

# FFT-based autocorrelation — O(n log n), avoids O(n^2) loop<br>n = len(y)<br>yf = np.fft.rfft(y, n=2 * n)<br>acf = np.fft.irfft(yf * np.conj(yf))[:n].real<br>acf /=...

import parser time mean args rms_mean

Related Articles