Following the new release of the new Pick N Place Wheel cross platform web application, I figured I’ll put together this guide on how to setup and use the web app on a Raspberry pi, since this is how a lot of people seem to prefer running the Pick N Place Wheel app.
To catch up on what the Pick-N-Place Wheel is, head to the main project page or watch the video.
The new Pick N Place Wheel web application is a cross platform Dotnet 5 Blazor server application, so it should run on Windows, Mac and Linux operating systems, however as I am primarily a windows user with no access to a Mac PC, I am only able to fully test the app on Windows and Linux (via the raspberry pi), but I am happy to report that it works really well on both.
In this guide, I’ll be showing you how to setup the Raspberry pi as a server for the Pick N Place Wheel App, so that you can serve it anywhere on your local network, you can run it by connecting a screen and a keyboard to the pi, or through any web browser on your computer, tablet or phone.
Here’s an overview of everything you need to do to setup the Pick N Place Wheel App on you raspberry pi:
- Download and setup.net core 5 on the pi
- Download the published Pick N Place Wheel web app
- Install and setup nginx as a reverse proxy
- Create kestrel service for the app
For this guide, you don’t need a screen or keyboard for the pi, everything is going to be done via SSH (remote access), I am using putty, but feel free to use your preferred terminal.
Step 1: (downloading the required files)Head to https://dotnet.microsoft.com/download/dotnet/5.0 to download the.net SDK and runtime for Linux Arm32.
Once you have.net SDK and Runtime files downloaded, head to the release page of the Pick N Place Wheel to download the published zip file for the Pick-N-Place Wheel Web App. https://github.com/ahmsville/Pick-N-Place_Wheel/releases make sure to download the Pick-N-Place Wheel Web Portable and not the windows installer versions.
Once you have all three files on your computer, you’ll need to copy them over to your raspberry pi, for this I am using pscp since it comes standard with putty, but again you can use any software you prefer for this.
Open command prompt and enter the following commands:
To copy.net 5 SDK
-pscp -r "C:\Users\ahmsv\Downloads\dotnet-sdk-5.0.403-linux-arm.tar.gz" pi@192.168.8.101:/home/pi
To copy ASP.NET Core 5.0 Runtime
-pscp -r "C:\Users\ahmsv\Downloads\aspnetcore-runtime-5.0.12-linux-arm.tar.gz" pi@192.168.8.101:/home/pi
To copy Pick-N-Place Wheel app
-pscp -r "C:\Users\ahmsv\Downloads\Pick-N-Place.Wheel.Web.cross.platform_frm-dep_portable.v1.0.zip" pi@192.168.8.101:/home/pi
Login to you raspberry pi via SSH and enter the following commands.
-sudo mkdir dotnet_5.0.4
-sudo tar zxf dotnet-sdk-5.0.403-linux-arm.tar.gz -C dotnet_5.0.4
-sudo tar zxf aspnetcore-runtime-5.0.12-linux-arm.tar.gz -C dotnet_5.0.4
-sudo mkdir Pick-N-Place-Wheel
-sudo unzip Pick-N-Place.Wheel.Web.cross.platform_frm-dep_portable.v1.0.zip -d Pick-N-Place-Wheel
To permanently setup.net on the raspberry pi, run:
nano .bashrc
and copy the following to the end of the file…
DOTNET_ROOT=$HOME/dotnet_5.0.4
export PATH=$PATH:$HOME/dotnet_5.0.4
reboot the pi with:
sudo reboot
once the pi reboots, login to it again through SSH and confirm that.net 5 and asp dotnet runtime is setup correctly with:
dotnet --info
if everything looks good, you can do a quick test by running the Pick N Place wheel app with:
-cd Pick-N-Place-Wheel
-dotnet "Pick-N-Place Wheel Web.dll"
The app should be started and listening on port 5000, if you happen to have a screen and keyboard connected to the pi you can confirm this from the browser by navigating to http://localhost:5000
Close the app with:
Ctrl + c
Enter the following commands into the terminal to install nginx
-sudo apt-get update
-sudo apt-get install nginx
After the installation, you can check that nginx is running with:
sudo systemctl status nginx
you can also navigate to the raspberry pi’s IP address from any browser, and you should see the welcome to nginx page.
Next you need to configure a nginx server as a reverse proxy for the pick n place wheel app, so that you can access it anywhere on your local network.
Unlink the default welcome page with:
sudo unlink /etc/nginx/sites-enabled/default
create a new server configuration file with:
sudo nano /etc/nginx/sites-available/pnpwheelsite.conf
copy the following texts into the file and save it:
server {
listen 5001 default_server;
server_name pnpwheel.local *.pnpwheel.local;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Link the new configuration to nginx enabled-sites with:
sudo ln -s /etc/nginx/sites-available/pnpwheelsite.conf /etc/nginx/sites-enabled/
you also need to modify the default nginx.conf file with:
sudo nano /etc/nginx/nginx.conf
comment out all the configurations under the http section except for the following lines:
- access_log /var/log/nginx/access.log;
- error_log /var/log/nginx/error.log;
- include /etc/nginx/conf.d/*.conf;
- include /etc/nginx/sites-enabled/*;
copy the following text into the http section of the configuration file and save it.
map $http_connection $connection_upgrade {
"~*Upgrade" $http_connection;
default keep-alive;
}
Test the configuration syntax with:
sudo nginx -t
if the test is ok, reload nginx with:
sudo nginx -s reload
To create a Kestrel service for the pick-n-place wheel app so that it is automatically started when the raspberry pi boots, use:
sudo nano /etc/systemd/system/kestrel-Pick-N-Place-Wheel-Web.service
copy the following text into the file and save it:
[Unit]
Description=Pick-N-Place Wheel Web
[Service]
WorkingDirectory=/home/pi/Pick-N-Place-Wheel
ExecStart=/home/pi/dotnet_5.0.4/dotnet "/home/pi/Pick-N-Place-Wheel/Pick-N-Place Wheel Web.dll"
Restart=always
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=PnPWheel
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
Enable the service with:
sudo systemctl enable kestrel-Pick-N-Place-Wheel-Web.service
Start the service with:
sudo systemctl start kestrel-Pick-N-Place-Wheel-Web.service
Confirm that the service successfully started the app with:
sudo systemctl status kestrel-Pick-N-Place-Wheel-Web.service
Enter the following commands to ensure you don’t get any weird permission issues when using the app:
-sudo chmod -R 757 Pick-N-Place-Wheel
-sudo adduser www-data dialout
You are now fully setup to use the Pick-N-Place Wheel and the App on the Raspberry pi, simply connect your Wheel to the raspberry pi, open a web browser and navigate to http://<pi’sIP address>:5001 (http://192.168.8.102:5001/), you should see the Pick-N-Place Wheel interface.
The operation and appearance of the web app is very similar to that of the desktop app, so all the setup instructions on the main project page of the Pick-N-Place Wheel applies here as well, the only differences is in how you load the project files, as a server app, the files used by the app are stored within the server itself, so when you generate your project csv file and board image, you will have to upload them to the server to be used by the app. All this can be done from the load project dialog box which you get to by clicking on the load button.
I’ve also included a sample project for reference purposes.
For the full instruction on how to prepare files and setup a Pick-N-Place Wheel project, head to the setup section of the main project article.
Comments