The Raspberry Pi is a very powerful computer in a tiny package. The cheapest option, the Raspberry Pi Zero, is capable of running a fully featured Linux distribution and driving a high definition display. It is the size of 3 coins (US Quarters) and costs $5. At $10, the Raspberry Pi Zero W comes with integrated WiFi and Bluetooth.
With a generic ARM CPU and easy networking, the Raspberry Pi can easily become a personal application server for you. For example, you can put a web application (eg a collaborative record keeping app) on a Pi, bring it to a meeting, and make it accessible to everyone in the room. You do not even need the Internet. It is completely decentralized and censorship resistant.
The personal server is especially useful for developers. You can have a separate environment to deploy and test your server-side applications without having to mess with your laptop. The personal dev server is like Docker on steroids.
The easiest way to set up your Raspberry device to install the Raspberry Pi OS from a MicroSD card. The Raspberry Pi OS is a Debian-based Linux distribution that is suitable for both desktop and server uses. You can buy a blank MicroSD card and use the Raspberry Pi Imager to load the NOOBS system on it. Or, you can buy one of those MicroSD cards with NOOBS pre-loaded.
Put the MicroSD card into your Pi device’s card slot, connect an HDMI display, keyboard, mouse, and power up! Follow the on-screen instructions to install Raspberry Pi OS. From there, you can create a user account, connect to WiFi, turn on SSH, and open the command line terminal. In order to use the Pi device as a “headless” server, you could request a static IP address from your router. In the future, you can just power it on, and connect to it via SSH from your laptop — there is no need for display, keyboard, and mouse. Once you are set up, use the following command to find your Pi’s IP address on your local network.
$ hostname -I 192.168.2.108 172.17.0.1
As with all new Linux installations, it is a good idea to update and upgrade to the latest packages. Run the command below and be patient. It could take an hour.
$ `sudo apt update && sudo apt upgrade`
Next, run the following command to install essential developer libraries.
$ sudo apt install build-essential curl libboost-all-dev
The following two commands install Node.js on your Pi.
$ `curl ``-``sL https``:``//deb.nodesource.com/setup_10.x | sudo bash -` `$ sudo apt install nodejs`
From here, you can use npm to install modules. Here we install the Second State VM (ssvm) to support high performance Rust functions in Node.js applications.
$ npm install ssvm
Next, let’s try to run a couple of demo applications.
Get the demo application from the Internet, and unzip the compressed archive.
`$ curl -O https://www.secondstate.io/download/quadratic.zip` `$ unzip quadratic.zip`
`$ cd quadratic/node` `$ node test.js` `[0.5,-3.0]`
Start the Node.js server application from the command line terminal.
`$ npm install express // Required for the web app.` `$ cd quadratic/node` `$ node server.js`
Point the browser to http://localhost:8080/ or you can access it from another computer on your network.
It is a web application that teaches math and solves quadratic equations. It could come really handy in a small group in a classroom!
You do not really need developer tools on a personal server. But the Raspberry Pi device is powerful enough to compile and build software. In fact, one of its common uses cases is to teach programming. The Raspberry Pi OS comes pre-loaded with developer tools for Java, Python, and Scratch. Now, let’s install some serious tools on it! I always install Git on all my development environments.
$ sudo apt install git
The following command installs the Rust compiler toolchain on the Pi.
`$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
Run the following command to set up the correct path without logging out and back in again.
$ source $HOME/.cargo/env
Next, you can clone our Rust learning repository, and learn from examples.
$ git clone https://github.com/second-state/wasm-learning.git
Here is the hello world example. Have fun!
$ cd wasm-learning/rust/hello $ cargo build Compiling hello v0.1.0 (/home/pi/Dev/wasm-learning/rust/hello) Finished dev [unoptimized + debuginfo] target(s) in 4.35s $ target/debug/hello Hello, world!
Now you have everything you need on the Raspberry Pi device. The next steps are to learn more about creating high-performance and resource-constrained Node.js web applications on your $5 Raspberry Pi personal dev server.
- Why WebAssembly is the perfect runtime for server-side (or serverless) applications
- Getting started with Rust functions in Node.js
- Access operating system resources from WebAssembly
- High performance image recognition in Node.js
- Machine Learning: K-means clustering and visualization
Have fun, and let me know how you used your Raspberry Pi device!
Don’t forget to create and publish a Node.js app to receive your FREE Raspberry Pi. Can’t wait to see what you can do with Rust and WebAssembly!
Stay in touch! Get the email newsletter on Rust, WebAssembly, serverless, blockchain, and AI.