Jukebox on Raspberry Pi with DotNet Core – Part 1


Estimated time for lesson: 2-3 Hours

Have you ever wondered what all uses can a Raspberry pi be put into? Well let’s explore one such use case. In this series we are going to build a Music Jukebox using a Raspberry Pi, Simple Speakers, DotNet Core and Angular 6. The final product requirements can be organised into 4 categories:

  1. Development:
    1. A computer with Windows, Linux or Mac
    2. Visual Studio Community or Visual Studio Code
    3. DotNet Core 2.1 SDK
  2. Hardware:
    1. Raspberry Pi 3 B+
    2. 64 GB Class 10 micro SD card.
    3. Speakers with 3.5 MM Jack
    4. Wi-Fi router for connectivity/internet access.
  3. API’s and Frameworks:
    1. DotNet Core SDK 2.1
    2. Bass.Net: open source dotnet core wrapper around cross-platform audio library BASS from un4seen.
    3. Angular 6
  4. Applications:
    1. DotNet Core 2.1 music jukebox application: The application would also expose the endpoints to control music operations using REST endpoints (using ASP.Net Core 2.1 WebApi and Kestrel server).
    2. Angular 6 client App served from Asp.Net Core 2.1 WebServer running inside a Kestrel process.

In the first part let’s setup our Raspberry Pi 3 B+ by setting up the SD Card and installing the latest version of Raspbian. Raspbian is a Debian based linux distribution. As of writing of this article, the latest version of Raspbian is Raspbian Stretch (Kernel v 4.14). You can install Raspbian either:

  1. By downloading the NOOBS setup image.
  2. By downloading the full Raspbian Image.

Both the downloads are available on the Raspberry Pi Foundation website at https://www.raspberrypi.org/downloads/.

We will perform the following steps in order to get the Raspbian Setup on our Raspberry Pi.

  1. Format the 64 GB micro SD card using FAT32 file system.
  2. Copy the NOOBS/Raspbian Image to micro SD Card
  3. Complete Setup of Raspbian:
    1. Connect to Wi-Fi network
    2. Check audio functionality
    3. Configure Raspberry Pi to have static IP address.
    4. Enable VNC and SSH on Raspberry PI

1. Format 64 GB micro SD Card with FAT32 file system

The raspberry PI can boot from any disk that has a FAT32 file system. The NOOBS or Raspbian images that we are going to download from https://www.raspberrypi.org/downloads/ can be used to boot the Raspberry Pi 3. The key concept to note here is that the SD card needs to be formatted using FAT32 (and not exFat file system or NTFS):

Image result for windows format sd card fat32
Windows Format Dialog

One of the key challenges when using Windows to format 64 GB SD card to use FAT32 file system is that Microsoft has set a limit of 32GB partition size for FAT32 file system to promote NTFS file system. FAT32 file system can support upto 16TB partitions but on Windows operating system you cannot format a disk with size greater than 32 GB with FAT32 file system. In order to overcome this you can either use a Mac or Linux machine or if you insist on Windows then I recommend this software called GUI Format – it’s a GUI wrapper around fat32format command line utility. You can download it from below links.

The utility is created by Ridgecrop Consultants Ltd. and they own all rights of the software. I am providing the tool as is.

Mirror 1: http://www.ridgecrop.demon.co.uk/guiformat.exe

Mirror 2: https://www.pradeep.vip/utilities/guiformat.exe

Click to download guiformat.exe
GUI Format Tool

2. Copy the NOOBS/Raspbian to SD card

After formatting your card you need to download NOOBS setup or Raspbian OS image from https://www.raspberrypi.org/downloads/ on your computer. After downloading, extract the contents of the zip file to a folder and copy the extracted files (from root of the extracted folder) over to the SD card. If you downloaded the Raspbian Image (and not NOOBS image) – you can jump directly to Step 4.

3. Install Raspbian using NOOBS

In this step we will setup our Raspberry PI by installing Raspbian using NOOBS image.

sd card
Insert micro SD Card
keyboard
Plug USB Keyboard and Mouse
hdmi
Plug HDMI cable
screenshot
Plug power cable.
  • Follow the instructions as explained in the section below (images courtesy: https://projects.raspberrypi.org)
  • Power up your Raspberry PI
  • Once the Raspberry PI finishes booting up you will be presented with the below screen.
install
Installation Screen: Select OS to install.
  • Select Raspbian Full from the list and click on the install button.
  • Click “Yes” in the dialog box that follows and then wait for the installation to complete as shown below.
installing
Installation Progress: Raspbian Installation in progress.
  • After installation is complete you will get a confirmation message as shown below.
installed
Installation complete
  • Raspberry PI will reboot and you will see the Raspbian Desktop as seen below.
raspbian desktop
Raspbian Desktop

4. Setup Raspbian OS

  • When you start your Raspberry Pi for the first time, the Welcome to Raspberry Pi application will pop up and guide you through the initial setup.
pi wizard
Setup complete dialog
  • Click Next to start the setup.
  • Set your CountryLanguage, and Timezone, then click Next again.
pi wizard country
Language and Timezone setup
  • Enter a new password for your Raspberry Pi and click Next.
pi wizard password
Password setup
  • Connect to your WiFi network by selecting its name, entering the password, and clicking Next.
pi wizard wifi
Wi-Fi network setup
  • Click Next let the wizard check for updates to Raspbian and install them (this might take some time).
pi wizard updating
Raspbian OS Update
  • Click Done or Reboot to finish the setup.
pi wizard complete
Installation Complete
  • Open terminal after the Raspberry PI reboots (as shown below), in the next steps we will set static IP address and enable VNC and SSH on our Raspberry PI. This would give us a static access point for connecting to our PI for configuration.
Open Terminal
  • In the terminal window type the command sudo nano /etc/dhcpcd.conf and delete everything in the editor window that comes up and add the following:
interface eth0

static ip_address=192.168.1.201/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

interface wlan0

static ip_address=192.168.1.201/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
  • Save the file by pressing ctrl+O, exit the editor by pressing ctrl+X
  • Open the Raspbian OS start menu by clicking on the Raspberry Icon on top left corner of the screen and select Preferences>Raspberry Pi Configuration utility as shown below
Raspberry Pi Configuration

Enable all options as shown below and click on OK button and reboot your Raspberry Pi.

Raspberry PI Configuration

In the next article we will understand this setup. Later in the series we will start creating our applications and deploy them several times to Raspberry PI until we have the final interface ready.

Other posts

  • Building Your First Neural Network with TensorFlow – Deep Learning 2

    Building Your First Neural Network with TensorFlow – Deep Learning 2

    Neural networks are a fundamental concept in deep learning and are used for a wide range of applications such as image and speech recognition, natural language processing, and much more. In this article, we will walk you through the process of building your first neural network using TensorFlow, a popular open-source machine learning library. We'll…

  • Introduction to Deep Learning with TensorFlow – Deep Learning 1

    Introduction to Deep Learning with TensorFlow – Deep Learning 1

    In this article, we provide an introduction to deep learning with TensorFlow. We cover what deep learning is, what it can do, why TensorFlow is a great choice for deep learning, and an overview of TensorFlow itself. We also explore the different types of neural networks used in deep learning, and demonstrate how to build…

  • How To: Set Up PyTorch with GPU Support on Windows 11 – A Comprehensive Guide

    How To: Set Up PyTorch with GPU Support on Windows 11 – A Comprehensive Guide

    Introduction Hello tech enthusiasts! Pradeep here, your trusted source for all things related to machine learning, deep learning, and Python. As you know, I’ve previously covered setting up TensorFlow on Windows. Today, I’m excited to bring you a detailed guide on setting up another popular deep learning framework, PyTorch, with GPU support on Windows 11.…

  • Solving a Complex Logistics Optimization Problem using the Pulp Library in Python – Part 4

    Solving a Complex Logistics Optimization Problem using the Pulp Library in Python – Part 4

    In this article, we demonstrate how to solve a logistics optimization problem using the Pulp library in Python. By defining the variables, objective function, and constraints, and using the solve method to find the optimal solution, we are able to minimize the total cost of transportation while satisfying the constraints. This article concludes the multi-part…

  • Linear Programming in Python using PuLP – Part 3: Optimizing Investment Portfolios with Multi-Objective Optimization

    Linear Programming in Python using PuLP – Part 3: Optimizing Investment Portfolios with Multi-Objective Optimization

    In this article, we used the Pulp library in Python to solve a linear programming problem to find the optimal investment portfolio. We defined variables, added constraints, defined objectives, and solved the problem to find the optimal solution that balances the trade-off between maximizing returns and minimizing risk. The code was concise and easy to…

  • Linear Programming in Python using Pulp – Part 2

    Linear Programming in Python using Pulp – Part 2

    In this article, we delve deeper into linear programming and explore how to solve a multi-objective optimization problem using the Pulp library in Python. We present a problem in which a nutritionist must find the optimal meal plan for a patient suffering from anemia, balancing the intake of Vitamin B12 and fat. We demonstrate how…

  • Linear Programming in Python using PuLP – Part 1

    Linear Programming in Python using PuLP – Part 1

    Linear programming is an optimization technique used to find the best outcomes for a given problem. This technique relies on a set of constructs which are all expressed using a system of linear equations. It is important to understand that you should be able to express your objective as a linear equation dependent on an…

  • How To: Setup Tensorflow With GPU Support using Docker

    How To: Setup Tensorflow With GPU Support using Docker

    Previously I published a guide for setting up tensorflow in an anconda environment with GPU support. A lot of people liked it and I have been working with this environment myself for more than a year now. I am happy with the results however the process is a bit involved and requires quite a bit…

  • How To: Setup Tensorflow With GPU Support in Windows 11

    How To: Setup Tensorflow With GPU Support in Windows 11

    It's been just 2 days since Windows 11 came out and I am already setting up my system for the ultimate machine learning environment. Today we are going to setup a new anaconda environment with tensorflow 2.5 with GPU support using NVIDIA CUDA 11.4 and CUDNN 8.2.4 along with Python 3.8. This is going to…

  • Tools of The Trade – II

    Tools of The Trade – II

    In continuation of my previous post today I will talk about the website tanooja.com. I did this project on request of my wife because she wanted to pursue blogging and didn't want to go through the ordeal needed to write, publish and manage SEO using most of the prominent blogging platforms like WordPress, Joomla, Drupal…

  • Tools of The Trade – I

    Tools of The Trade – I

    In this post I will share a few tools and technologies that I am using to run a couple of blazing fast websites using latest modern tools and technologies. The caveat here is that I don't pay any infrastructure/hosting costs for any of these websites and they can scale infinitely in terms of supported users…

  • Building Lizzie – IV

    Building Lizzie – IV

    Another post about Lizzie. I started off with a Raspberry Pi 3 to build a personal assistant for my car and I have come a long way both in terms of the concept and the functionality. Most importantly I have formalized the application flow and also extended the scope from one device to almost all…

  • OBD-II with Raspberry Pi3

    OBD-II with Raspberry Pi3

    I am writing this article in response to a question posted on my YouTube channel. Here I would be talking about communicating to an OBD-II device (ELM327 chip with Bluetooth) hooked into your car’s OBD-II port. The OS I am using is Windows 10 IoT core. This information is important because it makes a difference…

  • Building Lizzie – III

    Building Lizzie – III

    As mentioned in previous article today I would be talking about OBD-II integration in Lizzie using a Bluetooth serial communication with an ELM327 adapter that fits on a OBD-II port in your car. OBD stands for On Board Diagnostics which is connected to the ECU (Engine Control Unit) and provides a ton of information (both…

  • Building Lizzie – II

    Building Lizzie – II

    In the previous post I described my experiments around building an intelligent artificial personal assistant – Lizzie. The pseudo intelligent agents available today around us (Siri, Cortana or Google Next) are all great feats of engineering given the fact that they reside on small devices like mobile phones and are able to do powerful things…

  • Building Lizzie – I

    Building Lizzie – I

    Recently I have been busy building a personal assistant that I would be fitting in my car. Currently I am in experimentation mode and I am experimenting with speech capabilities. I would start with a description of my journey so far. First let me show off a little bit with these videos that I created…

%d bloggers like this: