Latest Entries »

This post is intended to assist you getting started with AVR DEVELOPMENT SELF LEARNING KIT.

It supports 40 pin AVR ICs like ATMEGA 16 /32 & a ZIF socket is provided to host the chip.All PORT pins are extended with berg pins for easy connections with peripherals.

For Analog input testing 2 nos variable pot are provided & for testing Digital inputs 4 nos switches are provided.A 4×4 keypad matrix is on board.

4 NOS 7 SEGMENT DISPLAY with driver circuit is provided.Other features include , EEPROM 24C16 , RTC  DS1307, UART MAX232 , MOTOR DRIVER ULN2003. An LCD can be plugged with the port provided.

An ISP connector accepts USBASP programmer through a 10 pin FRC Header.




Download sample code ,WINAVR , USBASP DRIVER, AVRPAL.NET from HERE

Watch this video for details of installing USBASP driver & getting started with AVR Kit.


Connect the USBASP AVRDUDE with ISP connector & USB cable to your port on PC.Power up the kit with the 12v/1A adapter provided.Once the driver is installed , under Device manager USBASP appears

Image 1


WINAVR is used to develop C code & upload HEX file on to the Target chip.WINAVR has a PROGRAMMERS NOTEPAD which is the IDE we use to develop code.

MFILE in WINAVR helps us to create the rules for making.This MAKE FILE must be saved within the same folder where you saved the C file.Compared to ATMEL STUDIO ( a HUGE Download) WINAVR is small & powerful.

Image 2


To start with create an empty Folder , say LED ,inside your drive.Here is where we’ll be saving all our files.

Open PROGRAMMERS NOTEPAD & type in the following C code.

Save the file as LED.c inside the folder we created earlier.

Do not forget the .C Extension.


#include <avr/io.h>
#include <util/delay.h>

int main(void)
DDRC = 0xFF; //Makes PORTC  as Output

while(1) //infinite loop
PORTC = 0b00000001 ; // LED ON at PC0
_delay_ms(100); // delay

PORTC = 0b00000000 ; // LED OFF at PC0
_delay_ms(100); // delay



The code starts with PREPROCESSOR Directives

# include <avr/io.h>     defines all PORT names & pins of AVR

# include <util/delay.h>   defines the delay timing

Then starts the MAIN function under which we first declare PORTC pis as all OUTPUT.

Notre that in AVR we use 1  to declare OUTPUT & a 0 to declare as INPUT (REVERSE TO PIC programming)

I/O Pins of AVR has 2 to 3 functions & each PORT is associated with 3 REGISTERS

For e.g PORTC is associated with 3 registers

DDRC —>  DATA DIRECTION REGISTER  Configures   Port as INPUT (0) or OUTPUT  (1)

PORTC —> Write Data to PORT Pins

PINC   —> READ DATA from PORT Pins


Next is the indefinite loop while(1)

Inside which we make PORTC bit 0 as HIGH & all other pins LOW.

This is achieved by Binary notation

PORTC = 0b00000001 ;

After a delay


we make PORTC bit 0 as LOW

PORTC = 0b00000000 ;

Now we need to create the RULES for Making which is done through MFILE of WINAVR

Open MFILE.Click on MakeFile

Select MCUtYPE as ATmega16

Port as usb

Programmer as usbasp.


Image 5


Under Progammer usbasp  is not listed. Select any other type like STK500 & then click on Enable Editing.

Now you’re allowed to make changes.Type in usbasp against Programmer.

Image 9

Scroll up to locate TARGET=main

Change this main to your C file name without any .c extension

Image 6

Save the Makefile inside the same folder where your C code is stored.

Image 7

Now click on MAKE ALL to generate HEX file.

Tools –> Program to load the HEX file automatically on to the target chip.

Image 4

Now let us see how to use the BITWISE OPERATORS in C code

To improve code clarity & to leave generation of  1s & 0s to the compiler we use SHIFT OPERATORS.

For e.g  instead of writing 0b0010 0000

we can write    0b0000 0001 <<5

or simply         1<<5     This is left shift operation.

0B0001 0000 << 3   will result 0B1000 0000    SHIFTING LEFT 3 TIMES

To generate  0B1110 1111    SHIFT FIRST & THEN INVERT IT




To set an individual BIT we use the OR OPERATOR  |

e.g   DDRD = 0b0000 0001    To SET bit 4

SHIFT it 4 times to get 0b0001 0000

OR this result with DDRD Register

DDRD = DDRD | (0b00000001 <<4);

DDRD = DDRD | (1<<4); 

or you  can write simply   DDRD |= (1<<4);

Only BIT 4 is SET & other bits not affected.

You can also define a constant & use it

# define LED 4

DDRD |= (1<<LED);



e.g  DDRD = 0b0101 0101;

To clear the bit 2 (shown in bold letter above)

start with binary no.    0b0000 0001

Left SHIT 2 TIMES  to get  0b0000 0100

Invert this to get    0b1111 1011

use the & OPERATOR with DDRD Register


#define switch 2

DDRD &= ~ (1<< SWITCH);



To check status of 4th bit of PIND Register

Notice the use of PIN Register here

#define switch 4

status = (PIND & (1<< SWITCH) !=0);




To toggle 4th bit of PORT D

PORTD = 0B0000 0000

START with 0b0000 0001   shift by 4 times to get

0b0001 000


#define LED 4

PORTD ^= (1<< LED);

Every time this statement is executed the LED changes state


Following is the code with BITWISE operators implemented.

We use OR EQUAL LEFT SHIFT to declare portC as output

Inside while loop PORTC BIT 0 is made ON & then OFF after a delay , which is repeated for ever.


#include <avr/io.h>
#include <util/delay.h>

int main(void)
DDRC |= (1 << PC0); //Makes PORTC PC0 Pin22 as Output

while(1) //infinite loop
PORTC |= (1 << PC0); //Turns ON LED at PC0 or PORTC=0b00000001
_delay_ms(100); // delay

PORTC &= ~(1 << PC0); //Turns OFF LED or PORTC=0b00000000
_delay_ms(100); // delay



cooltext753793315    cooltext753790696


Arduino ProMini , as the name indicates , is a miniature version of UNO .It runs on 16 MHz crystal ,ATMEGA328 ,but lacks USB connectivity. There are 5V  (16MHz) & 3.3V (8MHz) versions. In this demo I use the 5v version.




There is a voltage regulator on board so it can accept voltage up to 12VDC. If you’re supplying unregulated power to the board, be sure to connect to the RAW pin and not VCC.

Vcc accepts only 5v.

The latest version of this board breaks out the ADC6 and ADC7 pins ,also adds footprints for optional I2C pull-up resistors.

To upload code on to pro mini , a USB-TTL adapter is required.There are many types of  USB adapters available.The most reliable one that works up to Windows 10  is the one built on CP2102 IC .

CP2102 adapters are available in 2 variants .One with 6 pins that include the DTR  , Data Terminal Ready , which handles the RESET required by the promini board.

The other board is commonly available one with 5 pins.Here RESET must be done manually on promini while code is uploaded.






First let us upload code using the 6 pin version .

The connections are

PROMINI                USB-TTL

DTR   —–>   DTR

TxO   —–>  Rx

RxI    ——> Tx

Vcc   ——> 5v

GND  ——> GND

In some Promini boards the DTR pin is printed as GRN.


Plug in the USB board to PC & open the Device Manager . If the driver is installed previously , a COM port will be allotted.Otherwise , download the silicon labs cp2102 driver from here & install.


Image 1

Open the Arduino IDE , feed in the COM port allotted.

Select Board as Arduino Pro or Pro Mini , Programmer as USBasp.

In newer versions of IDE there is option to select type of ProMini board.Under Processor select ATmega328 5v,16MHz

Image 2

From Examples open the BL;INK sketch

Image 3

Click on UPLOAD button.

The DTR pin of USB board takes care of the RESET  & your code will be uploaded to PROMINI without any manual reset.


Image 4

Uploading code using a 5 pin version , needs a manual RESET on PROMINI.

The connections are

PROMINI                USB-TTL

TxO   —–>  RxD

RxI    ——> TxD

Vcc   ——> 5v

GND  ——> GND



Plug in the USB to PC & note the COM Port allotted.

Open Arduino IDE .Feed in the COM port , select board as Arduino Pro or Promini & Programmer as USBASP

From Examples , open the BLINK Sketch

Image 2.1

Click on UPLOAD button.

Image 2.6

Watch out for the message at the bottom of IDE.

“ Compiling Sketch “ message appears first.

Then it changes to “Uploading”

Image 2.2

As  soon as you see “Uploading” message , gently press the RESET Key on Promini.

This should be done instantly , as soon as you see “UPLOADING” message.

Image 2.3



If the KEY Press is at the right time , your code will be uploaded successfully.



You can also use your UNO board to upload code on Promini.

To use the UNO board , you need to by pass the bootloader .For this  upload an empty code to UNO or connect the RST pin to GND

Connecting RST pin to GND bypasses the bootloader & only the serial converter IC located near the USB socket is used as USB-TTL.

The connection here is STRAIGHT & not reverse

Tx of Arduino UNO goes to Tx of Promini

Rx of UNO goes to Rx of Promini

Gnd to Gnd



Connect the USB cable to PC & open the IDE.

Select the port where UNO is connected.

Image 2.5


Select the board as Arduino Pro or ProMini

Image 3.1

Open the BLINK sketch & UPLOAD.

Watch out the message at the bottom of IDE.

Initially “Compiling Sketch “ appears.

Then the message changes to UPLOADING…


Image 6

Once you see UPLOADING… message  , press the RESET key on PROMINI.




The code is now Uploaded successfully.

Image 7

Support VIDEO :

cooltext753793315   cooltext753790696

In the previous post we’ve seen how to connect the Arduino ETHERNET SHIELD to a Router directly  & upload LM35 data to Thingspeak.

What if  you do not have physical access to your Router & your Laptop is connected over WIFI to the Router. Or you cannot run a RJ45 cable from Router to Ethernet shield.

The procedure we follow is similar to the one we did for connecting Raspberry PI to Laptop.

Link here

First step is to enable SHARING of your existing internet.In my case , Laptop is connected to Router

over WIFI.

Open Control Panel –> Network & Internet –> Network & Sharing Center

Click on the existing internet connection

Image 1

On the next screen click PROPERTIES &  then SHARING

Image 2

Tick mark to ENABLE SHARING of Internet connection

Image 3


Now plug in the USB cable to Arduino & then connect the RJ45 Straight cable from shield to the RJ45

Port of LAPTOP.


As soon as you connect the RJ45 cable you can see an UNIDENTIFIED NETWORK


Image 4


Click on that new Network , select PROPERTIES.

On the next screen double click on Internet Protocol version 4 (TCP/IPV4)

Image 5

You can see an IP address like

Note that this is the new Gateway IP of the new network formed by Ethernet shield.If you do not see any IP , just select the “ Use the following IP “ &  feed in manually the IP.


Image 6


to verify the IP.

Under Ethernet adapter the Gateway IP of new network is displayed.

Note that this is the GATEWAY IP & Ethernet shield will be allotted IP in this range  .


Image 7

Let us try some built in example codes.

Under Examples  –> Ethernet –> select  DhcpAddressPrinter

This will print the IP allotted to the Shield.


Upload the code & open up the Serial monitor.

The IP allotted to the shield here is  which is in range of new Gateway .

Image 9


Next example is WEBSERVER

Image 10


Open the WEBSERVER code .

You need to change the IP Address as




Here change it to where the SERVER will be started. Note the usage of comma instead of dot between each byte.

Image 12


Upload the code & open the serial monitor to verify that SERVER is started.

Image 13

You can use your Browser as CLIENT.

Type in the IP to access the server.

On the Serial monitor “Client connected “ information will apper.

Image 14

On the browser you can see the values of ANALOG Pins of Arduino.

As nothing is connected to the Analog pins , you get random values.

Image 17


Next example is the TELNETCLIENT

Image 2


Open the code.

Here Ethernet shield is used  as CLIENT & you need to change the IP of client in range with the new Gateway

Next is the IP of the SERVER . This may be another PC or Android phone connected to the same Network .

Here the SERVER is started on PC with IP

Note that this IP is in the range of Gateway of Router

Image 3

Scroll down further & note the PORT number on which the SERVER will LISTEN.

Here it is 10002.

Upload the code on to Arduino.

Image 4

To test the setup , you need to start a SERVER on another PC on the same network with IP

For this we use HERCULES software. DOWNLOAD HERE

Click on TCP Server tab on Hercules , feed in the port number 10002 & click LISTEN.

The server is started on PC with IP , so , no need to enter the IP

Image 5

Now open the Serial Monitor of Arduino where SHIELD is declared as CLIENT.

You can see the “Connected..”  feed back from the Server.

Type in some characters on Arduino side , as well as Hercules side to verify 2 way communication.

Image 6

Instead of PC & HERCULES you can use your Android mobile ( to be connected over WIFI to the same Network).

On your mobile install TCP TOOLS



The IP of Android device is shown with default port 8080.Click on LISTEN

In the TELNET CLIENT code you need to change the SERVER IP t from 1,1,1,1

to & then change the port of server to 8080 & then upload to Arduino


mobile 2

Once code is uploaded open the Serial monitor.

On mobile you see the IP of CLIENT connected


Test 2 way communication by typing in characters.





Next we shall test the code which sends LM35 Data to THINGSPEAK SERVER.

You can check my previous post for details

Upload the same code without any change in IP.


Image 7

Open the Serial Monitor to see the data being uploaded to THINGSPEAK.

Image 8


cooltext753793315   cooltext753790696

Ethernet shield acts as wired Gateway between your Arduino & Internet.

This post demonstrates how to upload  temperature data from LM35 sensor to the server on THINGSPEAK.Before starting you should know how to connect the shield to Network.

There are 2 options by which your shield is connected to the Network.

First is the direct connection to your Router .You’ve an available RJ-45 port on your Router & you directly use a straight RJ45 cable to plug Ethernet shield to Router .Your PC/Laptop is also connected to the same Router either by wire or through WIfi (if your Router is WIFI capable).

Second is the indirect connection.Your shield is connected to your Laptop’s RJ45 with wire.Your Laptop is connected to Router through WIFI.In this case you need to bridge the connections or use the shield as unidentified second network with a different IP.

In this post we use the first Direct connection to Router method.

Check this connection image where my Ethernet shield is connected directly to  Router.My PC is also connected to the same Router by WIFI . Router is provided Internet access by the Internet Service Provider ACT.






To start with let us fix the IP of Ethernet shield STATIC , so that it is always the same on every boot up of Router.

From your PC  RUN –> CMD

Type in  ipconfig /all

The Default Gateway here is which is the IP of the Router.

All clients connected to this Router will be assigned IP in this range  where the last byte is from 2 to 255 (allotted on first come basis)

Image 1

In the above screenshot you can see (ipV4 address), my PC is assigned IP

IP is assigned automatically by Router , only when the DHCP is enabled in Router setting.

Type in your browser , the gateway IP & feed in your Router’s username & password  (generally both are “admin”)

Under DHCP settings ensure that DHCP is Enabled.

Image 2


Now click on the DHCP CLIENT LIST to know the devices connected to the Router.

In my case 2 devices connected.One is my PC which is allotted IP

& the second device is Ethernet shield which is allotted

But in our code we use IP .

Let us change the IP to & make it STATIC.



& then click ADD NEW



Feed in the MAC address of the Ethernet shield & the reserved IP as

The MAC address is the one you used in the code.This may be random unless you use more than one shield in the same network.


Click on SAVE & then REBOOT your Router to enable the changes made.


Now under DHCP Client list you can see your shield allotted & permanent (means STATIC IP)




Connect the 1st pin of LM35 to 5v of Ethernet shield , 3rd pin to GND. 2nd pin is connected to A0

Analog pin.

Connect the USB cable from ARDUINO to PC & note the PORT allotted.The RJ45 STRAIGHT CABLE is connected from Ethernet shield to Router directly.

Upload the following code on to Arduino.You need not change the MAC address.

You need to change the Gateway IP as per your Router & also change the IP of shield in this range.

Also you need to change the THINGSPEAK API according to your CHANNEL setting

Download Arduino CODE Here


#include <SPI.h>
#include <Ethernet.h>

int pin = 0; // analog pin
int tempc = 0,tempf=0; // temperature variables
int samples[8]; // variables to make a better precision
int maxi = -100,mini = 100; // to start max/min temperature
int i;

// Local Network Settings
byte mac[]     = { 0xD4, 0xA8, 0xE2, 0xFE, 0xA0, 0xA1 }; // Must be unique on local network
byte ip[]      = { 192,168,0,150 };                // Must be unique on local network
byte gateway[] = { 192,168,0,1};
byte subnet[]  = { 255, 255, 255, 0 };

// ThingSpeak Settings
char thingSpeakAddress[] = “”;
String writeAPIKey = “QGBA1G3872XSHBAC”;    // Write API Key for a ThingSpeak Channel
const int updateInterval = 10000;        // Time interval in milliseconds to update ThingSpeak

// Variable Setup
long lastConnectionTime = 0;
boolean lastConnected = false;
int failedCounter = 0;

// Initialize Arduino Ethernet Client
EthernetClient client;

void setup()

Ethernet.begin(mac, ip, gateway, subnet);
Serial.print(“ETHERNET SHIELD ip  is     : “);
// Start Ethernet on Arduino

void loop()

tempc = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;

String analogPin0 = String(tempc);

// Print Update Response to Serial Monitor
if (client.available())
char c =;

// Disconnect from ThingSpeak
if (!client.connected() && lastConnected)


// Update ThingSpeak
if(!client.connected() && (millis() – lastConnectionTime > updateInterval))

lastConnected = client.connected();

void updateThingSpeak(String tsData)
if (client.connect(thingSpeakAddress, 80))
client.print(“POST /update HTTP/1.1\n”);
client.print(“Connection: close\n”);
client.print(“X-THINGSPEAKAPIKEY: “+writeAPIKey+”\n”);
client.print(“Content-Type: application/x-www-form-urlencoded\n”);
client.print(“Content-Length: “);


lastConnectionTime = millis();

if (client.connected())
Serial.println(“Connecting to ThingSpeak…”);

failedCounter = 0;

Serial.println(“Connection to ThingSpeak failed (“+String(failedCounter, DEC)+”)”);


Serial.println(“Connection to ThingSpeak Failed (“+String(failedCounter, DEC)+”)”);

lastConnectionTime = millis();

void startEthernet()


Serial.println(“Connecting Arduino to network…”);


// Connect to network amd obtain an IP address using DHCP
if (Ethernet.begin(mac) == 0)
Serial.println(“DHCP Failed, reset Arduino to try again”);
else {
Serial.println(“Arduino connected to network using DHCP”);
Serial.println(“Data being uploaded to THINGSPEAK Server…….”);





You need to sign up with  to upload your data to the server.

Open your account on THINGSPEAK & select MYCHANNELS under CHANNELS




Feed in Name & Description of your channel & under FIELD1 enter name of field like TEMPERATURE

Scroll down & Enable PUBLIC VIEW.


Save the CHANNEL & then click on API KEY tag


Note down the WRITE API KEY


Replace this code with yours inside the Arduino code.


Upload the code.

Please ensure that you’ve changed following settings in your code before uploading:

1. Gate way IP of your Router.

2. IP address of your Shield in range with gateway IP.

3. Thingspeak  API WRITE KEY from your Channel


Once uploaded you can open the Serial Monitor of Arduino , to see data being uploaded to the Server


On your THINGSPEAK Channel click on Public View to see the Graphical representation of the LM35 data being uploaded.


If you get Arduino Failed to connect to Network,  then you need to check the IP address credentials again.


HTTP POST Method to write data on to server


In the Arduino code data is converted to STRING type & uploaded to Thingspeak. Thingspeak server accepts only String type data.,

The HTTPS method used in code is POST method .Other HTTPS methods are  GET ( to read data), PUT ( to update data), DELETE ( to delete data).

Understand the basics of this method which we will be using in upcoming posts of ESP8266 & other IOT related projects.

We use POST to submit data to THINGSPEAK Server.

POST request is a bunch of STRINGs.

Each request line is separated & ends with a newline.


client.print(“POST /update HTTP/1.1\n”);
client.print(“Connection: close\n”);
client.print(“X-THINGSPEAKAPIKEY: “+writeAPIKey+”\n”);
client.print(“Content-Type: application/x-www-form-urlencoded\n”);
client.print(“Content-Length: “);


The first string is the Message STARTLINE which has 3 elements separated by SPACE

POST /update HTTP/1.1\n

First element is the URI –Uniform Resource Identifier ( not URL) which is nothing but the method POST all in capital letters. Next element is the protocol /update & the 3rd element is the version  HTTP/1.1 . At the end  \n is used for new line , or you can use println instead of print.

Once we send the message start line string, then we need to  send different header fields. The HEADSER FIELDS are  predefined fields that give the Thingspeak server , information about our POST request. Apart from standard fields , there’s some non-standard fields.

If it’s a non-standard field, the header name is usually preceded by an x. Each header field that we send is going to be its own string, separated by a newline.

We’re going to send following different Headers :

1.Host header field,

2.Connection header field,

3.The x ThingSpeak API key header field,

4.Content type header field,

5.  Content length header field.

1} For ThingSpeak, the host is going to be —–>

2) For the connection header, we specify close, and that’s because after we make our request and after we get our response, we want to close the connection with the server. There’s no need to keep that connection open between sending information, so we close it.

3) The X-ThingSpeak API key header is a non-standard header, and that is going to be set to our Write API key that we can find out  from our ThingSpeak channel.

4) The content type header is going to indicate the kind of media that we planned on sending in the header body, In HTTP there are two ways to POST data:




We use the first one as we update string data.

For application/x-www-form-urlencoded, the body of the HTTP message sent to the server is essentially one  query string — name/value pairs are separated by the ampersand (&), and names are separated from values by the equals symbol (=).

5) The content length header specifies the size of the media that we’re going to be sending in bytes.


Once we’ve set the header fields, the last thing we do is send the message body.

The message body is the actual data that we want to update & post to the server. Just like the message start line, and just like the header fields, the message body is going to be a string of text. The message body is  separated from the header fields by two newlines.

client.print(“\n\n”);     // 2 new lines


Those two newlines are what let the server know that  we’re done with the header fields & we’re moving on to the message body.

Our message body is simply listing the field that we want to update with an equals sign followed by the value that we want to update it as.


If we want to do multiple fields, we separate them with the “and” sign. There’s no spaces in this message body

We’ve got the message start line. We’re identifying the method, the URI, the resource we want to use, and the protocol type. Then we specify the header fields. This is giving information to the server about the request that we’re making.

Finally, we have the actual message that we’re sending.

That makes up a basic HTTP POST  request



cooltext753793315   cooltext753790696



pic2    pic3


PICKIT3  seems to be a DEGRADED version of PICKIT2 . PIC may be a Microcontroller Giant , but a newer version of Toolkit should be more user friendly than the previous versions.In case of PIC the design Team has never bothered this.

Following are the Changes made in PICKIT3 , which many have criticized  :

1. The little useful standalone program  PICKIT2 to fuse HEX files is scrapped now.There is no standalone program to fuse HEX files.Now you need to install MPLAB IPE along with MPLAB X IDE & use that for fusing target IC with HEX file.

2. PROGRAMMER TO GO function of PICKIT2 is scrapped in PICKIT3.

This function allows a PIC MCU memory image to be downloaded into the PICKIT 2 unit for later programming into a specific PIC MCU. No software or PC is required to program devices once the PICkit 2 unit is set up for Programming-To-Go

3. TARGET is not powered automatically in PICKIT3. In PICKIT2 Automatic Power feature is enabled by default.In case of PICKIT3 you need to CONFIGURE manually , else you get TARGET NOT FOUND error.

4.PICKIT3 does not detect DEVICE automatically.You need to select the device from drop down list.

5.PICKIT3 uses PIC24 series MCU , while PICKIT2 was designed on PIC18 series.But PICKIT2 seems to be faster than PICKIT3.

6.If you change the target IC , Firmware upgrade happens every time in PICKIT3 , an annoying feature.   

As MICROCHIP has stopped production & support to PICKIT2 we’ve to live with PICKIT3.Let us now see the solutions for common problems faced in using this “ADVANCED Device”.

You can fuse the HEX file from within MPLAB X IDE or through MPLAB IPE..

MPLAB X IDE Method :

From within MPLAB IDE click the Icon with down Arrow image “Make & Program Device Main Project”.

The project is now BUILD.

Once you get BUILD SUCCESSFUL in the OUTPUT Window , the IDE will try to connect with PICKIT3 Programmer




But you get TARGET NOT FOUND error.



Click on RUN –>set project configuration –>CUSTOMIZE



On the new window select PICKIT3


Under OPTIONS CATGEGORIES drop down select POWER



Tick mark “Power Target circuit from Pickit3”

& select voltage level as 5.0



Click OK & then click on the  “Make & Program Device Main Project” again

Now the target is detected & HEX file fused on to target.


Method 2 : Through MPLAB IPE

From MPLAB IDE click RUN –> BUILD MAIN PROJECT  to create the HEX file.


The HEX file is created inside the PROJECT File –> dist –> default –> production

Note the location of HEX file.

Image 6

Now open MPLAB IPE the Integrated Programming Environment


Image 17

Select the IC , here PIC16F877A , Apply & then click on CONNECT

Image 7


You get Target Not found ERROR.

Image 8


Image 9


To enter Advanced mode you need to type in the password –     microchip

Image 1

Now a new set of buttons appear on left side.

Click on POWER button

Image 11

Select Vdd as 5.0 & then tick mark “POWER TARGET CIRCUIT FROM TOOL”

Image 12

Now click on OPERTATE button

Image 13

The target is found & connected now.

Click the browse button & navigate to select the HEX file stored.

Image 14

Click PROGRAM button to fuse the target chip with selected HEX file.

Image 15


Image 16


cooltext753793315   cooltext753790696

Generally Raspberry PI is connected to a Router as an individual computer.In case you do not have access to your Router you can very well connect PI to Laptop through an ETHERNET STRAIGHT Cable.

The available RJ45 cable in the market is mostly STRAIGHT cable & not CROSS OVER one.

Before connecting the PI to Laptop , open your Network & sharing center & click on your Internet connection.Mine is on Wireless Network


Image 4

On the next screen click on the  properties button.


Image 5

Under SHARING tab Tick mark “Allow other network users…..”

Click OK to enable Network SHARING.

Image 6

Now let us enable SECURED SHELL – SSH on Raspberry PI OS , so that it can be accessed over network.

This can be done by connecting RPI to a HDMI TV & a keyboard.

Under terminal open RASPI-CONFIG & enable SSH under Advanced options.

But in this post I consider a Headless mode , presuming that you do not have access to a TV or keyboard.You need a CARD READER for this purpose.

Place the SD card with Raspbian OS on to the card reader & plug it to ypur laptop.

Note down the Drive letter allotted.Here it is I:\  in my case


Image 1

Run CMD & type in following

echo >I:\ssh

Now a file named ssh without any extension is created under \boot.

Image 2


Image 3

While PI is booted up then , it looks out for the file named ssh.

If it finds one , it enables SSH & then deletes the file you created.

This is how SSH is enabled in the new Raspbian OS.By default SSH is disabled in new OS for security reasons.

Plug the SD card on to PI & connect the ETHERNET cable to Laptop’s RJ45 slot.

Power up the PI to see a new Unidentified network .

Image 7

Click on that new Local Area Connection that appears & then click properties.

On the next screen , double click on Internet Protocol Version 4(TCP/IPv4)


Image 8

Now you see the IP address of the new Network created.

Here it is which is the GATEWAY IP of the new Network.

PI will be allotted IP within this range

Image 10

To know the IP of RPI we make use of ADVANCED IP SCANNER

Download from here & install the scanner

Open the IP Scanner program & type in the Range to scan as to

Image 11

Click on the scan button.

The IP scanner will detect the Raspberry PI & displays its IP along with host name & MAC address.

The host name is   & the IP is

Image 12

You can use either the host name or the IP to access the PI.

We make use of an X Forwarding software called MOBAXTERM for a Graphical Interface.

You can use XMING server , but a separate SSH client like PUTTY is needed for that.

MOBAXTERM is a standalone freeware with an inbuilt SSH Client.

Download the X Server

Image 13

Fire up the MobaXterm_Personal application.

Image 14

Click on SESSION & then SSH

Image 15


Under Remote Host type in the host name of RPI



or you can use the IP address of PI we obtained from IP Scanner earlier.

Image 16

Now you get the login window.

Login username is pi & password is raspberry

Image 17


Now you are logged into Raspberry PI & you get the ~$ prompt

Image 18


To open Graphical interface , type in



Image 19


You get a warning message SSH is ON .

Image 20

Click OK to see the DEBIAN SWIRL desktop.


Image 21


Image 22


Image 24




To enable WIFI & internet access , watch this video :



cooltext753793315  cooltext753790696











Image 13

The older XBEE modules S2 & S1 are not capable of communicating  with each other. S2 can talk only to S2 , S1 with S1 .You cannot mix the modules.

The new XBEE S2C is capable of communicating with S2 as well as S1 modules.

For S2C to S2C configuration you can check out the previous post Here

XBEE S2C with S2

Place an XBEE S2C module on USB adapter & plug on to USB port of your Laptop.Open the XCTU & search for the radio.Once the radio is detected , select it & load the settings.

Image 2


The product family is XB24C  & the Function set is ZIGBEE TH Reg.  (Through Hole Regular).

Image 3

The PANID is set to 1234.

The same PANID to be set for the other Radio also.The Destination LOW address is FFFF which makes the Radio to BROADCAST mode.

AP is TRANPARENT mode which is AT mode

NI is Node Identifier which you can name it as COORDINATOR.

Image 4


Image 5

Click on the PENCIL icon on top to WRITE the settings made.

Now plug the S2 module on another USB adapter & plug it to other USB port .

Search for the Radio & select it.

Image 6

Load the settings & click on the UPGRADE FIRMWARE button.

Select the product family as XB24-ZB & the Function set as ZIGBEE ROUTER AT

Image 7


Click on FINISH button to complete the upgrade action.


Image 8


Image 9


Set the PANID as 1234 , same as that of COORDINATOR.

JV is ENABLED , so that the radio joins Coordinator on power on.

DL is set to 0 , which is the default address of coordinator.

Image 10

Now the S2 module is configured as Router.

Leave this module on the XCTU & close the Coordinator module.

Start another instance of XCTU window & search for the COM port , select the Coordinator Radio.

Place the XCTU windows side by side.Coordinator to the left & Router to the Right.

Image 11

Click on the Terminal icon on the top & then click the SERIAL connect icon.The open Serial icon now changes to a closed one.Do this on both the windows.

Image 12

Type in some message inside S2C window which will be received by the Router.Both way communication is possible (Full Duplex)


Image 13

S2C with S1

Now pull out the S2 module from USB adapter & replace it with S1 module.

S2C is left on the same USB port.

S2C module is to be upgraded Firmware 802.15.4TH .

Click on the Upgrade Firmware icon & select XB24C –> 802.15.4 TH & the latest version.

Click Finish to upgrade.

Image 14


The CHANNEL is left to default C.

PAN ID is 1234 , DL is FFFF

MY address is 0





Now start another instance of XCTU & select the COM port where S1 is plugged on.

Select the Radio & load the settings.

S1 belongs to Function set XB24  –>802.15.4



The Channel is set as C

& PAN ID 1234   same as that of Coordinator

DL –> 0  MY address is 1 & CE is set to END DEVICE.c

Image 17

Click on WRITE button to save the changes made.

Place both the XCTU windows side by side.

Click on TERMINAL icon & then SERIAL Lock on both the windows.

Test for communication by typing some message which appears on the other window.

Image 50

Watch this Support Video  :




DIGI International has recently introduced the new ZIGBEE S2C Module .The previous S2 & the traditional S1 both are discontinued.

The new module is powerful with both UART & SPI communication .

Operating frequency band is The industrial, scientific and medical (ISM) radio band
ISM 2.4 – 2.5 GHz

It utilizes Silicon labs EM357 transceiver

The Module is faster and has more RAM & flash memory with much reduced power consumption.

Increases the mesh capabilities & consumes under 1 micro amp sleep current.

Interface options : UART 1 Mb/s maximum (burst)  , SPI 5 Mb/s maximum (burst)

Here is the comparison chart of S1 , S2 & S2C .The Indoor/Outdoor range of S2C has also increased much more as the transmit output power is  double.Also it works on supply voltage from 2.1v to 3.6v DC.



Here are the device types of XBEE :

Device types

ZigBee defines three different device types: coordinator, router, and end device.

clip_image001 Coordinator

ZigBee networks always have a single coordinator device. This device Starts the network, selecting the channel and PAN ID.Distributes addresses, allowing routers and end devices to join the network.Buffers wireless data packets for sleeping end device children.

The coordinator manages the other functions that define the network, secure it, and keep it healthy. This device cannot sleep and must be powered on at all times.

clip_image002 Router

A router is a full-featured ZigBee node. This device can join existing networks and send, receive, and route information. Routing involves acting as a messenger for communications between other devices that are too far apart to convey information on their own.

Can buffer wireless data packets for sleeping end device children. Can allow other routers and end devices to join the network.Cannot sleep and must be powered on at all times.May have multiple router devices in a network

clip_image003 End device

An end device is essentially a reduced version of a router. This device can join existing networks and send and receive information, but cannot act as messenger between any other devices.Cannot allow other devices to join the network.

Uses less expensive hardware and can power itself down intermittently, saving energy by temporarily entering a nonresponsive sleep mode.Always needs a router or the coordinator to be its parent device. The parent helps end devices join the network and stores messages for them when they are asleep.

ZigBee networks may have any number of end devices. In fact, a network can be composed of one coordinator, multiple end devices, and zero routers.

Modes of operation
The XBee ZigBee RF Module is in Receive Mode when it is not transmitting data. The device
shifts into the other modes of operation under the following conditions:
— Transmit Mode (Serial data in the serial receive buffer is ready to be packetized)
— Sleep Mode
— Command Mode (Command Mode Sequence is issued, not available when using the SPI port)

Now let us practically see how to configure the Radio S2C. For communication one of the Radios to be configured as COORDINATOR & the other one as Router.

The Product family of S2C is  XB24C  (the previous S2 module belongs to XB24-ZB)

These S2C modules should be able to communicate with older modules, so long as they are all running compatible firmware (i.e. DigiMesh, ZB, etc..)

Following is the pin configuration of S2C.



To configure the XBEE you need an USB XBEE Adapter which can be easily connected to the USB port of your PC.



In case you do not have this USB board , you can use your Arduino board as USB-UART. For this you need to connect RST of Arduino to GND.This bypasses the bootloader of Arduino & the board can be used for Serial communication.Remember to connect Rx to Rx , Tx to Tx (straight & NOT reverse connection) between Arduino & XBEE while configuring.

You can watch this video on how to use Arduino to configure XBEE


Let us start with the configuration.Plug the S2C modules on to the USB adapters & connect to USB ports of your PC.

Open the new XCTU Software .S2C can be configured with this new XCT. The classic old XCtu does not support the S2C module.

Click on the SEARCH icon on top to detect the USB ports.

A list of active USB COM ports will be displayed.

Select the COM ports where you’ve connected the USB adapters.To confirm you can verify your DEVICE MANAGER for the proper COM ports.

In my case one of the USB adapter is allotted COM3 & the other one COM31.

Image 1

Click on NEXT & accept the default PORT PARAMETERS .

96008N1 is the default.  9600 is the BAUD RATE , 8 Data Bits, No Parity & 1 Stop bit.

Image 2

Click on FINISH .

The XCTU scans the USB ports selected & lists the RADIOs found with their unique 64 bit address.

Image 3

Select both the devices & click ADD SELECTED DEVICES.

Now both the Radios appear on the left pane.

Image 4

Let us configure the RADIO at COM3 as COORDINATOR first.

For this click on the COM3 RADIO to load the module settings.


Image 5

Once the parameter settings are loaded you can see that the product family is XB24C  (in case of old S2 it is XB24-ZB & of S1 is 802.15.4)

The function set of Firmware is ZIGBEE TH Reg , the Reg stands for Regular & not PRO. TH stands for THROUGH HOLE & not SMD.

Image 6

First thing is to set the PAN ID of the Network. This can be from 0 to FFFF hex.In my case I’m setting it to 1234.The other Radios also to be set in the same PAN ID.

Scroll down further & Enable the CE (Coordinator Enable)

 Image 7

The Destination address DH is left to default 0.

The Destination Address DL is set to hex FFFF which makes the Radio work on BROADCAST mode, so that it can communicate with all Radios in the same PANID.

The Node Identifier can be given any name like “Coordinator”.This naming  is optional.

Image 11_1

Click on the PENCIL icon on top to WRITE the changes made.

Image 8


Now let us configure the second Radio as ROUTER.

Click on the second Radio on the left pane to load the settings.

Image 12

The Router setting is quite simple.

Enter the PANID as 1234 , same as that of Coordinator.

Image 13



CE Coordinator is DISABLED

Destination Address DL is left to default 0 . (0 is the default address of Coordinator)




Click on WRITE button to save the changes made.

Image 14

The modules are paired & ready for communication.

Now let us test the communication.On the XCTU window delete the second Radio .Click on the first Radio to load the settings.

Leaving the XCTU window open , start another instance of XCTU &position it to the left of the previous window.

Image 15

Click on the Search button on the new instance of XCTU & select the second Radio .

Image 16

Click on the Radio selected to load the settings.

Image 17

Now the ROUTER Radio is on the left side & the COORDINATOR Radio to the Right.

Image 18

Click the TERMINAL icon on both the windows to enter Terminal mode.

Image 19

Click on the SERIAL CONNECTION icon on both the windows to enter the serial connection mode.

Image 20

You can see the SERIAL Icon in LOCK mode & the AT CONSOLE Status changes to CONNECTED.

Now you can type any message inside console log window & see that received on the other Radio.The transmit message is in BLUE & received message in RED.

Image 21


Once the Function set is selected , click on FINISH to load the firmware.

802.15.4 firmware is like that of our classic S1 module.But setting is slightly different.

CH channel can be left to default C

PANID to be selected , say 1234 ( the other Radio to be on same ID)

DL address is FFFF

CE coordinator enable for first Radio


For the second Radio , to be set as END device

CH Channel C

PAN ID 1234 , same as Coordinator

MY address is 1 ( the coordinator MY is 0)

CE is set to END device



Click on WRITE button & test the modules for communication.

In this 802.15.4 Firmware POINT TO POINT communication only is possible & NO MESH Networking.

In a nutshell, the new X2C module is powerful & can work as S2 or the old S1 module.

Watch this support video :



In the previous post we’ve seen how to program ESP8266 using Arduino IDE by installing the Boards Manager.

This post is on using the powerful ESP8266 WiFi Library which is automatically installed while using the Boards Manager.When you proceed with the  board package for the ESP8266,as explained in previous post, the ESP8266 WiFi library is automatically installed for you.

Now, any time you want to use the classes and the functions from that ESP8266 WiFi library,  use the Include statement at the top of the program first, followed by the header name

#include <ESP8266WiFi.h>

at the starting of Arduino code & start using the Classes associated with this library.

ESP8266 WiFi library is designed after the the standard Arduino WiFi library but has even more functionality than the standard Arduino library .The standard Arduino WiFi library is used for the WiFi shield or with the Arduino boards like YUN with inbuilt WiFi.

With the introduction of ESP8266 , the WiFi functionality has become much cheaper & easy to use.

The WiFi library has many classes that you can use. Each class has functions in it that are specific to that class. There’s the WiFi class, the IP address class, the server class, the client class and the UDP class.




In this post we’re going to explore the WiFi class & its functions.

The WiFi class allows to establish a connection with an access point.

What’s cool about the WiFi class is that we don’t  have to create an instance of this class. We can  go ahead and start using it. It’s like the serial library of Arduino. We don’t need to create an instance of the serial library.



First Function of the library is WiFi.begin().

The usage of this function is similar to our Serial.begin().

Just like Serial.begin() , we use WiFi.begin() .WiFi.begin() requires 2 strings as arguments. You need to pass the SSID and the password of the Access point you wish to connect.You need to pass the arguments as character arrays or strings with a lower case s.


The possible return values are

WL_CONNECTED      after successful connection is established with the Access Point

WL_IDLE_STATUS       when Wi-Fi is in process of changing between statuses

WL_NO_SSID_AVAIL     in case configured SSID cannot be reached

WL_CONNECT_FAILED  if password is incorrect

WL_DISCONNECTED        if module is not configured in station mode


The status function in the WiFi class, doesn’t take any arguments but it returns stuff depending on the status of the network that you’re connected to.

Usually, first, you call WiFi.begin, you pass the SSID and the password because you’re trying to establish a connection with the network. Then, what you do is you wait in a loop until WiFi.status returns the value WL_CONNECTED.



while (WiFi.status() != WL_CONNECTED)








WiFi.SSID doesn’t take any arguments but it returns the name of the SSID that you’re connected to.



Returns the current signal strength in  dB



Returns the number of discovered networks.It will not list the network names , but returns the number of networks.


Returns the MAC address of the ESP device

There is a specific function available to print out key Wi-Fi diagnostic information:


Here is a sample sketch to demonstrate the WiFi library.


#include <ESP8266WiFi.h>

void setup()

//disconnect any previous connections

//scan for number of nearby networks & print SSIDs

Serial.print(“Nearby networks found  :”);

Serial.println(“List of surrounding Network SSIDs…:”);
int n = WiFi.scanNetworks();
for (int i = 0; i < n; i++)

//connect to preferred SSID

WiFi.begin(“SARAVANA-ACT”, “mypass123”);

while (WiFi.status() != WL_CONNECTED)

// print SSID name,local IP allotted ,MAC address & signal strength

Serial.print(“Connected to SSID          : “);

Serial.print(“IP address allotted to ESP : “);

Serial.print(“MAC Address of ESP         : “);

Serial.print(“Signal strength is         : “);


void loop()


The screenshot shows the result in the serial monitor of Arduino IDE



The Client & Server classes & their methods are shown in screen shots below :





Here is the complete tutorial link for the WiFi library :

cooltext753793315   cooltext753790696

The ESP8266 by itself hosts a 32 bit Microcontroller on it & you can now program your ESP using Arduino IDE. Best part is that NO Arduino board is required.You can upload your code from Arduino IDE , as if you were upgrading the Firmware on ESP.

You can pretty much write any code  for an Arduino and run it on the ESP8266. Of course there is a limit to the I/O on some of the modules, but the Flash on the ESP-12E (Black) module is 4MB and the RAM is 80kB! Add to that the 80MHz 32-bit processor and you have a pretty impressive little cute Arduino.

A sample Blink example program on the ESP8266 turns out to be around 225kB, but that includes the core code.So it’s advisable to use an ESP8266 with more FLASH Memory.Generally the BLACK ones are with higher memory than the Blue ones.The new ESP12E has a Flash of whooping 4MB !!  The Arduino UNO has just 32k Flash & Mega 256k.





Program uploading is done at 115,200 Baud, the default for the module. But It still takes a while to upload a sketch to the module , unlike a regular Arduino.

To begin, you must install the ESP8266 board files in the Arduino IDE.

That is easy enough to do. Make sure that your Arduino IDE is latest

Open the Arduino preferences from File  —> Preferences

Image 1


Add the following URL to the “Additional Boards Manager URLs” seen at the bottom of Preferences Window

Image 2


Click OK to close the Preferences Window.


Image 4

When the Boards Manager opens, scroll to the bottom. You should see the esp8266 entry.

Select the latest version & then click on INSTALL button.


It takes a while to download & install .


Image 6

Once installation is over , close the IDE & start again,

Under Tools –> Boards you can now see a new list of ESP8266 Modules.

Image 7

Its time to test some example code.

While using the ESP module make sure that

Power source is 3.3v DC

CH_PD & RESET pins pulled HIGH through resistor.

You can use a development board available at


An LED is connected to GPIO4 through a resistor.

Image 22

An USB-TTL board is used to connect ESP with USB port of PC.

Rx of USB-TTL board goes to Tx of ESP board

Tx of USB-TTL goes to Rx (3.3v level) of ESP board

GND is made common.

5v of USB-TTL is connected to Vcc of ESP board.As the ESP board has a built in 3.3v regulator we can connect to 5v safely.

Connect the GPIO0 pin to GND.



Open the Arduino IDE & select the COM port allotted to the USB-TTL board.

Other settings are done under Tools tab as seen in screenshot below :


From File —> Examples —> ESP8266 select the BLINK sketch.

As we’ve connected an LED at GPIO4 pin , change the pinMode & digitalWrite pin to 4.

Ensure that GPIO0 is connected to GND & click on UPLOAD button.

It takes a while to compile & then uploading starts.


Once the Uploading is done the LED connected at pin 4 , starts blinking.

Remember to upload another sketch, you need to ground GPIO0 and push the reset switch. The ESP8266 will be put in UPLOAD mode.

When the upload is done, the sketch will start running. If you reset with GPIO0 still grounded, the sketch will not start running because the ESP8266 will be in PROGRAMMING mode. To exit programming mode, remove the ground from GPIO0.




In the next post we shall see how to use the built in WIFI library in your code.

cooltext753793315   cooltext753790696