Linux-Powered Electronic Projects With Python And Javascript Download
Node.js and Raspberry Pi
Raspberry Pi is a modest, multi-use computer.
With Node.js you can do amazing things with your Raspberry Pi.
What is the Raspberry Pi?
The Raspberry Pi is a small, affordable, and amazingly capable, credit card size computer.
Information technology is developed by the Raspberry Pi Foundation, and it might be the most versatile tech always created.
Creator Eben Upton's goal was to create a depression-cost device that would improve programming skills and hardware understanding.
Due to the small-scale size and price of the device, it has become the eye of a wide range of projects by tinkerers, makers, and electronics enthusiasts.
Raspberry Pi and Node.js
The Raspberry Pi has a row of GPIO (General Purpose input/output) pins, and these tin exist used to collaborate in astonishing means with the existent world. This tutorial will focus on how to utilize these with Node.js.
What Practise I Need?
For this tutorial you need a Raspberry Pi. In our examples nosotros use a Raspberry Pi 3, but this tutorial should work for most versions.
Hardware needed:
- Raspberry Pi computer
- MicroSD memory carte (We recommend a course ten with xvi GB or higher)
- MicroSD to SD retention card adapter (usually included with the MicroSD carte)
- Micro USB power supply to power the Raspberry Pi (ii.5A or greater recommended)
- WiFi/Ethernet Cable connection for the Raspberry Pi (Not needed for Raspberry Pi 3 as information technology has built in WiFi)
- A working estimator with internet and SD retention card reader (used to get the OS (Operating Organization) for the Raspberry Pi onto the retention card). In our tutorial we use a Windows computer for this, but you tin utilize a Mac or Linux computer if you prefer
- HDMI monitor, USB keyboard (nosotros need these only temporarily for the first boot of the Raspberry Pi)
For later on capacity in this tutorial nosotros will use special sensors or devices that we connect to the Raspberry Pi. We will specify these every bit special requirements in the relevant chapters.
If you already have a Raspberry Pi set up with Raspbian, internet and enabled SSH, yous can skip to the step "Install Node.js on Raspberry Pi".
Write Raspbian OS Image to MicroSD Card
Before we can start using our Raspberry Pi for annihilation, we demand to get a Bone installed.
Raspbian is a free operating system based on Debian Linux, and it is optimized Raspberry Pi.
Download the latest Raspbian prototype from https://www.raspberrypi.org/downloads/raspbian/ to your computer.
We use the "Light" version in our tutorial, since we are setting the Raspberry Pi upwardly as a headless server (we will connect to information technology through SSH, without having a keyboard/display connected to it). Yous can use whichever version you want, only this tutorial is written with the "LITE" version as its focus.
Insert the MicroSD memory card in your calculator (via the SD adapter if needed). Open File Explorer to verify that it is operational.
Etcher is a program for flashing images to retentiveness cards. Download and install Etcher from: https://etcher.io/
Launch Etcher:
Click "Select image" push button and discover the Raspbian zip file that you downloaded.
Click the "Select drive" button and specify the memory bill of fare every bit the target location.
Click the "Flash!" button to write the image to the retentiveness card.
Afterward Etcher is finished writing the image to the memory card, remove it from your computer.
Fix upwardly Your Raspberry Pi
To go the Raspberry Pi gear up to boot we need to:
- Insert the MicroSD memory bill of fare into the Raspberry Pi
- Connect the USB keyboard
- Connect the HDMI cable
- Connect the USB Wi-Fi adapter (or Ethernet cable). Skip this footstep if y'all are using a Raspberry Pi 3
- Connect the micro USB power supply
- The Raspberry Pi should now be booting up
When the Raspberry Pi is finished booting upwardly, log in using username: pi and password: raspberry
Prepare Up Network on the Raspberry Pi
If you lot will use a Ethernet cable to connect your Raspberry Pi to the internet, you tin skip this step.
For this section we will assume yous have a Raspberry Pi iii, with built in WiFi.
Start by scanning for wireless networks:
pi@raspberrypi:~ $ sudo iwlist wlan0 scan
This will list all of the available WiFi networks. (It also confirms that your WiFi is working)
Now nosotros need to open the wpa-supplicant file, to add the network you want to connect to:
pi@raspberrypi:~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
This will open the file in the Nano editor. Add the post-obit to the bottom of the file (change wifiName and wifiPassword with the bodily network proper noun and password):
network={
ssid="wifiName"
psk="wifiPassword"
}
Printing "Ctrl+x" to save the lawmaking. Confirm with "y", and confirm the name with "Enter".
And reboot the Raspberry Pi:
pi@raspberrypi:~ $ sudo reboot
After reboot, log in again, and confirm that the WiFi is connected and working:
pi@raspberrypi:~ $ ifconfig wlan0
If the WiFi is working propery, the data displayed should include an IP address, similar to this:
inet addr:192.168.1.50
Write downwards that IP address, as nosotros volition use it to connect to the Raspberry Pi via SSH.
Enable SSH, Modify Hostname and Password
Now your Raspberry Pi is continued to the internet, information technology is time to enable SSH.
SSH allows yous up apply the Raspberry Pi without having a monitor and keyboard connected to it.
(You will need a SSH client for this on your non-Raspberry Pi estimator. We utilise
Open the Raspberry Pi Software Configuration Tool:
pi@raspberrypi:~ $ sudo raspi-config
You should come across a menu like this:
Select option 5 Interfacing Options:
Select pick P2 SSH, to activate SSH:
Confirm with YES, to activate SSH:
SSH is at present enabled, and you should be in the main menu over again.
Select 1 Alter User Countersign, and follow the instructions to alter the password. Choose a secure password, but something you volition recall:
After you have finished changing the password, you should be dorsum in the principal menu.
Select two Hostname, and follow the instructions to alter the hostname:
After you accept finished changing the hostname, you should be dorsum in the main carte du jour.
At present we volition close the menu and save the changes:
When selecting Finish, you will become the option to reboot. Select Yes to reboot the Raspberry Pi.
Y'all can now unplug the monitor and keyboard from the Raspberry Pi, and we tin log in using out SSH client.
Open PuTTY, blazon in the IP address for your Raspberry Pi, and click Open:
Log in using the username pi and the new password y'all specified.
You should now see a command line like this: (we used w3demopi as our hostname)
pi@w3demopi:~ $
You lot are now able to run your Raspberry Pi in "Headless-fashion", pregnant you do not need a monitor or keyboard. And if you take a WiFi connection, you do not demand a ethernet cable either, just the power cable!
Install Node.js on Raspberry Pi
With the Raspberry Pi properly set up, login in via SSH, and update your Raspberry Pi system packages to their latest versions.
Update your organization parcel listing:
pi@w3demopi:~ $ sudo apt-get update
Upgrade all your installed packages to their latest version:
pi@w3demopi:~ $ sudo apt-go dist-upgrade
Doing this regularly volition keep your Raspberry Pi installation up to appointment.
To download and install newest version of Node.js, apply the following command:
pi@w3demopi:~ $ scroll -sL https://deb.nodesource.com/setup_8.x | sudo -Due east bash -
Now install it past running:
pi@w3demopi:~ $ sudo apt-get install -y nodejs
Check that the installation was successful, and the version number of Node.js with:
pi@w3demopi:~ $ node -v
Get Started with Raspberry Pi and Node.js
Now you accept a Raspberry Pi with Node.js installed!
If yous want to acquire more about Node.js, follow our tutorial: https://world wide web.w3schools.com/nodejs/
In the adjacent affiliate we will become to know the GPIO and how to use information technology with Node.js.
DOWNLOAD HERE
Posted by: larisawafty1953.blogspot.com
Post a Comment