Showing posts with label esp8266 12e. Show all posts
Showing posts with label esp8266 12e. Show all posts

Tuesday, 31 May 2016

All about Smart Keychain

Many time it happens that we are unable to find our keys as we have misplaced it. And generally this happens when we are in great hurry. Frustrating moment......

Try to make a smart keychain for you.



Now not to worry about your keys, they will be always in touch with you. Just trigger them whenever you are unable to find them, they will automatically tell you where they are.

Smart Keychain

Smart keychain is a WiFi keychain, made using ESP8266 12E development board. ESP8266 are great modules to dive into the world of connected devices. So if you find IoT catchy and want to do some projects on this topic, than go grab your  own esp8266 first.

Ok so talking about this project, In project, I have attached a buzzer with this WiFi module and a battery to power them. So in case we are unable to find our keys, we will just take out our smart phone, open an app named Telnet, and will just send data and the keychain will start ringing and with this we can easily track our keys.

Components and Programming


We will require only few components for making this project.They are,


  • General Purpose PCB
  • Female bugstrip
  • ESP8266 12E dev board
  • Buzzer
  • Battery


We have to connect the negative termincal of buzzer to D0 pin of ESP8266 12E board and positive pin to 3.3V. Here D0 pin is nothing but the Built In LED pin of ESP8266 wifi board. Ok so you are done with the connections.Now lets have a look over the code.


I have done its programming in Arduino. I have edited the example code of Telnet to Serial of ESP8266 library by Adafruit. So I have written the code in such a way that first of all it will connect to the wifi router or hotspot device whose ssid name and password we have already provided in the code. After that it will wait for the data from our smart phone. And as soon as any data is received, the buzzer will turn ON and it will start buzzing. 

On your smart phone side, you need to download an app named Telnet for the communication with your keys.I have also made a video on this, so In case you didn't understand how to make it, have a look over the video.


Smart Keychain code :- https://github.com/techiesms/Smart-Keychain/blob/master/Smart_Keychain.ino


#techiesms
explore | learn | share

Sunday, 28 February 2016

MQTT + ESP8266 12e (Node MCU)





             MQTT(Message Queue Telemetry Transport) is a Client Server publish/subscribe messaging transport protocol. This protocol is widely used in the field of IoT for communication between Machine to Machine because of its following features ,
  •  light weight,
  • open, and
  • designed so as to be easy to implement.

Hence these features are Ideal for the IoT purpose as we need to transmit mostly status of one machine to another.It was originally developed by IBM and is now an open standard.


Note: If you are not familiar with Node MCU module, I'll request you to watch my video Getting started with Node MCU before going into MQTT.


Working of MQTT Transport Protocol.

This protocol is easy to implement and also very easy to understand. It basically comprises of one Broker and multiple clients where clients can be treated as our smart phone, sensors, etc. and they all communicate with the server which is known as Broker.

In this protocol, every client need to connect to any address of the broker which is known as the topic to be subscribed in MQTT. In single broker there can be multiple topics and clients can also subscribe to multiple topics of the same broker.

First lets see this process in block diagram which will be easy for you to understand.



So basically here we have one broker and 3 clients subscribed to the topic “temperature”. 


So as soon as any of the client(Temperature Sensor) publishes or updates the value of Temperature to the broker, than all the clients(Smart Phone) subscribed to that topic will receive the value of temperature updated.
That’s it.

We can do a lot with this simple protocol. We can even subscribe to the topics of any other person if we know the username and password of the broker.

Implementation 


We will be making a project on "Controlling Home Appliances through Internet via MQTT". I will be demonstrating this by controlling Radio and Light of my room. 

Things required for making this:

  • ESP8266 12e development Board
  • 6V Relay x2
  • BC547 Transistor x2
  • 330 ohm Resistor x2
  • Connecting wires
  • BreadBoard




Broker
First of all we will need a MQTT broker. There are many broker for MQTT but I have used Adafruit MQTT broker. Its quite simple and its UI is also great. You will love to use that broker. For using Adafruit MQTT broker, first of all you need to make an account on Adafruit.io. Fill up the basic details and you are ready to use that broker.

Than goto your dashboard. My dashboard is like this.


There many options on the right corner of the page to edit the blocks, add new blocks,get the key,etc.

Now we will start with making a new button on the dashboard. For that click on the 2nd button i.e."Create a New block". It will show this window.


There are number of blocks to be added in this window like toggle button, push button, slider etc. In our project we will be using the first block i.e. toggle button. Click on create button and you will get following options.


Than you have to provide feed name which should be unique because this feed name is nothing but the topic which clients will be subscribing. I have given name of the feed as onoff. Than click the create button. And click on the choose button front of your feed name. Than click on the next step.


Than we need to provide what string to be sent when the button is ON and OFF. So, I have wriiten 1 for ON and 0 for OFF.


That's it. You are done with the broker side. No complexity, nothing. Only simple and great UI and that's why I like adafruit broker. You can even drag and resize the block according to your need.


Account holder at Adafruit IO will have their unique key which is also called as password for the subscription. You can get your key by clicking on the third button on the right corner. It is a key shaped icon on the button.



Client

We will be using two clients in our project first is the ESP866 12e development board and another is our Smart Phone. First of all you need to download library for MQTT  client by Adafruit. You can download the library from here.

Now open example in your Arduino IDE named "mqtt_esp8266". Just change the ssid name, password for internet access and also provide your broker username and password(AIO key). And than just upload the program because in the example sketch, they have already subscribed to the topic onoff so no need to change anything in this. Than open serial monitor and your adafruit dashboard side by side.


As MQTT is very light weight, the response we can observe is around in couple of milliseconds. It's really fast!!! As you can see in the Serial monitor, whenever I toggle the switch it shows the response like "GOT 1" or "GOT 0". And side by side it is also publishing value of counter on the topic named photocell. 

Another Client is our smart phone. For that you need to download an app of MQTT client. I have downloaded this app in my android device. Just provide 4 details.

Broker URL, here it is (io.adafruit.com)
Port, (1883)
Username ( username you have registered while making your account)
Password (Key which you can get by clicking the key icon on your dashboard)

After filling this details just subscribe to any of the topic and send either 0 or 1 to turn the button on or off. And yeah!!!!, now you can toggle the button from anywhere in the planet earth as long as you are in coverage area of your Internet service provider.


#techiesms