Thursday, March 30, 2017

Taking Screenshot in Raspbian

So this will be a very small post about how you can take a screenshot through command line interface in Raspbian operating system.

What Do we Need?

1. Raspberry Pi or any other single board computer that supports Raspbian.
2. Mouse, keyboard and Monitor if you want to use the Raspberry Pi alone.
3. Internet Connection.
4. Raspbian OS.
5. Power supply for the Pi.

Procedure:

1. Like always we will start off with making sure the Raspbian is fully updated. To do so just run the commands.

sudo apt-get update
sudo apt-get upgrade




2. Next we are going to install a small software called Scrot. To do so we have to type.

sudo apt-get install scrot



3. Now to take a screenshot all we have to type is

scrot


 4. You can also use a small timer that will allow you to take the screenshot after certain amount of time. To do so you have to type

scrot -d x
[where x will be a numerical value which is in second]



That's pretty much it! Hope this was helpful.


Resources:

1. My other posts.
2. All Pi related posts.


Tuesday, March 28, 2017

Check Your Internet Speed With Raspberry Pi

Good evening, welcome to another Pi post which is about checking your internet speed with Raspbian on Raspberry Pi. This post will be very brief and just to show how you can check your internet speed without using anything other than the Terminal.

So, what do we need? 

1. Raspberry Pi!
2. Internet Connection to it either via Wired or Wirelessly.
3. Power supply for Raspberry Pi.
4. Working installation of Raspbian on Micro SD card, I'm using the latest release.
5. Monitor, keyboard and mouse if you want to only use the Raspberry Pi.

Note: You can also use another computer to SSH into the Pi or maybe use Virtual Network Computing but if you have a computer where is the point of doing a speed test on Pi although it might be helpful to understand how fast will the Pi download something if used as a Torrent box.

Hardware Connection:

1. Connect Mouse, keyboard and Monitor.
2. Next connect the internet, however you like.
3. Finally plug in the micro USB power cable to power it up.

Procedure:

1. After the boot up, launch the Terminal and make sure to fully update the Pi. To do so type in

sudo apt-get install update
sudo apt-get install upgrade




Once that has accomplished let's move on to the actual installation.

2. Now we need to install the Python-pip which is a package management system used to install and manage software packages written in python. In the terminal type in

sudo apt-get install python-pip


Here I already have the latest version so nothing new installed.

3. Not time to install the speed test part which we will do using the Package Management system.

sudo pip install speedtest-cli 


Again I already have it installed so not much was shown here.

4. Let's do the speed test which will be shown in the Command Line Interface. To do so we have to type in

speedtest-cli




Just to make sure let's compare this with my computer that is also directly connected to the Router via Wired Ethernet just like the Raspberry Pi.




Ping has increased in Pi but speed is consistent. Although my internet is not that fast so it also proves another thing that for slow internet Pi is good enough.

That's pretty much how you can use Pi as your internet speed tester.

More links:

1. Read my other posts here.
2. More Pi related projects.

All About Pi!

Short Index for all Pi Related posts! Hope you will enjoy it.



1. Raspberry Pi Starter Kit. (Coming Soon)
2. Let's talk about operating systems for Raspberry Pi. (coming soon)
3. Virtual Network Computing(VNC) on Raspberry Pi.
4. Raspberry Pi as Network Attached Storage.
5. Turn your Pi into a Torrent Box. (Coming Soon)
6. Internet Speed test using Raspberry Pi.
7. How to take Screen Shot in Raspberry Pi
8. Turn Your Raspberry Pi into a IR Remote Controller. (Coming soon)

Tuesday, February 14, 2017

Musical Doorbell

This post is about making a simple musical doorbell circuit that can be used in your house and might take only couple minutes to build it.

Goal here is pretty simple, it will be a musical doorbell that has a very small power consumption and can play the music for couple moments even after releasing the momentary doorbell switch. For the music we will be using a melody generator integrated circuit to make our work easy and to turn on and keep it on we will be relying on Capacitor and transistors, so let's take a look at the component list.


Component List.

1. Integrated Circuit UM66.
2. Transistor 2N3904, 2N3906, SS9013, one piece each.
3. Capacitor 100uF.
4. Resistor two 1Kohm, and one 10kohm and one 100kohm.
5. Battery holder, two AA type.
6. Speaker 4/8ohm.
7. Momentary press button.


Let's talk about music!

Part number of the UM66 will give us an idea of what music it is going to generate. To find the right music for doorbell buy the one with the right part number.



The diagram!

Now that we know which Integrated circuit to order let's build the circuit.



How does it work? 

Power source for this circuit is two AA size cell, preferably Alkaline. They will provide roughly 3V.

When SW1 or the momentary press button is pressed the 100uF capacitor will be charged and at the same time the 2N3904 transistor will start conducting as it is getting current to it's Base.

As the 2N3904 can now be treated as a close switch we can assume the Base of 2N3906 to be at the ground which will cause the 2N3906 to start conducting.

Now we can see the current can enter into the integrated circuit causing it to turn on. This circuit will output a melody signal which will be amplified using SS9013 transistor which is feeding a loud speaker.

If the momentary switch is released, the 100uF capacitor will discharge through the 10kohm resistor and the 2N3904 transistor. So it will keep the circuit alive for couple moments after releasing the switch. Once it is fully discharged both the transistors will be open again and the integrated circuit will not get any power to stay On.


Note:

1. You can use ZL66 instead of UM66 too.
2. Two AA Alkaline cells will be fine for this doorbell.
3. A normal 1-3W speaker will be fine.
4. Increasing the value of the capacitor will cause the circuit to stay alive longer after the press button is released.
5. Both the 2N3904 and 2N3906 can be replaced by similar NPN and PNP transistor respectively.


Resources:

1. UM66 Datasheet.
2. SS9013 Datasheet.
3. Read my other posts.

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.


Connection:

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.
  Serial.begin(9600);

  // 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 = ");
  Serial.print(cel);
  Serial.print("*C");
  Serial.println();

  // 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(cel);
  lcd.print(" *C") ;

  //Start again after 300ms.
  delay(300);

}


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.


Applications:

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.


Links:

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()
{
  Serial.begin(9600);
}
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 = ");
  Serial.print(cel);
  Serial.print("*C");
  Serial.println();
  delay(1000);

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


  */
}



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.


Result:


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


Applications:

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.


Links:

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.

Procedure:

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.begin(9600);
  Serial.println("Welcome to the chat program...");
 
  // set the data rate for the SoftwareSerial port
  chat.begin(9600);

  // delay 1s to stabilize serial ports
  delay(1000);

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

void loop()
{
  if (chat.available())
    Serial.write(chat.read());
   
  if (Serial.available())
  {
    Serial.print("Me:\t");
    while (Serial.available())
    {
      text = Serial.read();
      chat.write(text);
      Serial.write(text);
    }
    chat.println();
    Serial.println();
  }
}


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.


Result:




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.

Links:

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