Skip to content
This repository has been archived by the owner. It is now read-only.
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Codacy Badge Build Status

LedEmotion

A very cool, Web-based RGB LED strip controller for the Raspberry Pi

This program drives an RGB LED Strip (APA102C) available from Adafruit (Adafruit DotStar Digital LED Strip - Black 60 LED - Per Meter - BLACK). It does so by using one of the SPI channels available on the RPi.

You will need a fairly powerful power supply to drive a 4m strip of 60 LEDs per meter (5V 10A switching power supply).

A Raspberry Pi 3 is recommended just because it's faster.

Table of Contents

Software Components

  • EmbedIO, to drive the web-based UI.
  • RaspberryIO, to interface with our hardware.
  • SWAN, to avoid rewriting some basic building blocks like logging and bitmap management in out app.
  • dotnet-sshdeploy, to perform continuous deployments to the RPi

Check our proposed diagram to test the project

Running

1. Installing mono on the Raspberry Pi

# First, update and upgrade the distro
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install mono-complete
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
# If the command line above doesn't work for you, you need to install dirmngr:
# $ sudo apt-get install dirmngr
# and execute the command again
$ echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo apt-get autoremove
$ sudo apt-get clean 

Now, go ahead and verify the version of mono

$ mono --version

You should get something above 5.4.1.6

2. Enable SPI

$ sudo raspi-config

You'll get a GUI like this:

Raspberry Pi Software Configuration Tool (raspi-config)

Select 5 Interfacing Options from the menu and then select P4 SPI to enable SPI

SPI

3. Deploy and test continuously

Before to continue with this tutorial, check this

To kill the current mono process:

$ sudo pkill mono

To start the mono process again:

$ sudo mono /home/pi/[container folder]/Unosquare.LedEmotion.Controller.exe

To see a list of processes:

  • top
  • ps
  • htop (might need sudo apt-get install htop)

4. The rc.local file

In the command line edit this file:

sudo nano /etc/rc.local

Then add the following line before exit 0:

mono /home/pi/[container folder]/Unosquare.LedEmotion.Controller.exe &

Just like this:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

mono /home/pi/[container folder]/Unosquare.LedEmotion.Controller.exe &

exit 0

Miscellaneous

A. Practical example

Diagram

Schematic

What do you need?

  • 1 Raspberry Pi 3 modelo B, v. 1.2
  • 1 LED strip (APA102C. Available here)
  • 1 DC barrel jack adapter (female. Available here)
  • 1 USB to micro USB charger (5 V)
  • Wires

Expectation:

Expected

An example of how LedEmotion works (click the image to watch the video):

Transition

back to the tutorial

B. Setting up dotnet-sshdeploy

  • SSHDeploy comes preconfigured with some default properties inside the .csproj file like:
<PropertyGroup>
    <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
    <SshDeployHost>172.16.17.54</SshDeployHost>
    <SshDeployTargetPath>/home/pi/ledemotion</SshDeployTargetPath>
    <SshDeployUsername>pi</SshDeployUsername>
    <SshDeployPassword>raspberry</SshDeployPassword>
</PropertyGroup>

These are just arguments for deploying LedEmotion via SSH using dotnet-sshdeploy and they can be modified to suit your needs. Click here for more information about dotnet-sshdeploy

<Target Condition="$(BuildingInsideSshDeploy) ==''" Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="cd $(ProjectDir)" />
    <Exec Command="dotnet sshdeploy push" />
</Target>
  • This target is what calls dotnet-sshdeploy after a successful build, we use it to automatically deploy LedEmotion using the defined properties explained above if you do not want to deploy every time you build LedEmotion you can remove this target and execute dotnet sshdeploy push in your project directory.

back to the tutorial