Node.js? Raspberry Pi? Beginners Guide!
- Posted: Aug 05, 2016 at 6:00AM
- 1 comment
Loading user information from Channel 9
Something went wrong getting user information from Channel 9
Loading user information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
So you've heard and seen that node.js is the new thing the cool kids are working with. You've heard and seem that IoT and the Raspberry Pi are the new things the cool kids are playing with.
Dave Johnson has written down and shared how you too can be a cool kid...
In this second installment of our LTM (Learning through Making) series of Node.js tutorials, we’re going to get Node up and running on a Raspberry Pi 2 or Pi 3. With the Raspberry Pi 3, you won’t need to buy a separate USB Wi-Fi adapter. I’m focusing on the Raspberry Pi 2/Pi 3 rather than older versions such as the Raspberry Pi B+ since these are the latest models at the time of this writing. The Raspberry Pi 2, for example, sports a 900MHz quad-core ARMv7 chip with 1 GB of RAM versus the Model B+’s 700 MHz single-core ARMv6 chip with 512 MB RAM. While Node can run on the model B+, we will be happier campers with this extra computing power available to us! Let’s get started.
This tutorial is useful for anyone wishing to successfully install a Raspberry Pi 2/Pi 3 system, even if they are not interested in Node.js since the Node.js installation happens in the final steps of the tutorial. But, why would you not want to install Node.js?
If you don’t currently own a Raspberry Pi, the easiest way to get started is to buy a starter kit such as this one on Amazon:
Write Raspbian Image to SD Card
We will be running Raspbian which is a free operating system based on Debian Linux and optimized for the RasPi. Here we go:
Prep the hardware
The Tech Brick Café has a nice overview picture of the various parts of the RasPi 2 here (RasPi 3 looks very similar) that may help you in this section. Let’s get this little SBC (single board computer) ready to boot! Here are the steps:
Configure the RasPi
We first need to make a few changes to the RasPi to for the purpose of optimization and personalizing it for our use. To get started, launch a terminal session by clicking on the icon shown here:
The Raspberry Pi is the brilliant brainchild from our friends in the UK. If you are not from the UK, some of the keys on your keyboard may not work as expected. Here are the changes I made to make my RasPi feel at home in San Diego:
After the RasPi reboots, we are ready to get Wi-Fi up and running to get on the network.
Apply Raspbian Updates
We will first run the apt-get “update” command. This command will not actually update any software on the system, but will download the latest package lists from the software repositories so that Raspbian will be aware of all new software available along with dependencies. Issue the following command at the “$” prompt:
Prepare Remote Desktop
We want to run the RasPi remotely through Windows rather than having to tie up a dedicated HDMI monitor and USB keyboard/mouse. Let’s do that now:
Create Windows File Share on the RasPi (Optional)
We can create a Windows file share on the RasPi so that we can copy files from our Windows machine directly onto the RasPi. This can come in handy in many contexts. Here’s how we do it:
You now have an amazing general purpose Raspberry Pi system that can be used for a variety of tasks and inter-operates well in the Windows world (it even looks like a Windows machine to the other Windows machines!) – and can play nicely in the Mac and Linux world too. Let’s go ahead and install Node.js so we will be ready to do some fun projects in the future. Here are the steps:
In a future post, we will leverage the goodness of the npm (Node Package Manager) community and build a simple, but highly functional Web server without any code. This can be accomplished using the Raspberry Pi system you just created here or on a Windows/Linux/Mac machine as I outlined in a previous article. Hope to see you then!
Follow Dave Johnson on Twitter to stay up to date on the latest tutorials and tech articles.