The Internet of Things refers to the idea that, in the near future, everyday objects will be connected to the Internet and will be able to send and receive data. That ‘near future’ is already underway and the Internet of Things can be seen in devices like Amazon Echo, the Fitbit, and the Nest Thermostat.
The Internet of Things is attached to high aspirations a world where your home, car, and even city are connected and using data to improve the quality of life for all. As society moves towards that innovative idea, your company can contribute (and profit).
When you consider the grand scheme of things, many developers try to jump ahead and focus on a product. Essentially, they start running before they can walk. We strongly advocate the POC so that you can demonstrate the viability, as well as understand the needs and steps necessary to attempt creating a marketable product. This exploration is necessary feedback in the design phase.
An IoT PoC is an ideal solution to experience tangible benefits by investing a fraction of the overall cost and efforts. Thus, a PoC can serve as testing water to ascertain how likely the actual implementation is capable of achieving the desired business goals.
Why use Mozilla IoT?
Mozilla IoT is an open source platform for monitoring and controlling devices over the web, including:
- WebThings Gateway – a software distribution for smart home gateways focused on privacy, security and interoperability
- WebThings Framework – a collection of reusable software components to help developers build their own web things
- NodeMCU ESP8266(To act as a client)
- Raspberry Pi ( To act as a server)
- 3. 5v Relay module (To control a load)
- Bulb and fan (for load)
Components Required:(5v Relay Module)
- 5v Relay
- BC547 – Transistor
- IN4001 – Diode
- 230 Ohm Resistor
- 1k Ohm Resistor
- PBT connector 3 terminal – (to connect load from the relay)
- LED – (to indicate whether it is on or off)
- Dotted board(2×2)
STEP 1: SETTING UP MOZILLA GATEWAY
1. Download Image file:
First download the latest gateway image from the link given below. https://github.com/mozilla-iot/gateway/releases/download/0.8.1/gateway-0.8.1.img.zip
2. Flash Image
- Open Etcher.
- Insert your SD card into an SD card reader attached to your computer
- Select the downloaded image as the source file
- Select your SD card as the target
- Click “Flash!”
Once flashing is complete, remove the microSD card.
3. Boot Raspberry Pi
- Insert the flashed microSD card into your Raspberry Pi
- Plug in any USB dongles
- Connect the power supply to boot the Pi
Note: On first boot the Raspberry Pi may take 2-3 minutes to boot.
4. Connect Wi-Fi
When the gateway starts up it will create a Wi-Fi hotspot called “WebThings Gateway XXXX” (where XXXX are four digits from your Pi’s MAC address). Connect to that Wi-Fi hotspot using your desktop/laptop computer, smartphone or tablet.
Once connected you should see the WebThings Gateway welcome screen which will then scan for nearby Wi-Fi networks.
Select your home network from the list and enter your Wi-Fi password to connect.
- If you are connected to the “WebThings Gateway XXXX” Wi-Fi network but you don’t see the welcome screen, you can try typing http://192.168.2.1 into your web browser’s address bar to manually navigate to the page.
- As an alternative to Wi-Fi, you can connect the Raspberry Pi to your home network using an Ethernet cable and it will attempt to automatically get an IP address from your router. You can then start first time setup by typing “http://gateway.local” into your web browser.
- If you move the gateway to another location and it can no longer access your home network, it will revert to access point mode so you can connect to it and re-configure a different network.
5. Choose Subdomain
Once you have connected the Pi to your wireless network, you should ensure that your laptop/tablet/smartphone is connected to the same Wi-Fi network and then navigate to http://gateway.local in your web browser.
You will then be given the option to register a free subdomain to safely access your gateway over the Internet using a secure tunnelling service provided by Mozilla.
Enter your choice of subdomain and an email address in case you need to retrieve it later, then click “Create”.
- You can choose to skip this step (either to only use the gateway locally on your home network or manually configure DNS yourself), but note that currently if you do skip this step you’ll have to re-flash the gateway in order to register a subdomain.
- If http://gateway.local fails to load (e.g. on Android or Windows) you can look up the IP address of the gateway on your home router and use that instead (look for a hostname of “gateway” or a MAC address starting with “b8:27:eb”.
- If neither http://gateway.local or http:// will load in your browser, check to make sure your computer is definitely connected to the same Wi-Fi network you connected the gateway to.
- If you have previously registered a subdomain you want to re-use, enter the subdomain and the email address you used to register it and follow the on-screen instructions to re-claim it.
6. Create User Account
Once you have registered your subdomain you should be automatically redirected to the next step of the setup process, which is to create your first user account on the gateway. Enter your name, email address and a password then click “Next”.
Note: You can create additional user accounts later.
You should then be redirected to an empty “Things” screen of the gateway where you can start to add devices.
STEP 2: Design of 5V Relay Module Design:
Relay module can be designed as per the given diagram with the above mentioned components .When the relay is activated, it can transfer the needed amperage to the horn through wiring which is designed to take the load. Or you can design your own relay module as per your own requirements.
STEP 3: Connecting the NodeMCU with Arduino tool
The connection should be made properly as per the circuit diagram given below or you can make your own connection as per the number components you need to connect.
STEP 4 : SETTING UP NODEMCU(ESP8266)
- To set up the NodeMCU you need to install Arduino IDE.
- Add the given link in the preferance
- Install the board form board manager
Tools–>board–>board manager–>(search for esp8266 and install it)
4.Add the required library
- ArduinoJson – can be downloaded in arduino. Sketch->Include Library->Manage Libraries-> ArduinoJson
- Wifi101- can be downloaded in arduino. Sketch->Include Library->Manage Libraries-> wifi101
- Webthing-arduino Sketch->Include Library->Manage Libraries-> webthing
- ESPAsyncWebServer – https://github.com/me-no-dev/ESPAsyncWebServer
- ESPAsyncTCP – https://github.com/me-no-dev/ESPAsyncTCP
- Select NodeMCU1.0(ESP-12E Module) from tools–>board
- Select the correct port from tools–>port
- Connect the NodeMCU with the pc and upload the code given below
Searching for devices
Next, add the Things(Appliances) to the gateway and it will be prompted if the new smart devices is found where it is being scanned.
In the Mozilla Interface we’ve to search for the available devices, and if any device is on then it will be discovered and we can connect them as easy as possible. Then the controls can be done even with other side of the planet and make sure everything is working properly. We can livestream it too!!
This is how the whole setup looks like:
- JSON error – Use this link
- We rectified logical error from existing program for our convenience usage.
- ASYNCTCP, ASYNCWebserver library error
For more details refer – https://iot.mozilla.org/docs/gateway-getting-started-guide.html
Note: Sometimes the relay voltage will be insufficient to activate the load since
As technology grows too fast, we people should be fast enough to make use of it. Mozilla IoT will make the people to get involved in the Internet of Things. It enables the user to control and automate the home appliances, these can be monitored and automatically get operated. If we can control our home appliances from wherever we want, it will save plenty of our money and time also electricity is utilized in an efficient way.
This is how the whole setup looks like:
Download Code for integration.
Looking for more projects, visit our website today!