Category Archives: Raspberry Pi

12 Volt trigger for audio amplifier – PCB version

Previously I wrote how I designed and implemented a 12 Volt trigger for an NAD audio amplifier. Some time ago I also designed a PCB version of it. Here you can find some photos and the Eagle schematic.

There is one error in the design: the GND pin of the Wemos D1 mini board is not connected to the ground plane. I solved it with an air wire.

Some of the differences to the previous version are that it now has a button, a 12V input trigger, and a status LED. The button allows to manually switch it on and off without having to use my mobile phone. The 12 V input trigger allows the amplifier to be switched on by and off by the Sonos Port that is also connected to the amplifier.

I am using Tasmota as the firmware which – besides the button to switch it on and off – allows control over a web interface and over MQTT. The Tasmota template for the configuration is the following: {"NAME":"12V trigger", "GPIO":[1,1, 1,1,32,288,0,1,256,1,160,1,1,1], "FLAG":0, "BASE":18}.

The MQTT interface makes it easy to implement some automation with Node-RED that I have running on a Raspberry Pi. The automation is the following: whenever the smart TV or the MacMini (used for music) are switched on, as detected by them returning a network ping on their IP address, then the amplifier switches on, and vice versa.

I also have it configured using Homebridge in my Apple Home environment, which allows the Home application on my iPhone or iPad to manually control it, besides the Tasmota web interface.

Combining all of these, the NAD amplifier is switched on and off by either

  • the manual button
  • the smart TV (detected by an IP ping)
  • the MacMini (detected by an IP ping)
  • the Sonos Port (detected by its 12V output trigger)
  • the Apple Home application on my iPhone/iPad
  • the Tasmota web interface

However, the automation is not perfect: when after an afternoon of listening to Sonos we switch on the TV and switch off the Sonos Port, the Sonos Port only falls asleep after a minute or so. Consequently, the last action happens to be the Sonos Port 12V output going low; the amplifier therefore switches off after a minute or so, whereas we just switched the TV on. A quick press on the manual button switches it on again. Also, whenever we switch between MacMini, TV, or Sonos, we still have to walk to the amplifier to toggle it to the right audio input. An idea for the future is to mount an IR blaster that switches between the audio inputs automatically.

Wireless classroom conference microphone system – #5

This post is part of a series on designing a wireless microphone system for hybrid online meetings, i.e. with some people present in person and others present online. See also the previous post in this series.

So far I have built and experimented with 4 wifi microphones, including an on/off switch and a rechargeable LiPo battery. I also added a magnetic name tag holder like this to the back of each of the microphones, allowing them to be mounted on a shirt or the the lapel of a jacket. The most relevant parts comprise an INMP441 microphone connected to a Lolin32 lite board. I have a few more wired up with just the Lolin32 board and the microphone to allow testing a larger number.

I have also implemented a Python based server that is running on a Raspberry Pi zero W, which also functions as Wifi access point. The audio server buffers and mixes the incoming signal from the different microphones and plays it on a HifiBerry DAC+ zero audio card. The output is a line level voltage, strong enough to drive a headphone, and with some attenuation also suitable to feed into the microphone input of a low-cost USB headset adapter. The whole system works as expected, although the noise level of the microphones is higher than I had hoped. My guess is that it is in part due to the microphone being so close to the ESP8266 antenna. Also, the wires between the microcontroller and the microphone run over the Lolin32 board without any shielding, probably picking up EM interference.

The Arduino source code, the Python audio server code, and the Fusion360 CAD design files are available from the wifimic repository on Github.

The fact that it works with an USB headset adapter like this, i.e. a miniature external sound card, demonstrates that the device can also be connected to the standard Windows laptop “pink” microphone input.

My MacBook has a TRRS combined audio input/output and the TRS (stereo) cable that comes from the HifiBerry DAC audio card is not recognized as microphone when I plug it in, but over the USB headset adapter it works fine. There are Y-adapters to split the TRRS input into TRS for the headphone and a TS for the microphone that would allow connecting it. However, the Python audio server also works fine on macOS, which has the advantage that I can investigate the microphone audio signals in full quality. Rather than first converting the sound to a analog line-out on the Raspberry Pi, and then back into a digital representation by the USB headset adapter, I can use BlackHole or Soundflower to get the digital audio stream as it is generated by the microphone. A cool feature of BlackHole and Soundflower is that they support many channels. With some modifications to the Python server script, it will also be possible to stream the audio output of each microphone to each own channel, and record them with Audacity.

12 Volt trigger for NAD-D3020 amplifier

Update 3 January 2021 – mention that I am now using Tasmota firmware.

Update 26 February 2023 – I have followed this up with a PCB version that also includes a button and a 12 Volt input trigger for switching the 12 Volt output trigger.

The NAD D3020 is a hybrid digital audio amplifier with a combination of analog and digital inputs. I have been using it for quite some years now to play the sound of my Samsung smart TV over the living room speakers and for digital radio, iTunes and Spotify from my Mac mini. The Samsung is connected with an optical Toslink cable, the Mac mini is connected with a USB cable.

In the way the D3020 is placed in our media cabinet, its on/off button is not so easy to access. The D3020 remote control is really crappy and I find it anyway annoying to have to use multiple remotes to switch the power of all devices. Also, the status LEDs of the D3020 are dim and got considerably worse over time, especially for the OPT1 and the USB inputs that are for the TV and the Mac mini, and hence on most of the time. I guess that it uses OLEDs, which have degraded over time. Consequently, it happened quite often that we forgot to switch the amplifier off for the night.

However, the D3020 features a 12V trigger input port which allows the amplifier to be switched automatically on/off along with other gear. Of course, neither TV nor the Mac mini has a 12V output port, but both are connected to my home network; hence it is possible to detect over the network whether these are powered on.

Continue reading

Getting started with Pine64

UPDATE: see at the end for some problems that I encountered after the initial install.

The Pine64 is a single board computer that resembles the Raspberry Pi, but with a 64-bit CPU, up to 2GB of RAM and available for $15-$29. It was introduced with a Kickstarter campaign which I supported. My 2GB Pine64 has been lying on a shelf for quite some time, as I was waiting for the kernel, distribution and documentation to mature.

My first installation yesterday went fine (some slight troubles to get WiFi connected), but while updating the kernel, the root disk partition completely filled up and borked the installation. Hence I have to start again. Let me now document it, as I might need to repeat the installation more than a second time.

I primarily followed the instructions from https://www.pine64.pro/getting-started-linux/ with some additional information from http://forum.pine64.org/showthread.php?tid=982. I am working off an Apple MacBook Pro computer.

Continue reading

Raspberry Pi – getting the RFM12b to work

Now that I know how to blink a LED, it is time to move to slightly more interesting applications of the GPIO interface on the Raspberry Pi. I have a few Arduino modules in and around the house monitoring the climate and various other measures. They are all battery operated and send their information to a relay that forwards all data to Thingsspeak.

My current relay module consists of an Arduino Uno with an Ethershield, connected over i2c to another Arduino pro mini. The second Arduino is connected to a RFM12b module and uses JeeLib to receive data from the sensing modules. Would it not be nice to receive that data on a slightly more powerful platform and be able to do more with it than just forwarding it elsewhere…

Raspberry Pi with RFM12b

Raspberry Pi with RFM12b

I decided to give the rfm12b-linux kernel driver a try, as it explicitly supports the JeeLib format. I followed the instructions from rbi-source without problems. After changing the board type (RFM12B_BOARD) and group (RFM12B_DEFAULT_GROUP_ID) in rfm12b_config.h, the module compiled without problems. However, it would initially not load, showing errors in the dmesg output.

Following some suggestions here and here, I used rasps-config to disable the SPI, I2C and the Device Tree. After that, it did load and dmesg showed

[ 478.278166] rfm12b: added RFM12(B) transceiver rfm12b.0.1
[ 478.278391] rfm12b : driver loaded.

I compiled the example applications and used this

pi@hackpi:~/rfm12b-linux/examples/bin $ sudo ./rfm12b_read 

successfully opened /dev/rfm12b.0.1 as fd 3, entering read loop...

Fri Apr 29 20:07:50 2016
	32 bytes read
		4 0 0 0 115 24 0 0 87 14 109 64 102 230 11 65 41 44 124 68 
		0 0 192 127 0 0 192 127 115 162 189 253 
Fri Apr 29 20:08:14 2016
	32 bytes read
		2 0 0 0 59 77 2 0 122 233 110 64 210 225 148 65 0 0 192 127
		0 0 192 127 0 0 192 127 93 112 175 32 

showing two messages from two modules. I recognise the pattern as

typedef struct payload_t {
  unsigned long id;
  unsigned long counter;
  float value1;
  float value2;
  float value3;
  float value4;
  float value5;
  unsigned long crc;
};

belonging to the lm35 and bpm085 modules that are sending their data approximately every minute.

lm35

bmp085

Raspberry Pi – first steps to blink a LED with Python

I already purchased my first Raspberry Pi in 2011, but have been postponing connecting any electronics to its GPIO interface. Instead, I have been using it for more general computing applications (media center, web server, remote ssh access and tunnel, etc.). Rather than using the Raspberry Pi for in refacing with hardware and IOT, I have been using a bunch of Arduino’s to implement sensors and actuators for home automation.

Since I recently have been brushing off my Python programming skills for the EEGsynth project and been teaching myself Node JS, I was triggered to revisit the Raspberry Pi for GPIO electronics. With the Raspberry Pi it will be easier to implement my own web server and to use webhooks to integrate my home automation hardware projects with online platforms such as IFTTT.

I decided to try Python first and after browsing the web decided to use the WiringPi interface, as it supports C programming in the same style as on the Arduino, but also has wrappers for more high-level languages (Python, PHP, Ruby and Perl).

I started with installing the WiringPi library as per instructions

git clone git://git.drogon.net/wiringPi
cd wiringPi/
./build 

and tested it with a LED in series with a 680 Ohm resistor attached to the first GPIO pin, aka pin 17 on the Pi cobbler. I still have to wrap my head around the pin numbering, but understand that there are different numbering schemes.

Subsequently I ran the test from

cd examples/
make blink
sudo ./blink

and also tried out this on the Linux command line

gpio write 0 1
gpio write 0 0
gpio write 0 1
gpio write 0 0

This all worked as expected and the LED would nicely blink. I subsequently moved on with Python. Instead of following the detailed installation instructions, I simply tried

sudo pip install wiringpi

which worked like a charm. The following Python code

#### this is blink1.py #### 

import wiringpi
import time

wiringpi.wiringPiSetup()

wiringpi.pinMode(0,1)

while True:
    time.sleep(0.5)
    wiringpi.digitalWrite(0,1)
    time.sleep(0.5)
    wiringpi.digitalWrite(0,0)

works with sudo, i.e.

sudo python blink1.py

As with the pin numbering, it is still a bit of a puzzle to me when super user rights are needed and when not. But the following worked for me without sudo

#### this is blink2.py #### 

import wiringpi
import time
import os

wiringpi.wiringPiSetupSys()

os.system('gpio export 17 out')

wiringpi.pinMode(17,1)

while True:
    time.sleep(0.5)
    wiringpi.digitalWrite(17,1)
    time.sleep(0.5)
    wiringpi.digitalWrite(17,0)

and then on the Linux command line

python blink2.py

It is already rewarding to see a simple LED blink. Next challenges will include combining it with a RFM12B or RFM69CW module to have the Rasperry Pi receive the messages from the (battery operated) Arduino’s for which I use the RFM12B for communication.

Furthermore, Adafruit has a nice tutorial showing how to use Node JS with a Raspberry Pi. That is also something to explore…