Category Archives: Advanced

Internet Radio with an Orange PI Zero

I had build an Internet Radio with an ESP32 and a VS1051 MP3 decoder, but I was not happy with the sound quality. So I am now trying it with a Orange PI Zero board and an USB DAC.

USB Sound DAC for Internet Radio

Currently I have an USB headphone connected to the PI, but I have ordered a Lusya SA9023A + ES9018K2M USB Portable DAC HIFI External Audio Card Decoder from Aliexpress.

On the Orange PI Zero I installed MPD and MPC for the sound deamon and the controller.

apt install mpd mpc

I also installed apache2 and php to run the web based front end from.

apt install apache2 php
orange-pi-zero
Orange PI Zero

The Orange PI Zero is an Older SOC with WiFi and an USB port, just the things you need for this project. You can buy it for around 18 Euro from Aliexpress.

Plug  your USB DAC in the Orange PI Zero and check the card id.

aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: Headset [Logitech USB Headset], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0

Here it shows that your hardware card ID = 1.
Use this number to edit /etc/mpd.conf and scroll down to the audio_output section. Here you can change the line with device from hw:0,0 to the below :

audio_output {
type "alsa"
name "My ALSA Device"
device "hw:1,0"
}

After making changes to mpd.conf you will need to restart mpd

service mpd stop
service mpd start

To add Internet Radio station use the following command:

mpc add http://airspectrum.cdnstream1.com:8114/1648_128

You can add as many stations you want with the above command.

mpc -f "%file%" playlist

To list all the radio stations you added with the mpc add command.

For the web frontend I combined two setups into my setup.
The two sources are:

http://www.suppertime.co.uk/blogmywiki/2014/10/raspberry-pi-internet-radio-with-web-interface/
https://github.com/Edzelf/ESP32-Radio

I added below radio stations with mpc

mpc add http://109.206.96.34:8100 #1 NAXI LOVE RADIO
mpc add http://airspectrum.cdnstream1.com:8114/1648_128 #2 Easy Hits Florida
mpc add http://21263.live.streamtheworld.com/RADIO10.mp3 #3 Radio 10
mpc add http://airspectrum.cdnstream1.com:8000/1261_192 #4 Magic Oldies Florida
mpc add http://icecast-qmusicnl-cdp.triple-it.nl/Qmusic_nl_nonstop_96.mp3 #5 Qmusic Pop
mpc add http://23603.live.streamtheworld.com/SRGSTR09.mp3 #6 Veronica Pop Nonstop
mpc add http://icecast.omroep.nl:80/radio1-bb-mp3 #7 Radio 1, NL
mpc add http://21223.live.streamtheworld.com/SRGSTR05.mp3 #8 Sky Radio
mpc add http://23543.live.streamtheworld.com/SRGSTR10.mp3 #9 Veronica Top 1000
mpc add http://playerservices.streamtheworld.com/api/livestream-redirect/TLPSTR11.mp3 #10 538 Hitzone
mpc add http://playerservices.streamtheworld.com/api/livestream-redirect/TLPSTR09.mp3 #11 538 Non Stop
mpc add http://playerservices.streamtheworld.com/api/livestream-redirect/TLPSTR16.mp3 #12 538 Party
mpc add http://playerservices.streamtheworld.com/api/livestream-redirect/TLPSTR21.mp3 #13 538 Verrückte Stunde
mpc add http://ice.cr6.streamzilla.xlcdn.com:8000/sz%3Dnhnieuws%3DNHRadio_mp3 #14 Radio Noord Holland
mpc add http://icecast.omroep.nl/funx-reggae-bb-mp3 #15 Reggae 1
mpc add http://node-19.zeno.fm:80/2sk4vqhtknruv #16 Reggae 2
mpc add http://direct.fipradio.fr/live/fip-webradio6.mp3 #17 Reggea 3
mpc add http://generations-caraibes.ice.infomaniak.ch/generations-caraibes-high.mp3 #18 Reggae 4
mpc add http://ganja.stream.ouifm.fr/ouifmganja-128.mp3 #19 Reggae 5
mpc add http://streams.bigfm.de/bigfm-reggaevibes-128-mp3 #20 Reggae 6
mpc add http://node-01.zeno.fm/8mrdsxfk8neuv #21 Reggae 7
mpc add http://radio.alloldieschannel.com:8000/stream #22 Oldies
mpc add http://21233.live.streamtheworld.com/CANDLELIGHT.mp3 #23 Candlelight
mpc add http://playerservices.streamtheworld.com/api/livestream-redirect/TLPSTR18.mp3 #24 Radio 10 60' 70' Hits
mpc add http://playerservices.streamtheworld.com/api/livestream-redirect/TLPSTR20.mp3 #25 Radio 10 80' Hits
mpc add http://playerservices.streamtheworld.com/api/livestream-redirect/TLPSTR22.mp3 #26 Radio 10 90' Hits
mpc add http://classichits106.stream.laut.fm/classichits106 #27 Classic Hits
mpc add http://21253.live.streamtheworld.com/TLPNET06.mp3 #28 JUKE Nederpop
mpc add http://21253.live.streamtheworld.com/TLPNET11.mp3 #29 Juke Cafe Genee Nederlands Muziek
mpc add http://21253.live.streamtheworld.com/TLPNET12.mp3 #30 Juke Levenslied Nederlands
mpc add http://21253.live.streamtheworld.com/TLPNET05.mp3 #31 Juke Zomer Lounge
mpc add http://icecast-qmusicnl-cdp.triple-it.nl/Joe_nl_1_96.mp3 #32 greatest hits a la Joe
mpc add http://playerservices.streamtheworld.com/api/livestream-redirect/TLPNET03.mp3 #33 Cabaret
mpc add http://saw-de-hz-fal-stream04-cluster01.radiohost.de/saw-deutsch_128 #34 Deutsche Hits
mpc add http://mp3.ffh.de/radioffh/hqlivestream.mp3 #35 Hit Radio FFH
mpc add http://pool.radiopaloma.de/RADIOPALOMA.mp3 #36 Radio Paloma Deutch
mpc add http://radiostreamserver.de/wunschradio-70er.mp3 #37 Wunschradio FM
mpc add http://stream.antenne.com/deutsch/mp3-128/radioplayer/ #38 Antenne Niedersachsen Deutsch
mpc add http://streambbr.ir-media-tec.com/live/mp3-128/web/play.mp3 #39 BB Radio
mpc add http://dieneuewelle.cast.addradio.de/dieneuewelle/simulcast/high/stream.mp3 #40 Neue Welle
mpc add http://stream.radiobrocken.de/bestof/mp3-128/radioplayerhp/ #41 Radio Brocken
mpc add http://pool.radiopaloma.de/RP-Kultschlager.mp3 #42 Radio Paloma Kultschlager
mpc add http://streams.greenhost.nl:8080/klassiek #43 Concertzender Klassieke Muziek
mpc add http://playerservices.streamtheworld.com/api/livestream-redirect/SRGSTR25.mp3 #44 Classic FM

Download here the radio.css file for the web frontend

ZIP file with radio.css file

And here the actual web page index.php

ZIP file with index.php file

Unzip the above two files  and put them in your apache web directory.

freenom.com

My BAD experience with freenom.com

I had some domains registered at freenom.com

1 domain was taken from my account after about 3 month, and was pointed to random advertisement sites.

Another domain was removed from my account after about 7 month and is now for sale at freenom.com. It was not heavily used (about 5 hits a day)

If you your domain is not used many times, then you will be lucky to keep it for 1 year. But don’t forget to renew your domain in the last 2 weeks before expiring or you will loose your domain.

So it looks like freenom.com only gives out free domains for a short period of time.

I will move the remaining domains I have with them to my own domain where I will create a few more sub-domains.
This will be the only possible way to know that your site won’t disappear from the internet.

ESP32

Not all pins of the ESP32 can be used.

Below a list of all special pins of the ESP32

  1. The application can use ADC2 only when Wi-Fi driver is not ESP32 HW-607started, since the ADC is also used by the Wi-Fi driver, which has higher priority.  GPIOs 0, 2, 4, 12 – 15 and 25 – 27
  2. Some of the ADC2 pins are used as strapping pins (GPIO 0, 2, 15), so they cannot be used freely.
  3. ESP32 Core Board V2 / ESP32 DevKitC: GPIO 0 cannot be used due to external auto program circuits.
  4. ESP-WROVER-KIT V3: GPIO 0, 2, 4 and 15 cannot be used due to external connections for different purposes.
  5.  The hall sensor is internal to ESP32, reading from it uses channels 0 and 3 of ADC1 (GPIO 36 and 39). Do not connect anything else to these pins and do not change their configuration. Otherwise it may affect the measurement of low value signal from the sensor.
  6. Pins 34-39 are input only
  7. GPIO 6-11 are used for the flash, so you can not use them.
  8. Serial0 is on GPIO 1 & 3 (TX RX). Serial2 on on GPIO 17 & 16 (TX RX)
    Serial1 is per default on GPIO 9 & 10, but they are used for Flash.
    You can modify Arduino\hardware\espressif\esp32\cores\esp32\HardwareSerial.cpp to assing different GPIO pins.
  9. I2C pins: 21 = SDA & 22 = SCL
if(_uart_nr == 1 && rxPin < 0 && txPin < 0) {
        rxPin = 9;
        txPin = 10;
    }

Setting up WordPress for Multisite and Multidomain

Multisite & Multidomain

Since Version 4.8 WordPress includes not only multisite, but also multidomain.
There is no extra plugin is needed anymore, as soon as you enable multisite, multidomain is also enabled.

Enable Multisite

To enable multisite you need to edit your wp-config.php file.
You need to add the following  code to your wp-config.php file just before the /* That’s all, stop editing! Happy blogging. */ line.

/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
Save this file on your server, and multisite is enabled on your WordPress installation.
Now you need to disable all your plugins before we activate the multisite option. (You can enable them again later)
When they are all disbled go to Tools >> Network Setup to activate multisite.
Choose option Sub-domains.
And fill in the Network Title & Network Admin Email
When all filled in click on the Install button.
WordPress wil now show you some code that you need to add to your wp-config.php and .htaccess file.

Enable multisite and multidomain in WordPress

After you have added the code and saved it to your WordPress installation you will need to login again.

You can now enable your plugins again which you disabled a few steps ago.

Your WordPress installation has now Multisite enabled and you will see a new menu item “My Sites” in the admin toolbar.

Wordpress Multisite and multidomain

You are now able to add a new sites and new users to your WordPress setup.

Click on Sites >> Add New to add a new site to your WordPress setup.

Wordpress multidomain

Here it still looks like you are not able to add a new domain.
But just fill in these 4 fields and press Add Site

You can add an admin email address other than the one you are currently using to manage your multisite.

If the email address is not currently in use by another user, then WordPress will create a new user and send the password and username to the email address you enter.

Enable Multidomain

To use different domains go to My Sites >> Network Admin >> Sites
Hoover over the site where you want to use your new domain and press edit.

You can now edit the  Site Address (URL) field and enter your new domain in it.

Make sure that the DNS server of your new domain has the correct IP address of your WordPress setup, and that your webserver points to the correct directory. This should be the same directory which you use for your first site.

You can now browse to your new wordpress site, and it should show it’s welcome site of the plugin used.
Most of the time you will not be able to go to the admin pages at this moment. You will see an error messages like this:

ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.

To solve this problem add the following line to your wp-config.php file just under the lines you added to enable Multisite:

define('COOKIE_DOMAIN', '');

Now your WordPress Setup is Miltisite and Multidomain enabled.