During this second Innnoexp we will explore creating physical 'Things' using Arduinos and similar boards and a wide range of sensors and actuators. Then we will connect them to the Internet of Things using the MQTT protocol and Node-RED. The idea is to get up to speed with the technology as quickly as possible, to give room for creative thoughts and innovation to happen.
This repository contains some Arduino sketches and Node-Red flows used to introduce the basic concepts.
Arduino boards are able to read inputs - light on a sensor, a finger on a button - and turn it into an output - activating a motor, turning on an LED. You can tell your board what to do by sending a set of instructions to the microcontroller on the board. To do so you use the Arduino programming language, and the Arduino IDE.
A sketch is the name that Arduino uses for a program.
This is the classic Arduino 'Hello World'.
It introduces:
- Usage of an LED.
- Usage of resistors.
- The first sketch
- defines a constant with the functional name of the pin
- has a setup and a loop,
- turns a digital pin on and off.
- uses a delay to time the blinking.
Turns the LED on when the button is pressed.
It introduces:
- The usage of a button.
- Pull-up resistors.
- The sketch
- reads the value of a digital pin.
Prints the measured value of a photo resistor to the serial output.
It introduces:
- The usage of a photo resistor, actually a light sensor.
- The sketch
- reads the value of an analog input pin.
- prints the value to the serial line.
- uses a non-blocking pattern to time the print-outs.
Uses the serial interface. Sends the light sensor value every 500 seconds:
{"light": 0-1024}
Sets the dim value of the LED after receiving:
{"dimmer": 0-255}
The sketch introduces:
- usage of a library to create / parse Json messages: ArduinoJson.
- power modulation (PWM) to dim the LED.
This sketch used to connect an ESP-8266 directly to an MQTT broker and make it send status messages and respond on commands.
Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.
It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click. Within NODE-Red it's also easy to create a live data dashboard.
All flows in this repository connect the Aruino through the serial port to Node-Red.
Connects the Arduino to NODE-Red using the Json sketch and serialport nodes. On the NODE-Red dashboard it displays a gauge for the light intensity and a dimmer slider for the LED.
The same as the previous flow but now using the Firmata protocol with Arduino nodes. It also adds a button to the dashboard to show the state of the button on the Arduino board.
The same as the previous flow but now directing all communication through an MQTT broker, turning our Arduino into a 'Thing' which is connected to the Internet of Things. This flow uses the builtin MQTT nodes.