Tuesday, December 13, 2016

Show Temperature on 16x2 LCD with LM35 and Arduino

Good evening everyone so in my Arduino series last two posts were about temperature reading, displaying it on Serial monitor and using a 16x2 LCD display. Now allow me to merge them together to show the temperature reading in that display.

Parts Needed:

1. Any Arduino board ( And yes I'm using the UNO);
2. USB Type A to Type B cable to connect to computer and upload the code.
3. 16x2 LCD Display.
4. Male to Male Jumper Wire.
5. Practice Board.
6. 220ohm Resistor.
7. 10kohm Variable Resistor.
8. LM35.
9. Arduino IDE.


Let's start with the display.

Pin 1 - Ground.
Pin 2 - +5V.

Pin 3 - Connect to the Wiper Terminal of the variable resistor. Variable resistor needs both Ground and +5V on it's other two terminal. This resistor is used as contrast control.

Pin 4 - Register select, connect this to Arduino pin 12.

Pin 5 - Read or Write pin. Connect it to the Ground to enable Write mode.

Pin 6 - LCD Enable Pin, connect it to the Arduino pin 11.

Pin 11 - D4 to Arduino pin 5.

Pin 12 - D5 to Arduino pin 4.

Pin 13 - D6 to Arduino pin 3.

Pin 14 - D8 to Arduino pin 2.

Pin 15 - LED+ to 5V/3.3V with a series resistor maybe a 220ohm one. I'm using a 1K one though.
Pin 16 - LED- to Ground. 

Now let's hook up the Temperature sensor.

Pin 1 - +5V
Pin 3 - GND

Pin 2 - Arduino Analog input pin 5.

That's pretty much the connection that we need.

The Code:

Here is the code with necessary explanations.

// Let's start with including the LCD Library.

#include  <LiquidCrystal.h>

// Define the Input pin for LM35, in this case it is A5.
int  tempPin  =  5     ;

// Declare variable
int  value;

// Initialize the library with the numbers of the interface pins.
LiquidCrystal  lcd    (12, 11, 5, 4, 3, 2);

void  setup()

  // Sets the data rate in bits per second (baud) for serial data transmission.

  // Set up the LCD's number of columns and rows.
  lcd.begin(16, 2);

  // Print a message to the LCD.
  lcd.print("Temperature: ");


void  loop()

{ // taking in the value from input pin.
  value = analogRead(tempPin);

  // convert the voltage information, as LM35 is already calibrated in celcius to get the celcius output not much code is needed.
  float mv = ( value / 1023.0) * 5000;
  float cel = mv / 10;

  // convert the celcius value to farenhite, uncomment this and print it to get the fahrenheit result.
  //float farh = (cel * 9) / 5 + 32;

  // Serial Print will print value to serial monitor.
  Serial.print("Temperature = ");

  // Let's give it a vertical shift so it will be on the bottom line.
  lcd.setCursor(0, 1);

  // Print a message on the bottom line.
  lcd.print(" *C") ;

  //Start again after 300ms.


So how does it work?

Well I have separately written how the display and the temperature monitoring works so I will just put links to those post at the bottom of this post where you can find details on them.

Let's look at the completed project.

Here you can see the display, Arduino and the LM35. The reason there is no variable resistor is because I don't need to control the contrast in this one. So I just left it out.


Temperature sensor can be really helpful and putting it on a display can be even more helpful. It not only can be used as a visual modification for your project but can be used in many different projects where it is necessary to show the temperature. You can also control other devices using temperature as the trigger point. One thing you can do is to make something like the following image and cover the wires with heat shrink material and can be used as a temperature probe to lower it in a liquid or reach in a place where it wouldn't be practical to put the practice board in.

In Here I'm Just using three Male to Female jumper wire, the one that is used with Raspberry Pi.

So that's pretty much it, hope this has been helpful.


1. Temperature monitor using LM35.
2. Using 16x2 display with Arduino.
3. Read my other posts here.

Monday, December 12, 2016

Temperature Monitor Using Arduino and LM35

Good evening. This is the continuation of the Arduino series and this particular one is about how to make a simple temperature monitor using the LM35 precision temperature sensor.

This will a very small project as the part it needs is the LM35. Reason behind that is this small chip is already calibrated in centigrade so it is just as simple as reading it's output value, do a small conversion and show it on display or use it in somewhere. LM35 is a linear temperature sensor and it's output voltage is proportional to the temperature. It's output is 10mV/Degree Centigrade. So if you rise temperature by 1 Degree Centigrade, output will increase by 10mV. So all you have to do is read that through Analog input pin of your Arduino and done. There are couple different positive things about using this. It has wide voltage range, it is a very small device so it is suitable for pretty much any application where temperature reading is needed.

So let's go over the parts list:

1. Arduino, again for basic projects like this I use UNO.
2. LM35.
3. USB A to B cable and Jumper Wires.
4. Arduino IDE on computer
5. Practice Board.

Procedure and Connections:

As there will be no other parts other than the LM35, the connection is pretty simple. LM35 has three pins. Pin1 takes in positive voltage which can be anything from 4V to 30V and Pin3 is the ground pin. I have just powered it directly from the Arduino 5V and GND pin.

Pin2 is the output pin of LM35 which needs to be connected to any of the analog input pins of the Arduino. You might have to change the code if you use anything other than 5 because that's what I'm using.

After connecting upload the code provided, code has all the necessary explanation and how you can modify it. Then open up the serial monitor to see the temperature reading.

The Code:

// declare variables.

int value;
int tempPin = 5;

void setup()
void loop()
  // taking in the value from input pin.
  value = analogRead(tempPin);

  // convert the voltage information, as LM35 is already calibrated in celcius to get the celcius output not much code is needed.
  float mv = ( value / 1023.0) * 5000;
  float cel = mv / 10;

  // convert the celcius value to farenhite
  float farh = (cel * 9) / 5 + 32;

  Serial.print("Temperature = ");

  /* uncomment this and comment the previous 5 lines to get temperature in farenhite
    Serial.print("Temperature = ");


Here is the project:

How does it work? 

I have talked about LM35 earlier on this post, so you get the idea of what happens with different temperature, it gives different output voltage which is analog. Hence we put that in the analog input of Arduino. Now we have to convert it to digital in a way that it represents the proper temperature value.


 You can check for the accuracy using a source with known temperature.


This one might be a very simple project but you can use it in many different things like battery over temperature protection or any kind of over temperature protection. It can also be used to control devices based on temperature. 

Hope you have enjoyed it.


Sunday, October 30, 2016

Easy Chat Program using Arduino.

Good evening everyone. So in this day of age anyone who is interested in electronics or keep an eyes on technological news Arduino should be a very common word for them and rightly so because it has made designing and implementing circuits so simple that even amateur people can actually make awesome things this days. Arduino has pretty much gave everyone the power to make something which was previously kinda on the hands of people who knows about how things work. Anyway you can already guess this post will be something using Arduino and it is a simple chat program.

So what this will allow us to do is just send and receive simple text from a computer. Yes I understand there are much better options out there but this one will help you to get familiarized with Arduino and show you how easy it is to get things done.

Parts needed: 

1. A pair of Arduino. I'm using the ever popular and cheap Arduino UNO.
2. A pair of USB Type A to Type B cables to connect Arduino with computers.
3. Two Male to Male jumper wire or similar cable to connect the Arduinos.
4. Arduino IDE on computers.


1. In this particular example I'm using the Arduino pins 7 and 8 but you can use any pin you want all you have to do is to change the code accordingly. I have used 7 and 8 because they are easy to find. Just connect pin 7 of one Arduino to pin 8 of the other. So there will be two wires connecting both the Arduinos.

2. Make sure the IDE is installed on your computer, it can be downloaded from their website for free.

3. Connect the Arduino via USB port and upload the Code found in the Direct Chat Code file, link will be on the bottom of this post. You need to put the exact same code in both of them. Make sure to select the correct COM port before uploading.

4. Now open up serial monitor and you can start chatting.

The Code:

/* Simple Chat Program

 Receives from the hardware serial, sends to hardware & software serial.
 Receives from software serial, sends to hardware serial.

 The circuit setup:
 * RX is digital pin 10 (connect to TX of other device)
 * TX is digital pin 11 (connect to RX of other device)

 Created and modified by Redwan Hasan based of software serial example.
#include <SoftwareSerial.h>

SoftwareSerial chat(10, 11); // Define RX, TX

int text;

void setup() 
  // open hardware serial, TX = 1, RX = 0
  Serial.println("Welcome to the chat program...");
  // set the data rate for the SoftwareSerial port

  // delay 1s to stabilize serial ports

  chat.println("Your Friend is online");

void loop()
  if (chat.available())
  if (Serial.available())
    while (Serial.available())
      text = Serial.read();

Here is the project.

Working Circuit for this project

So how does it work?

The basic idea is very simple here, the pin 7 is the RX pin and 8 is the TX pin. The way we have connected them is from TX to RX and RX to TX. What's gonna happen is this, what one is transmitting other will simply receive it and put it on display and as the path is bi-directional anyone can send and receive.


Here it is, a bi-directional conversation can be done here. I have used one a single computer to connect both the Arduinos but you can use two computers and essentially chat with someone else.

Hope it has helped.


1. Arduino webpage.
2. Read my other posts.

Tuesday, September 20, 2016

Fleming's Both Hands Rule!

Good afternoon everyone, so I think today is a good day to write about something kind of confusing which is Fleming's Left hand rule and his right hand rule. These rules are just mnemonic or you can call them memory technique to remember the directions of current, magnetic field and motion in both motor and generator.

So first things first remember this;

1. Fleming's Left-hand rule is used for electric motors.
2. Fleming's right-hand rule is used for electric generators.

Now let's talk about how to apply these rules, starting with left-hand or the motor hand.

As we are talking about motor the current and the magnetic field will be given but the force direction will be unknown. If a current carrying wire is subjected to a magnetic field in a perpendicular fashion then the wire will feel a force which is perpendicular to both the direction of current and magnetic field. So we are talking about 3 axis here, if you set say the field and current to x and y axis respectively then the motion will be in z axis. Things are a bit complicated without any visual representation.

Here is a left hand diagram where

Thumb or F is the force vector or the thrust on the conductor or motion of it. 
Fore finger or B represents the direction of magnetic field or flux density.
Second finger or I represents the direction of current.

Let's move on to the right hand rule now.

For generators however the motion and the field is given we need to know the direction of current. So thing is if we subject a moving conductor in a magnetic field we will get current which is both perpendicular to the two applied causes. Again let's look at a visual representation.

In here

The thumb is the motion of the conductors.
Fore finger is the magnetic field.
Second finger is the direction of current.

So that's a brief description of Fleming's left and right hand rules.

For more info visit the wiki links.

Left hand.
Right hand.

You can also read my other posts here.

Index to my blog.

Monday, September 5, 2016

Raspberry Pi Starter Kit

Good evening everyone. Hope you guys are doing great. So currently single board computers are very popular and getting more more and more popular day by day. Truth to be told there are huge amount of legitimate reasons behind their popularity. If you are however new to all these then this post might help you out. In this specific post I will be focusing on Raspberry Pi and I will go into the reason why in a few moments.

Like I was saying if you are new to this whole single board computer thing I would say start with Raspberry Pi as it has been here for quite a long time so you will get more support. Now let's take a look at what you are going to need to properly work with Raspberry Pi in many different scenarios. So couple things are common for all scenarios, let's start with them.

1. You will obviously need a Raspberry Pi, as for September 2016  I would suggest getting either a Pi 2 or Pi 3.

Raspberry Pi 3

Raspberry Pi 2
Let me give you a bit more info on this single board computers. Both of them are ARM based and have a lot of similarities but the newer one has couple more tricks up its sleeve.

System on Chip:

RPi2: BCM2836 Quad Core ARM Cortex-A7 900MHz with VideoCore IV 250MHz
RPi3: BCM2837 Quad Core ARM Cortex-A53 1200MHz with VideoCore IV 300MHz

Audio and Video Output:

HDMI supports 1080p video with audio.
3.5mm TRRS jack for Stereo Audio and Composite Video.


RPi2:  10/100Mbps Ethernet Port via an USB to Ethernet Adapter on-board.
           4 USB 2.0 Port.
           1 HDMI, 1 3.5mm TRRS Jack.
           40GPIO Pins,
           Camera Interface(CSI)
           Display Interface(DSI)
           MicroSD Card Slot for Loading Operating system.
RPi3:  10/100Mbps Ethernet Port via an USB to Ethernet Adapter on-board
           Bluetooth 4.1Classic, Bluetooth LE, Wi-Fi 2.4GHz 802.11n Standard.
           4 USB 2.0 Port.
           1 HDMI, 1 3.5mm TRRS Jack.
           40GPIO Pins,
           Camera Interface(CSI)
           Display Interface(DSI)
           MicroSD Card Slot for Loading Operating system.

5V 2A(Recommended) via Micro USB.

So the major difference here is the Improvement on the CPU side as frequency is bumped from 900MHz to 1200MHz and also the GPU sees a little improvement. The big advantage here is the fact that Raspberry Pi 3 comes with Wi-Fi and Bluetooth. Next thing we need is microSD card to load operating system.

2. MicroSD cards.

As they are inexpensive I would suggest you to buy about 4 of them, 16GB of capacity and Class 10 in speed specification. That way you can keep one or two stable operating system ready in hand to use and maybe one or two more for experimenting.

3. A good power adapter.

To power up the device properly a good quality power supply is needed with a good micro USB cable. Personally I use phone chargers and they work just fine. I would suggest getting at-least 2A one but if you plan on using portable Hard drive or something I would recommend getting a 3A one. (Although keep in mind that the combined current output of all four ports are 1.2A)

4. Ethernet cable or Wi-Fi dongle:

Depending on which method you use, you might need an Ethernet cable, a CAT5e would be enough or you can opt for a USB Wi-Fi dongle for RPi2 but for the RPi3 it has built in Wi-Fi. If you are plan on using network attached storage however I would recommend using the Ethernet port as it will provide more consistent speed and better latency.

5. HDMI Cable and 3.5mm splitter:

For connecting with TV or monitor I would recommend using HDMI as it is better and easier to configure as oppose to the composite output, however if you still want to use that you can use another 4 pole to two 3 pole converter. The one that will work with Android or apple devices will also work here to. What it will do is just take in the A/V signal and give out separate stereo audio and composite video. In case of using the same jack with laptop's combo port or phone you will get stereo audio out and microphone in. Don't fall for the HDMI cable money trap though, 5$ one worked exactly like a 50$ one.

6. USB flash drive.

If you are plan on using NAS or Media Center or maybe RetroPi gaming setup, you might need this. Don't bother with USB3.0 however because ports on Raspberry Pi2/3 are of USB2.0 standard.

7. An analog game controller.

If you plan on using RetroPi this is a must for you. You can get either the wired one or wireless one.

8. (under construction)

Tuesday, August 30, 2016

Setting up DHCP address reservation

Good afternoon everyone, in this brief post I will talk about how you can enable DHCP address reservation on your router. For demonstration purpose I'm using a TP-Link router which is very common but any other brand of router should have the similar option too.

Before getting into how to do it let's discuss DHCP. It stands for Dynamic Host Configuration Protocol and as it's name suggests it is an network protocol used on Internet network protocol. This protocol is controlled by a DHCP server to dynamically distributes network parameters such as IP addresses. So it drastically reduce the workload for the network engineer who is in charge with deploying a network. If DHCP wasn't available network engineer or the person who is setting up the network has to manually assign IP addresses to all the devices but with DHCP the server itself assigns IP addresses to devices automatically. Connect a new device and it will get a new IP automatically, you don't have to do anything. If you think about depleting IP addresses then lease time will help you with that. Unused IP addresses will be re-cycled via this. DHCP server leases IP for certain set period of time, if after that time the device no longer needs the IP it will be assigned to some other device. So it's all well and good right then where is the point of reserving certain IP?

Here is the thing, if you are running a network attached storage or IP TV or media center then DHCP might not be ideal as it will change the IP address over time. Say if you configure your phone to get certain data from certain IP, if that IP changes it will no longer get that data, you will have to enter the new IP. Now if you completely turn off DHCP then again you have to manually set all the IP addresses for different devices. Hence DHCP address reservation. In this method what is done is simply reserve certain IP address to certain MAC address or device address so that that IP won't be given to anyone. This ensures that certain devices will always get certain IP addresses. For example I always reserve IP address for my Raspberry Pi so that I can easily SSH into them. Let's look at the procedure then.


1. Get into the router via the web based interface, for different router it might be different for example
Tp-link can be accessed with or tplinklogin.net
SMC can be accessed with

After that login with the username and password, it should be written under the router or on the box if you haven't changed it yet.

2. After getting into the router you will be greeted with this page where you should find something like DHCP. We need to get into that too

3. Now getting into DHCP we will find the options for turning it on or off. Default it should be enabled and we want to keep it that way.

4. Next we need to go to the DHCP Client list to get the MAC address for our client. If you can't determine the device from the client name, for example it is very tough to determine android devices so in that case you might want to gather the IP address or MAC address from the device itself. Keep that MAC address in mind to assign the IP address that you want to assign. Remember the lease time I was talking about? Look carefully and you will see some devices have their IP address with lease time, after the expiration either those IP addresses will be renewed or given to some other device if needed. Those with the Permanent lease time are reserved.

5. Now let's move on to the final part the Address reservation, in here you will see any existing one that is already configured or you can add/modify/delete any entry.

6. As I already have couple devices configured to have same IP address all the time those devices are already listed here. If you are doing it for the first time you will see an empty table. To add a new entry you simply click Add new and put in the MAC address and IP address and done. You might want to restart the router afterwards.

So that's how easy it is got enable DHCP address reservation and saves a lot of time finding IP addresses of devices. Now for an example I will always reach my Raspberry Pi 2 at

Hope it has helped.

Read my other posts here.

Friday, August 26, 2016

Learn English - Euphemisms

Good morning everyone and in this particular post I will talk about Euphemism and it's usage with couple examples.

So what is Euphemism? 

To simply put it is something to replace certain harsh or offensive words with something mild or less unpleasant. So basically it substitutes harsh, offensive, direct words or words that has negative stigma attached to it to something softer in order to avoid offending people or over inflate the importance of some words. It can be a word or two or an expression. Honestly I'm not a big fan Euphemisms, I like to call things whatever it is in most cases but in this day and age it is very easy to offend people, so it is better to learn about an alternate way of expressing your mind. Hopefully this hasn't offended anyone yet. To me personally it is not about showing disrespect or something because I think someone can be disrespectful inside even if they use a milder word but someone can be respectful and yet call spade a spade. Now Let's take a look at couple examples that are very common.



Death, instead of blatantly saying someone has died we can use something different like

Passed away,
Meet someone's maker,
Six feet under,
Didn't make it,
Negative patient outcome etc.


Toilet, many people feels shy using this word so they use something else like

Little boy's room,
Rest room,
Wash room,
Lady's room,
Go and see a man about a dog,
Powder your nose,
Spend a penny etc.


Unemployed, it is a bit harsh to say someone is unemployed so we can use

Laid off,
Between jobs etc.


Handicapped or Disabled, again rude to use such terms and about the word disabled they are really not disabled so it is better to use something like this

Mentally challenged,
Physically challenged,
Differently-able etc. 


Fat, again some people consider this word to be rude so the following words can be used instead

Full figured,
A few extra pounds,
Let himself go,
Big boned,
Chubby etc.


Stolen(or cheap product), often times we can buy very cheap products from something like a black market that we know might have been stolen, we don't say stolen we say the following words,

Fell off the back of a truck,
Get off the truck etc.


Used, in car dealership using the term used kind of decreases the value of the good so they instead use

Previously enjoyed.


Getting pregnant, some people feel shy to admit it or say anything about it so they use different terms like

Bun in the oven,
Knocked up(some people actually consider this to be even more negative).


Jail, it is not pleasant to say someone is in the jail rather the following term is used.

Correctional facility.


Genocide, I don't have any problem with this word rather I would say it is better to use this because softening it might undermine the severity of what happened. We know examples of genocide like Armenian Genocide of First World War, Jewish genocide on Second World War, Genocide on Bangladeshi people on 1971 etc. and these were really severe so again I don't see any point of using anything else but people use the term

Ethnic cleansing.


Prostitution might sound taboo and people use

Turn a trick.


Accidental death, which often times happen specially during war time or invasion time like now and lot of time civilian casualty happens and rather than using accidental death media or government  usually uses

Collateral damage.


To fire someone might not sound good so instead of saying that we can use

Letting someone go.


Euthanize is to kill someone(usually animal) to lessen their suffering. In a terminal case where the animal usually a pet is going to die anyway and suffering greatly they are instead euthanized and people don't like to call it this so they say

Put to sleep,
Pull the plug.


Homeless, instead of saying homeless it is polite to use

On the streets.


Abortion might sound harsh or saddening to some people so they use

Pregnancy termination.


Pornography might offend some people so use

Adult entertainment.


Liquor, wine and beer might offend people too so instead use

Adult beverage.


Prostitute, some people use

Comfort woman although I don't agree with this because this word was used during world war 2 and comfort women were the girls that were forced into sex slavery by Japanese people so not really prostitutes.


Late kinda sounds harsh so use

Chronologically challenged.


To have Sex sounds aggressive to some people so use

Sleep together,
Go all the way.


Short, don't say someone is short which might offend that person instead use

Vertically challenged.


Maid, the person who works at home can be called

Domestic engineer.


Ugly can be derogatory so use

Appearance deficit.


A place where chance of getting mugged is high can be referred to as

Vibrant area of town.


Lazy can be harsh too so use a bit more polite

Couch potato.


Stripper is a person who usually dance or performs naked so use

Exotic dancer.


Elderly, rather than saying it better say

Senior citizen.


Poor also might sound rude so use

Economically challenged.


Unwanted call is kind of a call to or from wrong person and can be said

Courtesy call.

These are some very common one that you might hear regularly so hope this has helped.

Read my other posts here.