Friday, October 27, 2017

Remote SOund Navigation And Ranging(SONAR) Application with Raspberry Pi 2 in the Local Network Area(LAN)

Hello everybody, today I am here with another post. I will construct a remote SONAR application using Raspberry Pi 2, servo motor and HC-SR04 ultrasonic range sensor. In order to understand this post better, please check the previous posts that I have already written.

1 - Controlling Servo Motor using Raspberry Pi, Python (RPi.GPIO) software based Pulse Width Modulation(PWM)
2 - Using HC-SR04 Ultrasonic Range Sensor with Raspberry Pi 2

What do we need?

1 - Raspberry Pi 2
2 - HC-SR04 Ultrasonic Range Sensor
3 - Micro Servo Motor
4 - 1x1kΩ and 1x2.2kΩ Resistors
5 - Bread Board
6 - Jumper Male to Female Wires
7 - Laptop(for remote communication)

We need all the components above. But, if you want to display the results on Raspberry Pi locally, then you don't need a Laptop. However, here I will use Laptop. Because, Raspberry Pi is a small board which is used for remote applications generally.

Here is the technical description.

1 - My laptop's config(It will be the client machine):

- IP Adress:192.168.1.106
- Communication port is 9000
- Operating System: Windows 10
- This will be the client machine

2 - My Raspberry Pi's config(It will be the server machine):

- IP Adress:192.168.1.108
- Communication port is 9000
- Operating System: Raspbian Jessie Lite
- This will be the server machine

Thursday, October 26, 2017

Using HC-SR04 Ultrasonic Range Sensor with Raspberry Pi 2

The HC-SR04 ultrasonic range finder is a sensor that provides 2cm to 400cm of non-contact measurement functionality with a ranging accuracy that can reach up to 3mm. Each HC-SR04 module includes an ultrasonic transmitter, a receiver and a control circuit. It is very cheap and simple to use, however the signal output needs to be converted from 5V to 3.3V so as not to damage the Raspberry Pi. I will introduce some Physics along with Electronics in this tutorial in order to explain each step. But first, we should have the following components:

1 - Raspberry Pi 2 Model B
2 - HC-SR04 Ultrasonic Range Sensor
3 - 1x1kΩ and 1x2.2kΩ Resistors
4 - Bread Board
5 - Jumper Male to Female Wires

Ultrasonic Range Sensors and How do they works?

There are two types of ultrasonic range sensors: active and passive. An active sensors set sends out sound pulses called pings, then receives the returning sound echo. Passive sensors sets receive sound echoes without transmitting their own sound signals.

How HC-SR04 ultrasonic range sensor works? It is an active sensor and basically, it creates a pulse of sound, often called a "ping", and then listens for reflections (echo) of the pulse. If you check the following images. You will understand the concept better.


Sunday, October 22, 2017

Controlling Servo Motor using Raspberry Pi, Python (RPi.GPIO) software based Pulse Width Modulation(PWM)

Hello everybody. Today I am going to talk about controlling servo motors using Raspberry Pi. A servo motor is a rotary or linear actuator that allows for precise control of angular or linear position, velocity and acceleration. This project uses Python script, which uses RPi.GPIO library, run on a Raspberry Pi micro controller to send General-purpose input/output(GPIO) Pulse Width Modulation(PWM) outputs to a servo motor to set its angle. However, it is not an easy task since PWM period cannot be defined by the user. It is servo motor and manufacturer-specific.

For this project, I used the following items:

1 - Raspberry Pi 2 Model B
2 - Micro Servo Motor
3 - Jumper Male to Female Wires

The Raspberry Pi 2 has 40 pins and you can see the explanation of each pins below. The servo motor has three terminals. We need to connect these 3 terminals to the proper pins of Raspberry Pi.

1 - Position signal(PWM Pulses)
2 - Vcc (From Power Supply)
3 - Ground

Saturday, October 21, 2017

Live Video Streaming from Raspberry Pi using MJPG-Streamer and HTML5 in the Local Network Area(LAN)

Hello there! After Remote Connection to MySQL Database in the Local Network Area(LAN) post, I am here with another fancy topic which makes live stream over HTTP. There are many ways to do this. But after a quick search, I have found the one that leads to minimal latency and works really well over a WIFI connection. The solution is the combination of MJPG-Streamer on the Raspberry Pi and HTML5 client website on the other computer.

Here is the technical description.

1 - My laptop's config:

- IP Adress:192.168.1.106
- Operating System: Windows 10
- HTML5 client website will be implemented in this computer.

2 - My Raspberry Pi's config:

- IP Adress:192.168.1.108
- Operating System: Raspbian Jessie Lite
- MJPG-Streamer program will be installed here and it will stream live video.

Both are on a wireless LAN connected through a TP-LINK router(192.168.1.1).

One by one we need to do following steps:

Friday, October 20, 2017

Remote Connection to MySQL Database in the Local Network Area(LAN)

Hello there! It has been long time to not write any post in the blog. I do not want to say that I did not have any time, inspiration or something. I had time, really good ideas but somehow I was too lazy to write them down to the blog. But, today I wanted to break this laziness. Anyway, from the title most probably you got what I want to do. But, basically I will explain it again.

I have a private wireless LAN at home as everybody and two device is connected to this network.

Here is the technical description.

1 - My laptop's config(It will be the server machine):

- IP Adress:192.168.1.106
- MySQL Server 5.7 on port 3306
- Operating System: Windows 10
- The database is in this machine

2 - My Raspberry Pi's config(It will be the client machine):

- IP Adress:192.168.1.108
- MySQL Server 5.7 on port 3306
- Operating System: Raspbian Jessie Lite
- This machine will connect to my laptop

Both are on a wireless LAN connected through a TP-LINK router(192.168.1.1).

So the big question is that how can I configure the devices to connect to the database and execute queries?