Controlling a relay from a Raspberry Pi Zero using Restful API and Node.js
In this section, we will show you how to control a relay module connected to an Arduino UNO board, a relay for sending commands from a web browser. Let's do it.
JSON structure
JavaScript Object Notation (JSON) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language.
JSON is built on two structures:
A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
First, we need to know how to apply the JSON format that we use to describe this structure, as follows:
{"data": "Pin D6 set to 1", "id": "1", "name": "Arduino", "connected": true}
This is the format that we need to follow and make responsive...