Introduction: Mozilla IoT Gateway With ESP8266 and Z-Wave
Power to the Peoples! Mozilla wants do free the IoT protocol
The scope of this project is to “ensure the Internet is a global public resource, open and accessible to all.” The Internet of Things (IoT) is a new era of the Internet. And like the Internet, Mozilla imagines a free protocol for all. Cross-platform, cross country, cross brand.
The Hardware
For this project you must have:
1 X Raspberry Pi 3 (https://amzn.to/2DmQ8eB)
2 X ESP8266 (https://amzn.to/2AUvC3c)
Optional
1 X Z-Wave dongle adapter (https://amzn.to/2HxZokm)
ESP8266-01 Relay board (https://amzn.to/2Ufx7Ao)
Optional for Raspberry Pi setup
Mouse
Keyboard
HDMI Monitor
The Software
For this project you must have:
Arduino IDE or Arduino Create (https://create.arduino.cc)
Mozilla Gateway for Raspberry 3
All the Mozilla Gateway libraries
Step 1: How IoT Works Today
Today we have a lot of components inside the IOT communication. You should have, for example, an Amazon Alexa gateway and a lot of devices connected with that. But with Mozilla Gateway you can use the same gateway to use Alexa, Google home kit, simple ESP8266 or anything devices you want to "smartifing" your home.
Step 2: How Mozilla Imagine the Future
The Mozilla Project is an experimental framework with 3 components:
> Things Gateway: An implementation of a Web of Things gateway.
> Things Cloud: A collection of IoT cloud services.
> Things Framework: A collection of re-usable software components for building Web Things.
The Raspberry Pi Gateway
The core of all the project is a Raspberry Pi 3 Gateway by Mozilla. It's a really simple step. Mozilla has prepared a Linux distro that install the system on the Raspberry Pi. You can setup the gateway by using your smartphone.
Step 3: Start to Make Your Personal Mozilla IOT Free Gateway
1. Flash SD Card
Download the pre-built Raspberry Pi OS image from Mozilla and flash it onto an SD card. Download from THIS LINK the Mozilla Gateway distro. You can use the Raspberry Pi official guide to install the Mozilla Gateway on the SD. Another possibility is Balena Etcher (https://www.balena.io/etcher/).
Balena Ethcer is a program for Windows Mac and Linux that copy an ISO image on the SD.
2. Start you Gateway
Now you can start your Mozilla Gateway. After that, you can connect your phone with the gateway by using the Wifi from Raspberry Pi. Connect your gateway to your wifi network
After that, you must create a tunnel to the Mozilla cloud system. After that, you can see your gateway even out from your Local Area Network.
After this step, you receive an email with your Mozilla credential. You must compile the module and...that's it!
Step 4: Add Devices
Now you can add some devices. You can use Zigbee dongle to connect Zigbee devices or Z-Wave dongle for Z-Wave devices.
Step 5: Arduino Devices
My solution is able to use Arduino compatible devices. I use 2 NODE ESP8266. One of that is used as a receiver. You can connect the board to a relay and command a light for example. The other is an ESP8266 that collect the data from a sensor and send the value to the Gateway. In this, code ( https://github.com/masteruan/webthing-arduino/tree/master/examples/sensorNodeMCU) I've created a debug test. The ESP8266 send a random number every 3 seconds to the Gateway dashboard.
Node ESP8266 led is the link on Github code ( https://github.com/masteruan/webthing-arduino/tree/master/examples/LED).
Download the code and put on the Node ESP8266 board.
Step 6: ESP8266 + Relay Shield
I've used also this kind of board. A ESP8266 + relay. You can see my code on Github. You must only charge the firmware on the ESP8266 board and also you can command a relay that works clearly with Mozilla WoT Gateway.
When you add the device you can use like a led device. If you send from Mozilla Gateway "on" command the ESP send by the serial port command to the relay shield a serial command to switch on the relay, otherwise the ESP8266 send to the board a switch off command for the relay.
This is the link on Github code (https://github.com/masteruan/webthing-arduino/tree/master/examples/relayEsp8266)
Step 7: Node ESP8266 Sensor
You can see the code for the Node ESP8266 sensor. This is the link on Github code ( https://github.com/masteruan/webthing-arduino/tree/master/examples/sensorNodeMCU)
You must include some libraries for ESP LED and ESP sensor.
"Thing.h"
"WebThingAdapter.h"
"stdio.h"
"Arduino.h"
Also for ESP8266-01 Relay, you must include
"SoftwareSerial.h"
With this code you set up your local network SSID and password. After you create a new ThigDevice instance.