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.


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.


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 


Monday, 25 January 2016

IR Protocol Decoding and Transmiting through Arduino

In this blog, I will described various IR protocols adopted by different companies and will go in detail about 2 protocols. One is the most commonly used NEC protocol and another is the Samsung protocol. Why??? Because I have Samsung TV which uses its own protocol and a GTPL setup box, which uses NEC protocol as simple as that.

Source: Wikipedia

Different Companies uses their own protocols for eg. we have protocols like Samsung, LG, RC5/RC6 by Philips,and the most commonly used protocol NEC protocol.

Lets discuss the two protocols in detail.

SAMSUNG Protocol

Samsung protocol goes in sequence like a start bit,8 bit address,8 bit address,8 bit data and inverse of 8 bit data. In total there are 32 bits after start bit containing address and data.Start bit of this goes like HIGH for 4.5 ms and LOW for 4.5 ms. Followed by this start bit, address and data bits are transmitted. Frequency of transmission is around 38 kHz. To be precise it is 37.9 kHz. Level HIGH and level LOW is decided based on the duration on the low level of the signal. Logic 1 and 0 is decoded like this:

IR signal of samsung protocol will look something like this, and its sequence goes like

start bit - Address - Address - Data - Inverse Data - stop bit

start bit- 11100000 11100000 00100000 11011111-stop bit
This signal contains address - 11100000   data - 00100000.

NEC Protocol

NEC protocol is most commonly used for IR communication. Its frequency of transmission is around 38kHz. The difference in samsung protocol and NEC protocol can be easily identified by the start bit. Samsung has 4.5 ms mark and 4.5 ms space while NEC protocol have a start bit of 9 ms mark and 4.5 ms space.

Another difference between samsung protocol and NEC protocol is that NEC protocol contains Address and inverse of Address after that while samsung protocol repeats the address twice. Logic 1 and 0 of this protocol is same as that of samsung protocol.

Decoding and Transmitting Through Arduino

Decoding this signal using arduino is very simple. We will use pulseIn() function to read the duration of the pulse and accordingly decide weather the received bit is high or low.

Things Required;

1. Arduino Board
2. TSOP IR reciever
3. IR LED 

TSOP IR reciever will give digital output of the IR data received on 38 kHz frequency. By default, it will give digital 1. 
Note: This receiver will give the inverse output. i.e. If IR signal transmitted is 0, than TSOP reciever will give output 1.



First of all we will wait for the start bit of the signal. After that we will turn ON the led for indicating that IR signal is received.(This is the example of decoding a NEC IR signal).


Than we will check that whether the received data is logic 1 or 0 and we will store that 32 bit data in a boolean array.


Than we will separate address and data from this array. Now as we know that in NEC protocol the first 8 bits are the address and 17th to 24th bit are the data. Hence we will sort it accordingly.

Thats it. We have decoded the NEC protocol. Now lets see how to transmit it via IR LED.



First of all we will make a array of 32 bit and store the address in first 8 bits and the inverse of the address in another 8 bits. I am fetching the address value in integer from EEPROM.


Than we will store the data and inverse of the data in the remaining 16 bits of the array.


Than we will transmit this 32 bit data along with start bit and stop bit.Start bit of NEC protocol is HIGH for 9 ms and LOW for 4.5 ms. Here burst is the function which will send the HIGH signal at 38kHz frequency.

Burst is the function which will send pulses at 38 kHz frequency. Value of the burst signal may vary because of the time delay of the instructions. So I have tried by different divisions, and finally the transmitter was working when I divided the HIGH time delay by 38 for which actual dividend by calculation comes out to be 26 (9 us+17 us).

That's it. You are done with the decoding and transmission. You can even store the codes of the remote sequentially in the EEPROM and than transmit the code by fetching the data from EEPROM.
The pics in this blog are example of NEC protocol. I have attached link of a code for decoding and transmission  of code of Samsung protocol.

Further I am trying to make a self learning universal remote control which can simply copy the code into the memory and can be able to transmit the same signal. So that the issue of different protocols will be nullified.If any one have any idea regarding learning remote, do mail me.

Arduino Files:

Samsung Protocol Decoder
Remote Transmitter