Book Image

Hands-On Robotics with JavaScript

By : Kassandra Perch
Book Image

Hands-On Robotics with JavaScript

By: Kassandra Perch

Overview of this book

JavaScript has an effective set of frameworks and libraries that provide support for embedded device programming and the robotics ecosystem. You’ll be able to put your JavaScript knowledge to work with this practical robotics guide. The book starts by guiding you in setting up an environment to program robots with JavaScript and Rasberry Pi 3. You will build beginner-level projects, such as a line-following robot, and then upgrade your robotics skills with a series of projects that help you get to grips with the Johnny-Five library. As you progress, you’ll learn how you can improve your projects by enabling advanced hardware components and programming concepts. You’ll even build an advanced AI-enabled robot, connect its NodeBots to the internet, create a NodeBots Swarm, and explore Message Queuing Telemetry Transport (MQTT). By the end of this book, you will have enhanced your robot programming skills by building a range of simple to complex projects.
Table of Contents (19 chapters)
Title Page
Dedication
Packt Upsell
Contributors
Preface
Index

Getting weather data on our Pi with OpenWeatherMap


We're going to build a weather bot for this one, and while we could use a temperature sensor, that'd only tell us what it's like indoors, and usually we'd like to see what the weather's like outside before we head out the door. So we're going to use the OpenWeatherMap API to get data and display it on a character LCD; but let's walk before we can run by starting with getting the data from the API to the Pi.

Getting an OpenWeatherMap API key

First, you'll need to sign up for an account at https://openweathermap.org/, and generate an API key. Then, click your username in the upper-left corner and select API Keysfrom the tabs that appear near the top of the page:

Generate an API key on this page and keep the tab open; we'll use it in the next section to get the info we need.

Next, open the API link in a separate tab; you'll see the main API function calls on this page. The one we're looking for is right at the top – current weather data.

 

Click...