Showing posts with label ESP8266. Show all posts
Showing posts with label ESP8266. Show all posts

Thursday, 9 June 2016

Monitoring Sensor's Data Over Internet





Once upon a time, we used to see the data of our sensor on a 16x2 LCD. So whenever we need to monitor the readings, we need to see on that LCD and need to stay near to it. But now world has changed and so we need to. Now lets see how we can monitor sensor's reading on any internet enabled devices.

OK!!!!!!!!!!! it was too filmy.

So now in this article, ,we will be learning how we can upload our sensor's data to internet and observe it in graphical manner with the help of a great platform for our IoT projects called Thingspeak.com.

Process

Process of this project goes something like this.


So, first of all the data from DHT11 sensor will be given to Arduino Board. This board will process the data and will giving the signal to ESP8266 for uploading it to Thingspeak.com. This website, after receiving the data will automatically plot the graph of Data vs Time.

DHT11 Sensor

DHT11 is a sensor for measurement of temperature and humidity. Looking inside, it consists of two parts,

i)  A microcontroller



ii) Sensor



This sensor acts like a capacitor whose capacitance changes along with Temperature and Humidity. This raw data is given to the inbuilt microcontroller who will process this analog data and will convert it into a 40 bit digital Serial packet of data. And that 40 bit consists of,


Hence decoding of this serial stream of data in done in Arduino. For that, we are using one library by Adafruit, which you can download it form here.

After that, you need to interface ESP8266 with arduino in order to transfer data to Thingspeak.com

Thingspeak

Thingspeak.com is a perfect companion of you IoT projects.It provides you a platform, which you can use for different applications. As I have used it to create APIs for my project "Fetching Data from Any Website" In this project, we are creating channels in this for plotting graphs.

For that first make an account in this website, then go to channel and then into my channel. In one single channel you can plot upto 8 graphs or we can say 8 fields. You need to give name of each field. As we are plotting graph of Temperature and Humidity, I have named the fields accordingly.


After that, you need to copy the API keys from the API key button on the website. We will copy Write API key as we need to write data on to the graph.



Code

In the code, we are first reading data from the sensor, than connecting ESP8266 to the router whose host name and password we have already entered in the code. Than we will establish a TCP connection at port 80 as to communicate with Thigspeak.com. After that we will be updating the values from sensor to thingspeak.com. We will be providing 15 s delay hence we will be able to observer new value on the graph every 15 s.



You can download the code from here.


After that, you are ready to monitor data from your phone, laptop and any other internet enabled device just log in to your thingspeak.com account. The graph will be something like this.


I have made tutorial videos for this project in both Hindi and English Languages. So if you still didn't get what to do, just have a look to the videos.


Hindi


English 





#techiesms
explore | learn | share

Wednesday, 1 June 2016

Testing Your Internet Speed using ESP8266 WiFi module



In this world of connected devices, all our appliances need a proper internet connection all the time. But their is always some fluctuations in the speed or connection of the internet due to some issues. Sometimes its okay but this problem of fluctuation annoys at time of payment gate way, or submitting your college fees. After filling the form, when you press enter button, the scenario is like this


so you need to fill that form again and repeat the procedure. But still this don't happens all the time but I faced this problem so I have tried to make a small solution of this.

           I will be constantly measuring my internet connection's speed so that I come to know
           that my connection is alive or not. Hence at time of pressing submit button after filling
          any form, I will check the status of my internet speed and if the speed is great at that time
          I will submit my form so that I need not to repeat the same procedure again.


Now lets see how can we make a internet speed-o-meter using ESP8266. ESP8266 a great great great module to start with IoT. Cheapest Smallest yet fastest module and again easy to be used. In the era of Internet Of Things, demand of this module has increased a lot. With this, number of projects has also increased using this module. We can do almost anything we can think of using this WiFi module. So I have also made one simple yet useful project using this module along with my Arduino MEGA board.

With the help of only single AT command, you can get your internet speed. Hence this project is really easy to make. The speed you will get is nothing but the response time in milliseconds taken by you internet connection. After that, we can manipulate or map the data into different categorizes like Fast , Normal , Slow.

First I will explain you this concept on your laptop only and than we will implement this logic on our ESP8266 board. On you windows PC, open Command Prompt. Or simply press Windows button and type CMD.

After opening that window just type following statement, and press the enter button

ping -t www.google.com

Result of this will be as follows,


So we are just pinging the server of Google and observing the response time in milliseconds. That's what we gonna do in our project, just pinging the server and mapping this time into suitable speed of our connection. Now lets move towards the hardware part.


Connections

Connection of this module is with Arduino MEGA board is shown below,




This is simple connection in which I have connected ESP8266 WiFi  Rx Tx pins to Serial 1 of my MEGA Board. If you have UNO board, you can go for Software Serial connections.An d I have connected 3 LEDs for indicating status of our internet speed. So this is all on the hardware side, now lets movie towards the code.



Code

As we know that we need to just ping google.com continuosly as to monitor its speed. Their is an AT command for pinging whose syntax is,

AT+PING="www.google.com" 

This command will ping google.com you can ping any other website also by just editing the name of the website in above AT command. So we will just send this AT command through our WiFi module and in response we will get the time in milliseconds which we will be converting into speed by simple calculations.

I have attached the link of the code below, so you can definitely download it from there.I have also made a video tutorial on this, so have a look if you haven't understood this yet.




I have also recorded this tutorial in Hindi so in case you are more familiar with Hindi have a look over this video.






Code :- https://github.com/techiesms/Internet-Speed-O-Meter/blob/master/Internet_Speed-o-meter.ino



#techiesms
explore | learn | share






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

Thursday, 24 March 2016

Problem Solved :- ESP8266 with Software Serial ( Firmware Upgarding )

\


There was a problem faced by one my viewer in interfacing ESP8266 wifi module with Arduino UNO. In UNO, he was using Software Serial for communication with the module. Problem was that older version of ESP8266 was having default baud rate of 115200 and Software Serial doesn't work at this high baud rate. Software Serial perfectly works at 9600 baud rate. So the Solution is that, we need to change the baud rate of our ESP8266 wifi module.

One of the solution is that we can change the Baud Rate by giving AT command,

AT+CIOBAUD= Required Baud Rate

We can change the baud rate to 9600 by just writing AT+CIOBAUD=9600. And our problem is solved. But what I found is that, in my module this command was not at all working. I don't know the reason but it may be because of older firmware may not have this command defined in it. 

So first go for this step. If Your Baud Rate get changed, than no need to read this blog further. The response after entering this command will be something like this.

But If you face the similar problem which I have faced i.e. The command is not at all working on your module, than you need to go for firmware upgrading of your wifi module.
Firmware Upgrading
Firmware upgrading is not at all difficult. Just 2-3 steps and 2-3 minutes and you are done with it. First of all you need to download these necessary files before proceeding further.
After that, Open esp8266_flasher in that folder. And than select the bin file i.e. the firmware version you want to update, and also provide the COM port. It will be same port on which your Arduino is connected. Than click the download button.
It will take a minute while flashing your module. And after it complete its work, than you are ready to play with this module at 9600 Baud rate using Software Serial. And the good news is that, in this firmware, you can change the baud rate by the command AT+CIOBAUD to you required baud rate.
You can definitely watch my video in which I'm flashing my own module. I have made it in two Languages,
ENGLISH

HINDI

Files for upgrading ESP8266 firmware click here.
#techiesms

Monday, 8 February 2016

Fetching Data from any Website

             This Project idea struck in my mind during the time of IPL(Indian Premier League) when we used to be in our class attending lecture and we guys are so much curious about the live status of the match. At that time I thought of a small screen on which we can get regular updates of the match. And the Research Begins.........

            Visualizing it in block diagram wise, first of all we need search for a website on which we can get the live updates of whatever we want like live stock prices,current time, current temperature,YouTube Views,likes  and many more. Later we need to fetch the data from the server of that website and make an API(Application Program Interface). API serves the purpose of getting access to only those data which we are in need of from all the data available on the server.Suppose we need only number of views of our video uploaded on YouTube. So we need a interface which rather than requesting the whole HTML page, requests only number of Views of our video. Than we will give a GET request as we want to fetch the data from the server. All this task will be done through Thingspeak.com . A great website for your IoT based projects.

             In thingspeak.com, we will get our required API.  To test the API just request the link provided by thingspeak(On the right side of the page) in your browser than you will only get the data for what you requested.


In this Image,  I have created an API of number of views of my YouTube Video. Method I selected is GET as we want to fetch the data and HTTP version is 1.0. Than I Inserted URL of the page and for the last row (Parse String) you need to follow following steps.



Now paste that XPath into parse string row and thats it save it and API will automatically get generated. Test it by pasting that link into your browser. Than it will show something like this.


This is all about to pick up the right data.But what if we want to make project based on this. To make this data more useful you will require Arduino, LCD and the most amazing thing ESP8266 ( WiFi Module).


ESP8266(WiFi module)

             This is an absolutely amazing thing which will help your controller to communicate to the virtual world.And it is very easy to use. It has a on chip controller and we can communicate with this WiFi Module via AT Commands.Here is the list of all AT Commands.


If you are using Arduino Mega than you can use Serial1(RX1 and TX1) and Upload MultiSerialMega code into you board and change the baud rate to 115200 and you are ready to use WiFi Module. Just use all this AT commands once so that it will get easier to deal with this module further.

Steps for fetching data through API

Step 1:

Reset the WiFi module :- AT+RST
Set the mode to 3:- AT+CWMODE=3
Join any WiFi network :- AT+CWJAP = "SSID_Name","SSID_Password"

Step 2:

After connecting to the WiFi network, we need to establish a TCP connection to communicate with servers via port 80. To establish a connection, the AT command is,

AT+CIPSTART = "TCP","api.thingspeak.com",80

In our project, we are using API generated from Thingspeak.com so we have written the host server name as api.thingspeak.com. 

After this command we need to provide that how many number of characters we need to request. For this the command is,

AT+CIPSEND=90

in our case the number of characters are constant i.e. 90. Because different APIs from thingspeak.com will have different api key rest of all the things will remain same.

Step 3

After that we need to request the api generated from thingspeak.com. As we want to get the data from the server, we will send a GET request. And the sequence goes like,

GET /apps/thinghttp/send_request?api_key=XXXXXXXXXXXXXXXX 
Host: api.thingspeak.com

So whenever you make a new api, just change the key and leave rest of the things as it is.

Step 4

After following all the three steps, you will get the data in response. But many times the we need to filter the required data from the response we get.So for that we need to filter the required data form the response. And this can be done easily through some of the commands of String which I have mentioned in the code.


             This is all you need to know if you want to  fetch the data from internet and use it further for your project. I have made one sample project so that it becomes easier for you to understand the whole concept. This is the same project on which I have recorded the video i.e. fetching data from website and display it on your touchscreen. 

             If you don't have touchscreen module, just filter out the required data and analyse the response from the server on your serial monitor.

If the concept is still not cleared than have a look to my video tutorial for this whole procedure. And I have also shared the Arduino code for the same.


#techiesms


Saturday, 30 January 2016

Getting Started with WiFi Module(ESP8266)

In this section we will see how to use this tiny little still most useful module ESP8266. Main reason for the popularity of this module is I think its price and its features. It is easily and cheaply available in the market for just ₹ 250-300.
The ESP8266 is a micro-controller from Chinese manufacturer Espressif that includes Wi-Fi capability.This small board allows micro-controllers to connect to a WiFi network. This little module can work in station mode, access point mode or both. Each ESP8266 module comes pre-programmed with an AT command set firmware.

First of all lets see the pins of this module. We can communicate with this module via serially. We can use either USB to TTL converter or you can use your Arduino board as I have used.

Pins of ESP8266 module 


Things Required are:



  1. BreadBoard
  2. Arduino Board
  3. ESP8266 WiFi module
  4. LD33CV IC ( 3.3V regulator IC)
  5. Resistors (1k & 2.2k)
  6. Some connecting wires

STEP - 1


As this module is not breadboard friendly, you need to follow the steps shown below before using this module.


Cut a piece of prefboard, and first solder female connector as shown in the fig below.


After that, solder male headers on the opposite side of the prefboard. It would look something like this.


Now attach the module on to the converter.


With this, it can be easily connected on to the breadboard.



STEP-2



Note: This module strictly works on 3.3V do not give 5V supply to this module.

As this module works on 3.3V we need to use a 3.3V regulator IC (LD33CV) or you can also use 3.3V pin from your arduino board. Even the Tx pin of arduino will provide 5V signal to the module. Hence we need to step down the signal to around 3.3V before feeding it to the module.

Connection of all this things is shown in the fig. below.
I have used the Rx1 and Tx1 of Arduino MEGA board. But you can even use the Rx and Tx pins. I have used this pins beacuse in my further WiFi projects, I have used TFT touch screen module, hence we won't be able to use pin 0 and 1.

Open Arduino software and open Multi Serial Mega example and change the baud rate to 115200 and upload the code. Change the baud rate in serial monitor to 115200 and the mode to Both NL & CR.

STEP-3

Now communicate with this module by sending the AT commands in the Serial monitor and play with this module.List of  AT commands are given in the PDF whose link is mentioned below.


I have also made a video on "Getting Started with ESP8266, As simple as possible"                                                                                


Datasheet of ESP8266
   AT Commands 


#techiesms