Jaldi Labs

Aa Jao!

Monitoring train noise – part २

As of May 1st, we have a continuous sound level monitoring system setup outside on our terrace.

This idea has been pending for well over a year, but FUD about installing the system outdoors held things back. How would I power it? I can’t find a low-voltage waterproof wall-wart! What about our dogs barking? Shouldn’t it be on the other side of the building?

Since the system is running continuously, averaging and uploading readings every 20s, there’s no way it’s ‘low-power’, and it has to be plugged in. I can’t use solar as I originally planned. So I finally broke down and bought a cheap weatherproof 12V converter and waterproof extensions via AliExpress, installed a new waterproof outdoor in-use cover for the terrace outlet, changed the on board supply from a 5V linear regulator to a buck regulator, and built a little 4″ pvc house for the board and sound level monitor.

It works good!  This plot shows noise levels for the past 8 hours and is updated every 5 minutes:

Interestingly, there were relatively few trains over the last week while I was testing things out, but suddenly this morning at the unusual time of 6:40am (usually the night train arrives ~4am) a train was passing through and making a hell of a lot of noise. I figured today was the day to finalize the first phase of the installation and get some useful graphics up.

Since the image above is updating real-time, below I have a snapshot of the ‘first-day’ data so that I can reference it as I’m writing this.  One issue with the data representations in my original post was that the simple plots generated with ThingSpeak are very ‘full of stuff’ (see them here). You could see what was going on, but, yeah.

The train this morning (and two subsequent trains) made it easy to come up with a way to represent the data cleanly (at least I hope so!).

Each of the dark spikes of data points in the plot is a train passing through.

The 8:40am train is at left.

Absent trains, the average city-background sound level during this period is on the order of ~56dB. As the trains pass through, the peak 20 second averaged dB levels range from 80-86dB. The monitor is located ~270 feet from the tracks.

First-day Data

What next? There’s a lot we can do with this. To be continued…


An aside – the trick for the representation in the image was to come up with a MATLab scheme to change the plot point sizes so that the continuous background noise levels were de-emphasized, and the train noise popped out. (The second trick was to ignore the maximum sound levels in each interval. That picks up our dogs freaking out about the neighbors and barking at the other dogs in the building.)

Since I’ve never used MATLab before, it took some time to get in tune with how it thinks. So for reference, here’s the key part of the code:

numberOfMinutes = 480;
color = [0 0 0.5];

%% Read in two data arrays – ‘data’ (the sound levels)
%% and & ‘time’ (the timestamps)
[data, time] = thingSpeakRead(readChannelID, ‘Field’, fieldID, ‘NumMinutes’, numberOfMinutes, ‘ReadKey’, readAPIKey);

%% Generate a logical array (‘cut’) that represents data
%% points > 60dB. It’s all about array operations here.
cut = data>60;

%% Generate an array that maps spot size to data values
%% based on the cutoff criteria. Array operation, again.
spotSize = 20*cut + 2;

%% Generate the scatter plot, using the spotSize array to
%% specify the size of individual data points.
s=scatter(time, data, spotSize, color, ‘filled’);

Monitoring train noise – part १

What’s the train noise like at Burnham Station? This is data from a prototype, but it was super-easy to setup. Right now it’s sitting in the ‘lab’ with the window open, taking an averaged reading every 20 seconds and uploading it to Thingspeak.

Let’s see what we get…

A huge thanks to user RING67630 at the Arduino Forums for identifying this cheap, hackable, sound level meter. Powered from a 9V source -> Linear Regulator -> 5V to Particle Photon and ‘Digital Sound Level Meter‘ -> reading 10mV/dB from the DC output jack. Took a couple of hours to assemble and code.

The plan is to get this outside in a rain-proof open box and start managing a real-time record of sound levels around here… And, v2.0 will be solar powered

Let’s listen for the trains, shall we?

Here’s an updated plot including the smoothed ‘average’ and ‘maximum’ reading during each period.

And… more (scatter plot of the averaged dB):

And (scatter plot of the max dB):

 

Edited 5.2.20 – Changed post title and updated plot references. This project has finally moved forward and the data is live. Will update shortly.

 


Context: 

Soldering Iron Timer – part २

A lot of people have set up timers for their soldering irons… There’s the built-in outlet timer approach:

Almost burned my house down a couple times. Had to make this.

There’s the drop a relay into the power circuit approach:

The 30 Minute Soldering Iron Timer Module / DIY Electronics Kit

And then I came across this – the interface with a remote controlled relay approach:

Use Arduino to Interface with a Remote Controlled Power Switch

What’s interesting here is that “… to use my Arduino to interface with this power switch, all I need to do is to simulate a button press by sourcing a positive voltage to wires labeled SW1, SW2, SW3 etc.” So this is cool – RAYSHOBBY‘s goal was to use a microcontroller to control an outlet – so he modified the fob. My goal was to introduce a timer circuit to control an outlet. Let’s modify the fob!

And realized that I already had what I needed – I use one of these “Woods 32555WD” wireless remote kits to control a fan in my office at work:

And I figured I’d follow the strategy above “simulate a button press by sourcing a positive voltage to wires labeled SW1, SW2, SW3 etc.” So I took a look at the fob circuit board, noting the connections from the switches to the controlling IC, and tried to simply supply 5V from an Arduino to the ‘On’ and ‘Off’ pins. Nope.

So, time to understand the fob circuit.  Here’s the board:

Since, generally, “I don’t know anything, what’s this?” it took a little time figure out how the circuit works. A battery supplies 12V to the circuit. The ‘on’ and ‘off’ switches are connected to pin 7 (‘on’) and pin 6 (‘off’) of the U1 IC. Power to the circuit is controlled by the transistor Q1 (at left on the right). A bunch of radio stuff is at the top right (right image).

The parts of the circuit that matter for what I wanted to do are diagrammed in the two images below.

The 12V supply is at left. The pins of the two switches are at the center. The pins of the IC are at the bottom. When the both SW1 and SW2 are open (left image), the traces in blue are at GND, the traces in ‘red’* are at 12V.

When the SW1 ‘on’ button is closed (right image), the trace in blue is at GND, the trace in ‘orange’* is at 8.5V, and the traces in ‘yellow’* are at 3.5V.

So in the case shown, pin 7 of the IC was at GND, but is momentarily pulled up to 3.5V. (And radio magic then happens to send an ‘on’ signal to the relay remote to switch power on for the device connected to it).

 

There are two things going on that matter, and that affect the approach I took to make this work.

When the switches are open, R1 pulls up the base of Q1 to 12V, and net COM is held at 12V.  The pins Pin6 and Pin7 of U1 are held at GND by the pulldowns R6 and R7.

When a switch is closed, a voltage divider between 12V and GND forms such that the base of Q1 goes to 8.5V, and nets COM and PIN7_ON (or PIN6_OFF) go to 3.5V. The B-E differential turns Q1 on and powers the system. So PIN7 (or, PIN6) of U1 is pulled HIGH.

What I had tried to do in my first attempt was simply to supply 5V to either PIN6 or PIN7. This doesn’t work. Why? Because the buttons tell the IC what to do (‘on’ or ‘off’), but they also turn on the whole circuit (by drawing the base voltage down and turning on the transistor Q1).

So, after figuring out what’s going on it was pretty simple to come up with a strategy – (a) Use the manual ‘on’ switch to turn the system on, and monitor the PIN7_ON net so that a timer starts with the net goes HIGH. We can use an N-MOSFET to capture that and send a signal to the board and start a timer. And (b) when the timer is done, close the connection between COM and PIN6_OFF (mimicking SW2_OFF). We can use an optocoupler inserted in parallel to SW2 for that.

Connected some wires, breadboarded it…

 

…then designed a little PCB to adapt an Arduino-based Extracore-type board (supplied by a 5V buck regulator) to start a timer and control an optocoupler to turn the switch off.  Prototyped it, set up some simple code, and there you go…

It even almost fit into the fob case, but I still had to cut the back off (and that’s why there’s a hole covered in kapton tape in the final version now).

And it actually worked… for a day or two. 

I hadn’t thought much (at all) about the battery. The fob’s 12V is supplied by an A23 battery.

But an A23 battery (which is just a stack of eight 1.5V button cell batteries) only has a capacity of about 55 mAh.

An Arduino Uno will draw ~50mA when it’s running, and an ATMega328 processor without all the ‘stuff’ (pretty much what an Extracore is) will draw ~15mA. So an A23 battery could only supply my setup for a few hours, that’s it. Without careful power management, there’s no way my simple-minded idea was going to work.

There was a problem to be solved.

To be continued… 

Part 1 here.


* I’m red/green color-blind

 

Soldering iron timer – part १

So, the idea was to avoid burning down the house if I forgot to switch off the soldering iron.

This was actually a very cool circuit to figure out.

The original idea was to have the timer small enough to fit inside the fob for a wireless remote switch. But to accommodate my first idea I had to cut out the back of the fob to fit three boards – an Extracore Arduino, a buck regulator, and an optocoupler adapter. It was too big, and it used way to much power.  So the hole is still there, and now it’s covered with kapton tape.

This version of the timer board is much smaller, works, and should fit completely inside the case.

Here’s the board – it’s based on a LTC2956-1 wakeup timer chip. (The LTC2956 is the little square guy near the top left.)

Here it is wired to the remote switch circuit. There’s an LED lit up – it’s timing!

Here’s the switch –

Power is from a 12V ‘23A‘ battery used by the fob circuit. There are basically three parts to the timer board – the LTC2956 chip which is powered by the 12V input and which is triggered by the fob ‘on’ circuit, a 74HC73 JK flipflop to handle an issue with the timer logic, and a VOS618A optocoupler to trigger the fob ‘off’ circuit. Plus a couple of MOSFETs and a voltage regulator to supply the 74HC73.

Turn it on, and 20 minutes later it powers off. Woohoo!

I’ll write up the logic of the fob circuit and how the board integrates with it in part 2. And at some point I’ll get the files up on Github.

To be continued

Air quality monitor – part १

Built a system based on the Omron B5W LD0101 air quality sensor.

Three components – the sensor, a Particle Photon, and an EA DOGM lcd display.

Code turned out to be super easy. I’ll update later.

For now while I’m developing this, here’s the raw data (via Thingspeak) –

2.5 micron raw counts: