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

Saturday, 23 April 2016

Practical Application - Modulation Techniques

Signal from device generated is known as base band signal which is not directly transmitted to the desired place but it is modulated before feeding the signal to transmitter. Modulation is a technique of varying any component of carrier signal in proportion to that of base band signal. In this article I have covered several Analog and Digital modulation techniques. Mentioned its basic definition with figure and the important thing, practical application of  that modulation technique.So lets go into brief description and application of some of the techniques.



 Amplitude Modulation

In the simplest way possible, AM can be explained as changing Amplitude of the carrier signal or the high frequency signal with respect to the modulating signal.


Application


1. It is used in Aircraft for communication between station to pilot and vice versa. So why didn't they opt for FM which is less affected to noise as compared to AM. The reason I found is that, AM is used so that multiple stations on the same channel can be  received. While in FM, reception of weaker signal is blocked by the stronger signal which is normally known as capture effect.






2. It is still used in commercial radio broadcasting. But AM having Low frequency, they only broadcast the commentary or news or we can say only vocals will be their. As the frequency is increased, in ground wave propagation attenuation will increase. Hence FM having higher frequency will get more degraded in ground wave as compared to AM. But still use of FM is more than AM. Because it uses direct wave propagation(line of sight).





Frequency Modulation

In case of frequency Modulation, the frequency of Carrier is varied with the instantaneous value of modulating signal.Advantage of FM over AM is that it has ability to reject the noise or in the other way, noise doesn't affect much in FM.



Applications





1. The most common application which I don't thing any of you is not aware of this. i.e. FM Radio broadcasting.









2. It was surprise for me also to know that, FM was used in VCR tape recorder. For storing Luminance i.e. the black and White portion of the video is recorded by FM modulation in this analog Tape while the color part is directly recorded by the base band signal. I didn't got more data in this but I came to know that it uses FM for recording.






Quadrature Amplitude Modulation

Till now we have seen that, only single parameter is changed with the instantaneous value of base band signal. But in QAM, two parameters of the signal are changed Amplitude and Phase. In short, QAM is made up of AM and PM. QAM is also known as QPSK(Quadrature Phase Shift Keying) which can be treated as mixture of ASK(Amplitude Shift Keying)  and PSK(Phase Shift Keying).

QAM can be of different types depending upon the number of possibilities of Amplitude and Phase.
For Eg. I have shown two fig. in which first is 8-QAM (2 diff. Amplitude & 4 diff. Phase), and the second fig. is 16-QAM ( 4 diff. Amplitude & 4 diff Phase).




Applications

1. NTSC and PAL are color encoding techniques used in analogue TV  and both these encoding techniques uses QAM modulation for encoding the luminance and chrominance information combinedly, for composite video signal.

2. WCDMA(Wideband Code Division Multiple Access) commonly known as 3G connection of our mobile phones also uses QAM. WCDMA uses 64 QAM. 64 QAM has 6 bits per symbol while our 2G connection has only 3 bit per symbol hence 3G is much faster than 2G. 
Amplitude Shift Keying

Till now, the modulation techniques were used for analog signal, but now the modulation techniques we will discuss are used in digital signal modulation. First is ASK, it is very much similar to AM, in which Amplitude of the carrier is varied in proportional to the digital base band signal. As digital signal is a binary signal, so we will have only 2 different amplitude value in ASK. ASK modulation is shown below.





Applications

1. ASK Modulation is used in RF Modules. I have used this module many time for making wireless robo car. We need to attach Encoder and Decoder IC to code decode the data. And the digital data from the Encoder is modulated by ASK and than it is transmitted.
2. Some of the RF remotes and RF car keys also uses ASK modulation for transmitting digital data over air. While studying about RF car keys, I found that in some of the car keys, every time the button is pressed different data is transmitted so that one can't just simply copy and transmit the same data to unlock the car.








On Off Keying

On Off Keying(OOK) modulation technique is similar to that of ASK. Difference is that in On Off keying, binary '0' is represented by 0 volt while binary '1' is represented by some fixed amplitude. And frequency in both the cases will be same as carrier frequency.





Application


1.  This modulation technique is used only for low data transfer rate around 100 bits per second. One application of this technique which we use daily is in  IR Remote Control. That remote can be of TV, AC, Radio etc. It works on 38 kHz carrier frequency. 






Frequency Shift Keying

FSK can be related with FM. But this modulation technique is used on digital modulation. In this, frequency of the carrier is changed in accordance with the data bit. For digital '1' frequency will be high while for digital '0' frequency will be low. FSK modulation technique is shown in below fig.







Applications

 1. Bluetooth or BLE(Bluetooth Low Energy) which normally used everywhere like in mobile phone, wireless speakers, Laptops, etc uses  GFSK( Gaussian Frequency Shift Keying ) modulation technique for data transmission. Difference between GFSK and FSK is nothing but GFSK has an additional Gaussian Filter to reduce the side band power.





Phase Shift Keying

In phase shift keying, phase of the carrier is changed in accordance with the data or base band signal. For digital data '1', phase shift will be 180 degree while for digital data '0', phase shift will be 0 degree.




QPSK Modulation


Application

1. WiFi has different versions based upon different IEEE standards. Different versions have different speeds and also uses different modulation Techniques. Out of them IEEE 802.11b uses QPSK modulation and 802.11a and g uses 16 or 64 QAM modulation for transmission. Difference between this two is the speed of data transfer. Obviously, 64-QAM is faster than QPSK.


2. Enhanced version of GSM is known as EDGE ( Enhanced Data rates for GSM Evolution ) uses 8-PSK modulation technique for faster data transfer as compared to GSM. GSM uses only 1 bit per symbol for data transfer while EDGE uses 3 bits per  symbol for data transfer. It is commonly called as 2.75G network



Minimum Shift Keying

MSK modulation can be compared with PSK modulation but the difference between them is, in MSK their is no abrupt change in the phase of the carrier signal, rather their is very smooth transition between different phases. It looks similar to that of FSK.




Application

1. MSK is used with Gaussian filter ( commonly known as GMSK ) is used in GSM mobile communication or 2G network. Gaussian filter is used to reduce the side band power of the spectrum. It's data transfer rate is only 1 bit per symbol. Enhanced version of GSM was developed which is known as EDGE( Enhanced Data rates for GSM Evolution ) which uses 8-PSK modulation which uses 3 bits per symbol, faster than GSM.

2. Ships uses GMSK modulation technique for communication with other ships as well as the station. Data like speed of the ship, its current position, Estimated Arrival Time, Type of the ship etc is constantly transmitted through Time division multiplexing. This Tracking system is known as Automatic Identification System (AIS).




This much of data I got when I was researching the topic "Application of modulation techniques". If you know something more than this, do share it with others by commenting below. 




#techiesms

Sunday, 17 April 2016

Practical Application - Description

Question


We all like to come FIRST and if we easily achieve this result by mugging the stuff, than what is the use of understanding the stuff???


Statements 

“Don’t go for the glory by mugging up, Go for passion and glory will follow.” says Jayraj Sagar

“People mistaken marks as knowledge/talent and that are the reason the past and coming generation both was and is practicing this.” says Parth Kalarthi

“Mugging up is nothing else than writing shit on a piece of a paper.” says Pratheesh Prasad

“Saari mark sheets samosa ki dish saaf karne k kaam aayenge, agar tumhe kuch nahi aata. (All mark sheets would be eventually used as garbage if you don’t know the things practically)” says Makwana Amit

“Sometimes in the battle of coming first, we forget that we are learning it for self development.” says Vijay Dhanwani.


What is the Problem?

In your journey of engineering, we come to learn new techniques, new methods, new technology and new theories many more such stuffs. But the problem is that, we exactly don't know that which of the technique is actually practically used and where it is used. Are we using that devices whose theory we have just studied?? Or are we studying the stuff which was never ever used practically?? 

Due to this lack of practical understanding I personally faced the problem of learning all the theories. I started mugging up all the contents. But soon I realized that why not try to see the actual applications of all this stuffs. So my interest took me on this way of researching and the result was I actually started loving those stuff and understanding that why particular thing is used in this device and It helped me learning new theories very quickly because I can now related the things with the device using particular technique.

 The need

In Digital Communication lecture, all guys were sitting doing their own stuff
rather than focusing on what the professor is saying. Some were acting to be 
focused and very few actually are. The topic which professor was teaching was based 
on Digital Modulation techniques. To be precise, he was teaching QAM (Quadrature Amplitude Modulation). This full form sounds too boring and I personally didn't pay attention to the 
theory and was busy in my mind thinking another stuff. So this is the current phase
 of almost all the students and classes. 


Lets look into another form.


In Digital Communication lecture, all guys were sitting doing their own stuff
rather than focusing on what the professor is saying. Some were acting to  be 
focused and very few actually are. The topic which professor was teaching was based 
on Digital Modulation techniques. To be precise, he was teaching QAM (Quadrature Amplitude Modulation). But this time, before going into theory he asked one question, 

Do you the modulation technique used for 3G  data transfer???
Why 3G data rate is faster than 2G???
This was the technique to draw attention of the student and to excite them. And actually 3G
data transfer or 3G communication uses 64 QAM modulation technique for faster data 
transfer. And I don't think now the professor has to tell the students to pay attention.
And seriously, if the students know the practical application and if they are using 
that techniques, I don't think they were ever going to forget this stuff. And Mugging dies here.




The Motto


As the tagline of my blog says, “If you have knowledge and experience more than others, then share it with others.” I would post the Practical Application of various theories on the blog. Anyone who doesn’t want to be mainstream; anyone who wants to understand the things would be entertained for sure.



Limitation


It’s quite intricate for me, finding the practical application of every theory but I came up with few interesting ones.As a not so famous quote says that,


So on next Sunday, I'll be posting one article based on practical application of  a particular Theory. And will share all the data gathered which I think will be definitely useful to you.


So this was my thinking based on my experiences and I came to this conclusion of writing such articles. So lets see how much this remedy will cure the disease named Mugging.




#techiesms

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

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

Tuesday, 16 February 2016

Analyze any IR protocol with just you Arduino board

               Recently, I was in deep research on how to make our own "Self Learning Universal Remote". So when I searched for the procedure of making this, first step I found is analyzing IR protocol,its frequency (time period),and also the combination of High and Low pulse for making a particular carrier frequency. And for measuring all these parameters, all the people either used DSO or some other hardware and software analyzer. But I didn't have any hardware or software for protocol analyzing except my Arduino MEGA board. Yeah!!!, now you can measure all the parameters of IR remote by your Arduino board only.



Steps for analyzing Frequency and Period

IR remote transmits the data by modulating it with a carrier frequency. Hence If we want to transmit the data through our arduino board, we must be aware of the carrier frequency of the remote. Hence analyzing Frequency and Time period becomes much important parameters.For analyzing the parameters,  people used Oscilloscope and other hardware, software for this but what if we don't have anything except our Arduino Board. Lets see how we can analyze these parameters using Arduino.

Things Requied are:

Arduino Board.
Photodiode.
330 ohm Resistor.

Connect Photodiode and resistor to form a potential divider circuit.


Connect the junction point to pin 2 of your arduino board and upload this code. And press the button in front of your photodiode. You will get response like this.



This process is like trial and error method because sometimes Photodiode may give the unexpected result. So I will request you to follow this process 5-10 time to get the accurate result. 

During my research, when I was decoding various IR remotes, I found that this data i.e. 12 us High,16 us Low and 35.7 kHz frequency is most common in all the remotes. But still you can confirm the parameters using this code.


Steps for analyzing Protocol

Different IR remotes follows different protocols. As I have also written blog for Samsung and NEC protocol previously, In that you can observe the difference. So after analyzing frequency and period, next step is to decode the data transmitted form that remote. 

Things Requied are:

Arduino Board
TSOP IR receiver

Connect TSOP's signal pin to pin2 of your Arduino board. And upload this code to your board.
After uploading, open the serial monitor, It will show "Press the button once".

After that press the button of your remote ONLY ONCE. Because:

Case i)

In case of AC remotes, whenever we press the button it will transmit whole data of that button only once even if we have pressed the button for quite long time. Hence we must press the button only once. By pressing the button for the second time, the buffer in the code will be overflowed and the arduino will restart.

The Response we get when we press button of panasonic AC remote is as follows:



So the data of 439 bits is received when we press the button once. And yes this much amount of data is sent in every button. Now this data is in form of time duration, so we need to convert it into binary form to analyse it. For that we must be aware that which type of encoding is done in this. Every IR remote uses Pulse Distance Coding i.e. PDC for encoding the data. Hence whether the bit is 1 or 0 can be decided by the duration of the LOW time in signal. Duartion of HIGH time in signal will be constant around 500 us, so we need not to consider HIGH time whenever converting it into binary form.

If the duration of LOW time is around 300 to 400 us, than that bit is binary '0'
and
If the duration of LOW time is around 1200 to 1300 us, than that bit is binary '1'.

You can analyse the received data and recognize the START bit, STOP bit, binary '1' and binary '0' by below mentioned range.


So the received data will be around the mentioned range and with the help of this we can easily decode the received data. Lets decode the data which is received in the above image.

So this is the decoded data of my Panasonic AC. Than convert this data into 8 bit HEX code. Panasonic AC protocol consists of 8 bytes constant data and 19 bytes of other data which contains information of Temperature, Fan speed etc. In total there are 27 bytes of data, which is transmitted when we press single button of the remote.

You can search for different protocols for decoding binary '1' and binary '0'. But if you don't get any information, you can go for this logic,

first bit will be always start bit. and last bit will be always stop bit.
if low duration is greater than 1000 us , than it is binary '1'
and
if low duration is less than 1000 us , than it is binary '0'.

I don't know that this will work for all the appliances or not but mostly this will work.


Case ii)

In case of TV,Setup box, Radio remotes the data is transmitted continuously as long as the button is pressed. Even if the data of that particular remote is sent, it will repeatedly send the same data as long as the button is pressed. 

So, we need to press the button only once so that data is recorded only once. When I press the Remote of Radio which follows NEC protocol, the response I get is as follows,


So I received 75 bits of data which is not the true number in case of a NEC remote. Because NEC protocol sends only 34 bits(34*2=68 bits  Here two is multiplied because for one bit we receive both High time and low time) of data including start bit and stop bit. But what if we don't know which protocol is this and how many data bits are their in that protocol??? In that case we need to look after the Stop bit. Now the question is how to recognize the stop bit. Stop bit of most of the protocols is a long duration of Low time. The duration is much longer as compared to the other bits in the signal, hence it easily gets highlighted in the serial monitor. The stop bit in this protocol is shown below,


In NEC protocol, the stop bit is 40,000 us long. Hence get easily noticed. So the exact data of the single button of NEC remote is upto this stop bit ( including stop bit).

And again, we can convert this data in its binary form by decoding the duration of Low time pulses.

Start bit High Time - 9050 - 9150 us
Start bit Low Time - 4450 - 4550 us
Data High Time -     450 - 650 us
Data Low Time '1' -   1650 - 1750 us
Data Low Time '0' -   450 - 550 us
Stop bit High Time - 450 - 650 us
Stop bit Low Time - around 40,000 us 

So with this you can convert this duration into binary data. In NEC protocol data format is like 
Start bit - Address byte - Inv. Address byte - Data byte - Inv Data byte - Stop bit.

So this is how you can analyze the protocol and parameters of different IR remotes by just using you arduino board. I tried my best to explain this topic in as simple way as possible, still if you have any doubt feel free to ask me by email or just comment below.

I have also made video on this topic, have a look.

You can download Codes from here.

#techiesms.