Sensors
In this section we are going to introduce all the sensors the Blue Seal Robot is equipped with.
Raspberry Pi camera module
The camera module is the main add-on to the Raspberry Pi computer. It can be used to make high-definition video (up to 1080x720 with 30 fps) or to capture pictures. The main advantage of the camera module are its hight quality recording and easy usage for a low price. There are two types of camera modules
- - standard camera module
- - NoIR camera module - without infrared filter
The classical camera module makes a nice true-colored pictures whereas the NoIR colors are gloomy. Nevertheless, as a trade-off for the dark colors the NoIR camera can make pictures and videos at bad light and even in dark with infrared lighting.
You can find here how to setup the camera module with your Raspberry Pi.
Gyroscope+Accelerometer module MPU-6050
The module MPU-6050 is an amazing thing incorporating a 3-axis gyroscope and a 3-axes accelerometer. It communicates via the I²C bus, which allows you to connect up to 128 devices with only two cables.
The I²C bus makes it really easy to connect the module to our Raspberry Pi. Basically, you just interconnect the right GPIO pins on the Raspberry Pi (denoted as SLC and SDA) with the correct pins on the module (SLC and SDA), you also plug-in the supply voltage 3.3V (VCC) and ground(GND) and you are done. You can either connect the VCC and GND pin with the pins on the Raspberry Pi or use the right.
Be careful, since the location of SLC, SDA, VCC or GND may be different for different revisions of the Raspberry Pi computer. Always check the layout of your Raspberry Pi before you start connecting devices to its GPIO pins to prevent damaging the Raspberry Pi itself or the devices!
An example of the GPIO layout for the revision 1 and 2 can be found here.
We should mention that the MPU-6050 can also act as a master and further device can be connected to its additional I²C bus. This feature is very handy if you want to connect an electronic compass in order to be able to measure the absolute orientation of our robot in the space(for now, we omit this possibility in the Blue Seal Robot).
The datasheet for the MPU-6050 can be found here.
There are already many great tutorials on the Internet about the Raspberry Pi and the MPU-6050, so I will just reffer to them without repeating the informations provided there:
- Interfacing the Raspberry Pi and the MPU-6050
- Reading data from the MPU-6050 on the Raspberry Pi
- Using a complementary filter to combine Accelerometer and Gyroscopic data - here we can learn how to get clear and precise orientation angles by combining data from both the sensors
All the basic information how to use MPU-6050 with the Raspberry Pi are provided in the tutorials and a simple program obtaining the actual orientation of the sensor can be easily written by using their help.
Nevertheless, a problem occurs when we want to run this program simultaneously with an other program(e.g., the main program controlling the robot) and share the sensor data between these two programs. How to do this, we will learn in the section 3.
Ultrasonic sensor HC-SR04
The ultrasonic sensor HC-SR04 a perfect and easy-to-implement way how to determine distance from a robot to obstacles. It is designed to work perfectly with the Arduino boards. Nevertheless, it can be use with the Raspberry Pi as well with some more-or-less important drawbacks.
One of the discrepancies is that the sensor operates at 5V. This means that we need to supply the sensor with this voltage and translate its logical one voltage to the logical one voltage of the Raspberry Pi.
The other, but a far more important drawback, is the precision of the sensor, which is strongly dependent on capability of the computer board to process data in the real-time. To be honest, this is not a good feature of a Linux operated computer as a Raspberry Pi and our measurement will be influenced. Let us hope that the inaccuracy wont prohibit us from using the sensor at least for a rough navigation.
The datasheet for the sensor can be found here.
The ultrasonic sensor is easy to use with Arduino (see the tutorial on arduinobasics), but non-trivial to use with the Raspberry Pi, where the main problem is given by different voltages at GPIO ports of Arduino(5V) and Raspberry Pi(3.3V).
This problem can be overcome by constructing a simple voltage divider.
Summary
We have introduced the sensors used in the Blue Seal Robot. The question how to operate them from Raspberry Pi with Python will be answered in section 3.
Share this page with friends via