Book Image

Internet of Things Programming with JavaScript

Book Image

Internet of Things Programming with JavaScript

Overview of this book

The Internet of Things is taking the tech world by storm, and JavaScript is at its helm. This book will get you to grips with this exciting new technology. Where do Node.js, HTML5 and Windows 10 IoT Core come in with JavaScript and IoT? Why Raspberry Pi Zero rather than Arduino? How do you configure and build an IoT network from scratch? All your IoT JavaScript questions are answered in this book.
Table of Contents (15 chapters)
Internet of Things Programming with JavaScript
Credits
About the Author
www.packtpub.com
Customer Feedback
Preface

Connecting to the home network and accessing remotely


Our Raspberry Pi will be working in a real network, so it needs to be set up to work with all the devices that will be together. For this reason, we need to configure our home network. We will show you how to use the Ethernet adapter and the Wi-Fi plug that can be used in the Raspberry Pi Zero.

Connecting with an Ethernet adapter

If you want to connect our Raspberry Pi Zero to the local network, you need to use a USB OTG Host Cable - MicroB OTG male to female from Adafruit. You can find it here: https://www.adafruit.com/products/1099. The board that we're using doesn't have an Ethernet connector, so it's necessary to use it to communicate with the devices from outside.

In the following image, we can see the Ethernet adapter connected to the Raspberry Pi Zero:

This is the connector that you can use to connect your Ethernet adapter and make a link to the network:

Now we need to follow the next steps to configure the Ethernet connection adapter:

  1. Connect your adapter to the converter; I used a TRENDnet NETAdapter, but you can use an Ethernet Hub and USB Hub with Micro USB OTG Connector from Adafruit. You can find it here: https://www.adafruit.com/products/2992m. This is a hub and can be connected to the Ethernet cable or USB devices.

  2. Verify the router configuration, and after both LEDs start blinking, you can see the IP address in your configuration. The DHCP server assigns the IP address to the Raspberry Pi.

This is what you will see as your router configuration on your hostname raspberrypi:

Accessing the Raspberry Pi Zero via SSH

As we know the IP address that our Raspberry Pi has, we will access to it using the PuTTY terminal as we can see in the following screenshot. You need to enter the IP address, and the port is 22 by default; click on the Open button:

After that, we have the login screen as follows:

Use the following command:

sudo ifconfig -a

We can now see the information about the configuration of the Ethernet controller adapter. Eth0 is the Ethernet adapter:

Connecting to the Wi-Fi network

In this section, we will show you how to configure your Wi-Fi network connection so that your Raspberry Pi Zero can interact with your Wi-Fi network. First, we need to connect the Miniature Wi-Fi (802.11b/g/n) Wi-Fi dongle to the Raspberry Pi using the USB OTG Cable: