How to control home devices using Arduino and a smartphone? | Supla #1

in #utopian-io6 years ago (edited)

Repository

https://github.com/SUPLA/arduino

Technological progress aims to make life easier for people. We invented cars to make us able to travel more comfortable, faster and further. We invented light bulb to make us able to function during a night. However, for a long time, there was no revolutionary inventions affecting homes which served mostly as a shelter. Finally, in 1982, IoT (Internet of Things) technology has appeared and quickly became disruptive. It allows to connect devices in a network, where they can communicate and share information with each other.

Nowadays, there are plenty of platforms using IoT, through which you can make your home intelligent and control it using your smartphone or voice. Unfortunately, these platforms are usually complex, expensive and closed. As there is stated on the Supla page:

SUPLA is simple, open and free of charge. It gives an opportunity to build elements based on RaspberryPI, Arduino or ESP8266 platforms and then join them either through LAN or WiFi. Through SUPLA you can, among others, control the lighting, switch on and off household appliances and media, open and shut gates and doors, or control room temperature.


Supla is a Polish project and has a rich community, which willingly develops new solutions and features. However, there is a lack of knowledge about Supla in English, which causes less interest in this project worldwide. I want to change that situation by a series of tutorials, explaining major features of Supla.

What Will I Learn?

  • You will learn how to connect Arduino to the internet
  • You will learn how to use SuplaDevice library
  • You will learn how to configure Supla on Arduino

Requirements

  • Smartphone
  • Arduino Mega
  • Ethernet Shield or ENC28J60
  • NPN Transistor (e.g. BC547B)
  • Resistor 10K
  • Relay module
  • 5V supply
  • Arduino IDE

Difficulty

Intermediate

Tutorial Contents

  • First we need to connect Arduino to the internet. You can do it either using Ethernet Shield or ENC28J60.

In case of Ethernet Shield, simply attach it to the Arduino:

fdjonfsjdnjf.png
Source

In case of ENC28J60 you need to connect following pins using wires:

ENC28J60Arduino Mega
VCC3,3V
GNDGND
SCKPin 52
SOPin 50
SIPin 51
CSPin 53

schematenc.png

  • Connect a relay with the Arduino pin 44 (this particular pin is very important) using the scheme below. To avoid situation when too high current flows through Arduino board (this may affect the correct work of the device) we have to control relay using NPN transistor and supply it from the external source. We also have to limit the current reaching the transistor base. For this purpose, we use a 10K resistor before it.

schemat.png

Arduino applies voltage between the base (2) and the emitter (3), which turns the transistor on. It allows a current to flow from the collector (1) to the emitter (3) and triggers the relay.

Important: Arduino has to be powered from the same source as relay.

  • Download Supla library for Arduino, which allows you to integrate your device with Supla ecosystem. Open Arduino IDE, go to Sketch -> Include Library -> Add .ZIP Library... and select downloaded .ZIP file. Important: if you are using ENC28J60, you need to install additionally UIPEthernet library.

IDE.png

  • Once you library is successfully installed, go to File -> Examples -> SuplaDevice and choose the properly example, depending on which board you use. In my case it will be ENC28J60, but next steps are the same for both boards.

dfdf.png

  • Scroll down until you see:
char GUID[SUPLA_GUID_SIZE] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

Replace this GUID with the one you can retrieve from here. GUID is a globally unique identifier for your device. It should look like that:

char GUID[SUPLA_GUID_SIZE] = {0x69,0x0F,0x43,0x1D,0x3A,0x2D,0x54,0x2B,0x7F,0x9C,0x0B,0x03,0x07,0x1E,0x14,0x4E};
  • Then you will see Ethernet MAC address. Leave it without any changes.
uint8_t mac[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
  • Below you will see defined channels of your device. There are already several of them, but in this tutorial we will only take into consideration Channel 0 - Relay. Note that (44) symbolizes the pin number where the relay is connected. You can add new relays by using SuplaDevice.addRelay(pin number); formula.

chanells.png

  • Now, go to Supla Cloud page and create a free account by following instructions provided on the screen. Supla Cloud is a central point which connects your devices and allows you to control them via your smartphone from anywhere in the world.

create.png

  • Sign in to Supla Cloud and you will get a screen with your account data. Supla-dev contains data for your control devices (in our case Arduino with relay) and supla-client contains data for your smartphone.

starthere.png

  • Get back to the Arduino IDE and find your Supla Cloud configuration in the code. Fill it with data from supla-dev. In my case it looks like that:
 SuplaDevice.begin(GUID,              // Global Unique Identifier 
                    mac,               // Ethernet MAC address
                    "svr18.supla.org",  // SUPLA server address
                    17,                // Location ID 
                    "9ce5");           // Location Password
  • Upload your sketch to the Arduino. Once it is complete, reset your board.

  • Get back to your account in Supla Cloud, and go to the My SUPLA tab. Your Arduino device should appear there as connected. Click on it and configure your relay by following instructions provided on the screen.

CLOUD1.png

  • Download Supla App on your iPhone or Android phone. Then open it, enter your email address and submit operation. Now you should be able to control the relay using your smartphone.

39686750_234173873934303_1237611606779625472_n (1).png

Further reading

Thank you for reading. Hope this tutorial will be helpful.

Sort:  

Thank you for your contribution.

Your tutorial is well explained thanks for your work.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thank you for your review, @portugalcoin!

So far this week you've reviewed 10 contributions. Keep up the good work!

Thank you for your review.

Hey, @neavvy!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Hello! Your post has been resteemed and upvoted by @ilovecoding because we love coding! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!

Reply !stop to disable the comment. Thanks!

thank your share

No problem :) Visit my profile for more interesting tutorials.

Congratulations @neavvy! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:
SteemFest³ - SteemitBoard support the Travel Reimbursement Fund.

Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Congratulations @neavvy! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

Award for the total payout received

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

SteemitBoard - Witness Update
SteemFest³ - SteemitBoard support the Travel Reimbursement Fund.

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @neavvy! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

SteemitBoard - Witness Update

Support SteemitBoard's project! Vote for its witness and get one more award!

Hi @neavvy this is super useful
I started a home automation project some time back that needs to be completed.
I am going to follow these tutorials of yours for sure
Good luck my friend :)

I started a home automation project some time back that needs to be completed.

Great to hear that @thetimetravelerz :) If you have not decided on a particular platform yet, I highly recommend Supla. Unfortunately, future tutorials will release with delay, as I am super busy at school. However, I will make sure to notify you once I will publish them :)

Greetings, Jan

This is great my friend @neavvy. You shared amazing information my friend. Are you electronics engg. my friend ??

Thank you my friend @flash07. Unfortunately I am not an electronics engineer yet, as I am only 17 years old :) However, electronics is my passion and I highly enjoy such projects :)

Greetings, Jan

I didn't know you are only 17 Years old my friend @neavvy. Also it's hard to believe because you wrote so many good articles.

Great work man.
You surely have bright future.

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.033
BTC 64303.16
ETH 3137.29
USDT 1.00
SBD 3.97