Project tutorial
Mozilla IoT WoT Gateway and ESP8266

Mozilla IoT WoT Gateway and ESP8266 © CC BY-SA

Internet of Things for all! Mozilla WoT gateway based on Raspberry Pi and ESP8266 powered. Try to create your own gateway and device!

  • 1 comment
  • 9 respects

Components and supplies

Apps and online services

About this project

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 (

2 X ESP8266 (


1 X Z-Wave dongle adapter (

ESP8266-01 Relay board (

Optional for Raspberry Pi setup



HDMI Monitor

The Software

For this project you must have:

Arduino IDE or Arduino Create (

Mozilla Gateway for Raspberry 3

All the Mozilla Gateway libraries

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.

How Mozilla imagine the future

The Mozilla Project is an experimental framework with 3 components:

Things GatewayAn implementation of a Web of Things gateway.

Things CloudA collection of IoT cloud services.

Things FrameworkA 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.

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 (

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!

3. 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.

4. 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 ( I've created a debug test. The ESP8266 send a random number every 3 seconds to the Gateway dashboard.

NodeESP8266 led

This is the link on Github code (

Download the code and put on the Node ESP8266 board.

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 (

NodeESP8266 sensor

You can see the code for the Node ESP8266 sensor.

This is the link on Github code (

You must include some libraries for ESP LED and ESP sensor.

#include <Arduino.h>
#include <stdio.h>
#include "Thing.h"
#include "WebThingAdapter.h"

Also for ESP8266-01 Relay you must include

#include <ESP8266WiFi.h>
#include "SoftwareSerial.h" 

With this code you setup your local network SSID and password. After you create a new ThigDevice instance.

const char* ssid = "xxx";
const char* password = "";
WebThingAdapter* adapter;
const char* deviceTypes[] = {"MultiLevelSensor", "Sensor", nullptr};
ThingDevice device("SensDevice", "Analog Sensor pluged in single pin", deviceTypes);
ThingProperty property("level", "Analog Input pin", NUMBER, "LevelProperty");

With this code you connect the board to the wifi network.

#if defined(ESP8266) || defined(ESP32)
 WiFi.begin(ssid, password);
 // Wait for connection
 bool blink = true;
 while (WiFi.status() != WL_CONNECTED) {
   digitalWrite(ledPin, blink ? LOW : HIGH); // active low led
   blink = !blink;
 /*IPAddress ip = Ethernet.localIP();
 Serial.print("log: IP=");
 Serial.print("Connected to ");
 Serial.print("IP address: ");
 adapter = new WebThingAdapter("w25", WiFi.localIP());
 adapter = new WebThingAdapter("analog-sensor", WiFi.localIP());
 Serial.println("Starting HTTP server");

With this code you send a random number to the gateway every 3 seconds

 if (countator >= 3000){
   countator = 0;  
   ThingPropertyValue levelValue;
   levelValue.number = random(0,100);

Test the gateway

Now you can test your gateway. Try to connect to the dashboard and switch on/off the Node ESP8266.


IoT Mozilla Gateway for ESP8266 Arduino IDE


Similar projects you might like

How To Use To Improve IoT Projects

Project tutorial by Kutluhan Aktar

  • 9 respects

IoT Blink - Getting started with IoT

Project showcase by AppShed Support

  • 1 comment
  • 27 respects

IoT | TensorFlow Weather Station Predicts Rainfall Intensity

Project tutorial by Kutluhan Aktar

  • 24 respects

RGB HexMatrix | IoT Clock

Project tutorial by Mukesh Sankhla

  • 40 respects

KatLight - The Coolest IoT Wonderlamp

Project tutorial by remnis

  • 11 respects

IoT Twitter Follower Tracker and Status Notifier

Project tutorial by Kutluhan Aktar

  • 1 comment
  • 4 respects
Add projectSign up / Login