Category Archives: Raspberry Pi

Raspberry Pi Rover to Mine Water on Mars

Water is an essential chemical for sustaining any sort of life on the planet Earth. From what knowledge space explorations have provided us so far, this is true for life elsewhere in the universe as well, but there are deviations. Mars being our closest neighboring planet, it is only natural for us to try to locate water there. Additionally, with the human population on our home planet close to its saturation point, it is essential we plan to distribute the excess populace on nearby planets. For this, we need to make sure of the presence of water there or at least, the possibility of generating it simply and easily.

Collaboration between the Gilmour Space Technologies, Australia and the Singapore University of Technology and Design is exploring the Mars Aqua Retrieval System or MARS. This is a prototype for harvesting water from the soil of the Red Planet. The team has built the prospecting rover for less than $10,000. Based on the famous Single Board Computer, the Raspberry Pi and an Arduino unit, the rover uses microwaves to heat up and release the frozen water present in the Martian soil.

Although designed to work on Earth, the proof of the concept takes its basic idea from the discoveries made so far by Curiosity and the Phoenix Mars Lander. These extraordinary rovers have indicated the presence of water on the Red Planet. This water either is in non-liquid forms such as ice or buried in its soil. Engineers have designed the rover MARS to extract water from the Martial soil, collect and store it. With NASA recently declaring the presence of running water on Mars, project MARS has taken on an even greater importance.

Detailed documentation of the project indicates scientists considered various methods for each step of the process. The final concept involved separating and collecting water using microwaves and a cold trap. According to tests conducted by the team, they claim to have collected four grams of water from frozen soil in four minutes.

The process of water collection involves cycles of locating the MARS system using its two powered wheels to move to the target area, lowering a microwave unit over the ground and then heating the area for about 20 minutes. This releases steam from the Red soil and it enters a collection pipe leading to a condenser bag, where the steam condenses into water that finally drips into a collection box. The entire process is similar to distillation in any chemistry laboratory.

Although NASA provided only a meager budget of $10,000, the team has managed to create a prototype that presently functions satisfactorily on Earth. The two SBCs the Arduino and the Raspberry Pi in MARS control the locomotion and timing, the arm movements and the on/off switching of the microwave. The prototype is able to withstand 30% of the pressure and temperature conditions present on Mars.

According to Adam Gilmour, CEO of Gilmour Space, the US space agency has reacted favorably to the details of the MARS design sent to NASA. Although, in its present form, the prototype is unlikely to leave Earth’s atmosphere, MARS will be available for public view at the Gilmour Space Museum, north of Australia’s Gold Coast.

Keep Your Fish Happy with a Raspberry Pi

People who keep fish in aquariums at home know it is important to feed them timely and to keep their habitat clean. Trouble starts when the owner has to leave home for a few days and cannot find a knowledgeable caretaker to take care of the pets. Cabe Atwell tried to solve the problem he faced in an ingenious way – by using the power of the Internet.

Cabe had an automatic fish feeder, but he also enlisted the services of a friend to keep an eye on her goldfish, the friend was not sure of what was required and the automatic fish feeder broke down. Fortunately, the losses were not fatal, but Goldie the goldfish grew to double her size because of overfeeding. This led Cabe to work on a system to allow watching and feeding the pet over the Internet.

Cabe wanted a system that would allow seeing the fish in real time, anytime, by moving a camera around the tank. The next requirement was sensing the tank water temperature and cutting off the power to the tank bubbler and air filters, if necessary. It was also necessary to feed the fish manually, and above all, to do this through a network and ultimately, via the Internet.

Cabe’s research led to the conclusion that a Single Board Computer such as the Raspberry Pi or RBPi and a Pi camera would be most suitable for seeing the fish via the internet. For the other features, an Arduino Uno was more appropriate.

Accordingly, Cabe selected two small Nema 17 mount stepper motors, available on Adafruit, for the driver components. The motor controls came from an Arduino Motor Shield, which made it simpler to drive the motors. Cabe designated one motor for allowing movements in two directions, while the other rotated the food container to dump fish food into the water.

The fish feeder was a modification of the original malfunctioning feeder. It consisted of a drum to hold the fish food. When rotated completely around, a simple trap door opens briefly to let a small amount of feed.

To keep the camera motor traveling too far, Cabe incorporated limit switches in both directions. The limit switches were placed in position using rare-earth magnets, which allowed easy adjustments for the movement range. A surplus belt driven motion platform provided an affordable arrangement for viewing the entire length of the tank.

For sensing the water temperature, a waterproof digital temperature sensor was the most suitable – DS18B20. Although fresh-water fishes are more tolerant of water temperature variations, loss of air-conditioning or heating arrangement can lead to the tank water becoming too hot or cold for the comfort of its occupants.

For the video stream, Cabe settled on VLC since it was easier to use. VLC offered the maximum resolution of 640×480 pixels at 15 frames per second, which Cabe found adequate for keeping a tab on the fish. A simple AC relay took care of feeding power to the air filters and bubbler.

For the future, Cabe wants a better AC control and more sensors for measuring the pH, ammonia and nitrate levels in the water.

Incubating Eggs with a Raspberry Pi

Incubating eggs is a process best left to the mother bird alone or sometimes the father bird. That is because nature has programmed them for applying the appropriate temperature profile necessary to hatch their eggs successfully. However, this vital information is no longer the sole proprietary knowledge of the birds alone. Humans, at least those who rear chicken, probably know as much.

Hens incubate their eggs by sitting on them and instinctively controlling several factors, mainly the temperature and humidity, with their body heat. They also turn the eggs over periodically, which is vital for a successful hatch.

Although there are commercial alternatives available, building your own incubator has its own advantages such as affordability and the ability to add features. Dennis Hejselbak from Denmark has not only made such an incubator, but has also posted complete build instructions here. For those who want to follow, Dennis uses a Raspberry Pi or RBPi, the tiny, versatile single board computer for controlling his incubator. He has made available the necessary Python codes and the wiring schematics as well.

Dennis has built his incubator box from polystyrene, which makes it well insulated. He controls the temperature inside using an incandescent light bulb and an old CPU fan. Wet sponges inside the incubator supply it with the moisture necessary, while a hygrometer keeps an eye on the humidity levels. The RBPi controls the light bulb and the CPU fan based on feedback from a temperature sensor and the hygrometer. Dennis keeps watch on his eggs via a camera attached to the RBPi. He has enabled his RBPi with Wi-Fi and real time pictures of the incubation process are available on his website.

The only process Dennis has not attempted to automate so far is the periodic turning over of the eggs. He does this manually, about three times each day, until the eggs hatch. Although hatching eggs takes about 21 days on average, some eggs may hatch a day or two early and some a day or two late.

As Dennis is using forced air for his incubator, he programs the RBPi to keep the temperature within about 99-99.5°F (37.2-37.5°C). For successful hatching, eggs require 45-50% humidity from day 1 to 18 and 65% for the balance few days. Dennis has placed the temperature and humidity sensors to hang just above the eggs.

As the incubator is a large box, placing the RBPi on its top was not a difficult task for Dennis. This has its advantages as the box needs only a single hole for both the cables of temperature and humidity sensors to pass through – making it easier to insulate. Of course, other holes are necessary for the cable of the light bulb. Dennis handles all monitoring of the RBPi from outside, without having to open the incubator.

The RBPi controls the temperature by turning the light bulb on or off as necessary. A simple electromagnetic relay operated with a power transistor is enough for this purpose, although those who are adventurous among you may opt for a more expensive solid-state relay.

A Primary Display HAT for the Raspberry Pi

A portable single board computer such as the Raspberry Pi or the RBPi ought to have a portable screen, preferably a touch screen that is comfortable to use. This is a long overdue, much sought-after request from users, especially from developers, who see and use several smartphones and tablets with capacitive and or resistive touch screens.

The Pi Foundation has been hard at work on developing a seven-inch touch screen as an add-on to the RBPi. This would be appropriate for a number of projects where you would want to pit the RBPi against a portable tablet or even a laptop. However, for development of embedded systems, people prefer a smaller and more compact version of display. The 2.4-inch TouchScreen display from 4D Systems fills this void perfectly and affordably, being compatible with the RBPi models A+, B+ and RBPi2.

The TouchScreen is almost as large as the RBPi board and covers it as far as the USB and Internet ports, while sitting perfectly on the bank of GPIO pins and covering all of them. At present, the other end of the TouchScreen hangs as there is no support and there is a possibility of its backside touching the connectors. You can expect a set of stand-offs to come soon and these will secure the screen above the connectors and pins of the RBPi.

According to an intentional design decision between 4D Systems and element14, the TouchScreen fits very neatly within the official case of the RBPi. That leaves out only the portable power, which, if the official case could support, would have made the RBPi truly portable.

The 30 gm. TouchScreen module dimensions measure 56.5×65.0x14.2 mm. It has a viewing area of 49.0×36.7 mm, with four mounting holes of 2.6 mm diameter. The QVGA TFT screen has a resolution of 240×320 pixels and sports 65K true to life colors. Integrated with the screen is a 4-wire resistive touch panel. You can display the full GUI output or the primary output on the TouchScreen, just as would a monitor connected to the RBPi. The display uses a PWM control for the backlight and on board, there are three backlight choices, selectable with jumpers – On, Off and PWM.

The display module connects to the RBPi via a high-speed SPI interface working at 46MHz and using SPI compression technology. If you have a kernel that compresses images, expect higher frame rates than the typical value of 17 frames per second. The module does not require a separate power supply as it powers itself directly from the RBPi.

Although the screen has full capabilities, its limitations are because of the way Linux handles framebuffers. For example, although the display can play full motion video, you cannot render OpenGL to the screen. That means you cannot expect hardware acceleration from the SPI screen. Someday, this may be possible if someone tweaks the Broadcom code for the VideoCore and OpenGL.

UPS-PIco for Uninterruptible Power for the Raspberry Pi

The innovative Raspberry Pi or RBPi, the tiny single board computer, has endeared itself to the young and old alike. When used for critical applications, it is often necessary to supply the RBPi with continuous power, for which, an advanced uninterruptible power supply such as the UPS PIco offers several innovative power back up and development features.

With a 300mAh LiPO battery, the standard UPS PIco offers a safe shutdown during a power cut. However, you can easily upgrade this battery to an extended version of 3000 mAh. This will allow you to use the RBPi for a prolonged 8 hours, even if no power supply is available.

An embedded measurement system within the UPS PIco works continuously to check the powering voltage of the RBPi. As soon as it detects the absence or the inadequacy of the cable power of the RBPi, or senses a power failure, the UPS PIco switches over to its battery source automatically. The module continues to check the voltage on the RBPi cable, and if the power is once again available or adequate, it switches over from the battery and allows the regular cable supply to power the RBPi.

You do not need any additional cabling or a separate power supply for charging the battery, as the UPS PIco is a powered unit, with the GPIO pins on the RBPi powering and charging the battery pack intelligently.

The UPS PIco complies with the HAT standards for the RBPi models A+/B+ and 2B. Mechanically, it is compatible with the original models A & B of the RBPi, provided you use an extension header. Additionally, the UPS PIco is compatible with most cases housing the RBPI, especially as it fits within the footprint of the RBPi and does not require any additional powering.

An additional feature on the UPS PIco allows remote operation. An optional infrared receiver does the trick. The PCB routes the infrared receiver directly to the GPIO18. With this feature, you control the RBPi and UPS PIco remotely.

Finally, if you are likely to operate the RBPi in a very high temperature environment, you will need to cool it with external methods. The UPS PIco allows you to implement a PWM fan controller with an automatic temperature control feature. With a micro-fan fitted on the RBPi, the UPS PIco keeps your CPU cool.

Apart from being HAT compliant with RBPi models A+/B+ and 2B, the smart uninterruptible power supply or UPS is fully plug and play. Although the integrated LiPO battery provides 8-10 minutes of back-up power, an additional 3000 mAh battery pack extends this run-time to nearly 8 hours, providing a power backup of 5V, 2A with a peak output of 5V, 3A.

A real time clock simulated with software, with the battery backup offers a functionality offering a file-safe shutdown. The UPS PIco has a pair of user-defined buttons and a pair of user-defined LEDs, along with integrated buzzer for UPS and user applications. With I2C Pico and RS232 RBPi Interfaces, the user can easily monitor and control the operations of the UPS. Add-on boards are easy to use, as the UPS PIco has a stackable header.

Leap Motion with the Raspberry Pi

Robots have the capability to work where humans would find it inconvenient. In fact, that is one of the reasons people build robots. For example, in areas where high amounts of nuclear radiation would be fatal for a human being, a robot can work happily. Science fiction movies have exploited this feature several times – a robot mimicking the hand movements of its human controller, when watched and manipulated from a safe distance. Now, with a few motion-controlled servos, Leap Motion and Raspberry Pi or RBPi, the tiny Single Board Computer, you too can make a robot with the ability to mirror the movement of your hands. Additionally, you can do this even when you are sitting on the opposite side of the Earth.

The project involves two servos, each mirroring the movement of your individual hands. A Leap Motion controller captures the motion of your arms and sends appropriate instructions to the RBPi, which drives the two servos using a PWM driver. Two 8×8 RGB LED matrices individually attached to the servos react to each finger movement on your hands. The Leap Motion controller communicates with the RBPi via PubNub Data Streams.

The project uses the RBPi Model B+, Leap Motion controller with Leap Motion Java SDK, four numbers of Tower Pro Micro Servo, the Adafruit PWM Servo Driver and an optional display case.

The Leap Motion controller is a powerful device. It is equipped with three infrared LEDs and two monochromatic IR cameras. The cameras capture the movement of your hands and Leap Motion publishes their attributes to a channel via PubNub. The Leap Motion SDK has the attributes pitch, yaw and roll pre-built in it and actually separates the movements of your hands into the three attributes.

For achieving real-time mirroring, Leap Motion sends the attribute information messages nearly twenty times in a second. It sends information about your individual arms and each of your fingers to PubNub. Since the RBPi subscribes to the same channel, it is able to parse these messages for controlling the servos and the RGB LEDs.

To start, you will need to open a Java IDE and create a new project. You will find a guide for the Leap Motion Java SDK here. Follow up this step with installing the PubNub Java SDK. Make your project implement Runnable, which will allow all the Leap activity to operate in its own thread.

Every second, Leap Motion captures nearly 300 frames. Each frame has a huge amount of information about the hands, such as the number of fingers presently extended and hand gestures such as pitch and yaw. To simulate the motion of the hands, one servo mirrors the pitch while the other mirrors the yaw. Incidentally, pitch is the rotation around the X-axis and yaw is the rotation around the Y-axis. Both servos rotate 180-degrees with a sweeping motion. The resulting servo mimics most of the movements your hands make.

Leap Motion outputs values for the pitch and yaw in radians. The RBPi is responsible for converting these radians into degrees and finally into PWM or pulse width modulation between 150 and 600 MHz for driving the servos.Leap Motion with the Raspberry Pi

Raspberry Pi Zero for a Real-Time Sensor Dashboard

Using the Raspberry Pi or RBPi, the single board computer (SBC), and a few applications from Google, you can have a functional dashboard showing real-time parameters from sensors. Google offers its App Engine in the form of a Platform as a Service or PaaS. The advantage is you can deploy and run your own applications using the Google infrastructure without bothering about exclusive ways of setting up hardware, servers, or Operating Systems.

Google also offers the free and powerful Google Charts that you can use as simple charting tools for plotting the data from the sensors into line charts. An HTML5 templates generator such as the Initializr is also useful for generating templates for the dashboard. Initalizr has several useful frontend resources such as Bootstrap and jQuery.

RBPi Zero is the perfect hardware platform to use for this project. This SBC is a full-fledged computer, but smaller than a credit card. It features a single-core CPU running at 1 GHz and 512 MB RAM. Along with a 40-pin GPIO header, the RBPi Zero has USB and a mini HDMI port.

When you connect a few sensors to the GPIO pins, the RBPi Zero sends their data over to the Google App Engine. On the dashboard, you can see the values and the charts updating in real-time as new data arrives from the sensors. Github carries the instructions for building and deploying the project for the RBPi Zero app and the App Engine dashboard.

For this project, Java is the programming language, as both the RBPi Zero and the Google App Engine support it – both use the Pi4J library. However, those who prefer Python can easily change the code, as both RBPi and the Google App Engine support Python as well. As the latest version of Raspbian, the Operating System of the RBPi comes pre-installed with Oracle Java 8, it is easy to deploy and run an executable JAR on the RBPi Zero.

The JAR acts as the go-between with the sensors and the Google App Engine – it reads inputs from the sensors and passes them on to the Google App Engine. You can use the Apache Maven to compile and build the code on the RBPi Zero. Of course, you may also build the code on your laptop or desktop and copy the resulting JAR over to the RBPi Zero.

You can use Cloud Endpoint on the Google App Engine side. This is a powerful service for creating a backend API by using annotations. This includes the client libraries for web and mobiles. It generates a Java based Android client for use with the RBPi Zero application. Google Qauth 2.0 authenticates the API for installed applications.

The RBPi Zero based hardware provides readings from three sensors – voltage generated by a solar cell, temperature from an analog temperature sensor, and illuminance or LUX from a photocell. A 10-bit Analog to Digital converter with SPI interface is necessary to covert the analog signal to a digital format suitable for the RBPi Zero. All the sensors work with a supply of 3.3V, and the RBPi Zero is capable of sourcing this.

Play Chess with the Raspberry Pi

You could be an ardent chess player searching for a worthy opponent. A human opponent may not always be conveniently present, but a computerized player can be relied upon to be available at any time of your choosing. With the Single Board Computer, the Raspberry Pi, or RBPi, you can now play a complicated game of chess, provided you are willing to build a chessboard first.

You will need an Arduino to control the chessboard and an RBPi to run the actual chess engine Stockfish, along with Chessboard, which is the chess rules library. The entire arrangement is completely automated – plug in the different parts, press the green button and you start playing. If there is no automated arm, you must move the pieces manually and the computer signals its move by flashing LEDs. You get 21 levels of play along with the ability to set the personality of the computer – coward or aggressive.

Apart from the personality setting and the 21 levels, Stockfish allows several features. Choose to play with black or with white pieces, and play against the computer or another human. Along with providing hints if stuck, Stockfish recognizes and makes special moves such as Castling, En Passent, and Pawn Promotion. It validates all moves against all rules of chess, signaling errors and allowing re-moves. The chess engine has a maximum rating of GM and an ELO level of 2900.

Although you can use the RBPi alone to control the board and play the chess engine, using an Arduino relieves the RBPi of many functions, speeding up the chess engine running on it. Since the Arduino does not use an Operating System, it is not possible to run Stockfish on it. Although there are chess programs to run on the Arduino, none is as strong as the Stockfish. Moreover, if you are using a computerized arm, the Arduino can take care of operating the motors. The combination of RBPi and Arduino for the chessboard works efficiently.

You can make the board out of wood or plastic according to the materials readily available. A chessboard has 64 squares with alternate black and white colors. To sense the pieces, you need reed switches under each square. These will be wired in the form of a matrix with eight rows and eight columns, with a single reed-switch straddling each junction. By numbering the rows as 1-8 and the columns as A-H, a command E2E4 tells the computer to move the piece from the E2 square to the E4 square.

To let the computer signal its move with LEDs, you will need a second matrix similar to that of the reed switches. Only this time, instead of reed switches, you must place LEDs at the junction points. Using sockets for both the reed switches and the LEDs is advisable as it becomes easy for maintenance. Unlike reed switches, LEDs are polarized, and need to be properly oriented to function. Placing them in sockets helps to re-orient them if they are inserted the wrong way. The Arduino controls both the matrices with data from the RBPi.

Driving Steppers with the RasPiRobot Board

The Raspberry Pi or RBPi is an inexpensive, tiny single board computer running the Linux operating system. As such, the standalone RBPi is not suitable for running motors, but when combined with an expansion board such as the RasPiRobot Board, you can easily run DC motors as well as Stepper motors off the RBPi. For this, you must use the version 2 of the RasPiRobot or RRBv2 board. Please note you can run only 5V steppers with the RBPi RRBv2 combination, as this board does not support 12V motors.
In practice, the RRBv2 board sits over the RBPi fitting over the latter’s GPIO connector. The stepper motor wires connect to the RRBv2 board, using its L & R screw terminals. To do that, you must first strip the wire ends of their PVC insulation, until about 10 mm of bare copper wire is exposed. Unscrew the terminal sufficiently to allow insertion of the copper part of the wire into the hole. Turn the screw clockwise to let the jaws hold the wire firmly.
One of the advantages of using the RRBv2 board is you can run the stepper motors from a battery pack. The board has a switch-mode power circuit to provide stable power to the motors. Additionally, you can even run your RBPi from this on-board power supply. That makes the entire arrangement completely portable.
When connecting the battery pack to the RRBv2 Board, take care to observe the correct polarity of the flying leads from the battery pack. Some battery packs terminate the wires on a plug. Therefore, you must use a matching female socket adapter that has flying leads. In either case, connect the positive or red lead to the screw terminal marked Vin on the RRBv2 board. Connect the negative or black lead to the screw terminal marked as GND on the RRBv2 board. Powering on/off through a battery pack becomes simpler if there is a built-in switch.
If you have connected your RBPi to the RRBv2 board, throwing the switch to the on position will allow the RBPi to start booting. To run the stepper motor with commands from the RBPi, you will need to download the RRBv2 Python library codes. For this, you will have to connect your RBPi to the Internet.
You can use the Ethernet connection to connect your RBPi to the Internet. Alternately, you may use a suitable Wi-Fi dongle. Once online, use SSH to establish connection to the RBPi from a PC and proceed to download the RRBv2 Python library from here and install it.
To run a stepper motor, you can write some simple Python codes, following the tutorial here. For example, you will have to provide the delay between the steps, the total number of steps you want the stepper motor to move and the direction of rotation – backwards or forwards.
The delay between the steps governs the speed of rotation of the stepper motor. For example, as you make the steps larger, the motor turns more slowly to make the total number of steps.

Room Automation and Raspberry Pi

Most people prefer to come back to a cozy room after a full day’s work. For many, this may not always be possible, unless someone turns on the AC at the right time. For those living alone, help is available in the form of a single board computer, the Raspberry Pi or the RBPi. In addition, the RBPi operates the blinds and you can control it from anywhere in the world – the RBPi is connected to the Internet.

For this project, you will need an RBPi with a suitable SD card, a Wi-Fi dongle, a stepper motor. You will also need a power source capable of driving the RBPi and the motor, a stepper motor driver board, an IR receiver, an IR LED and an NPN transistor.

Controlling the AC is a simple affair, with the RBPi simulating the infrared information the remote control normally uses. You need to use the LIRC library for the RBPi to record this IR information via the IR receiver. The infrared LED driven through the NPN transistor duplicates the signal sent by the remote control of the AC. Initially, you must let RBPi learn the IR codes by recording those using commands in the LIRC library. LIRC produces a configuration file that holds the IR codes for your AC. Playing back these codes through the IR LED allows you to control the AC just as its own remote does.

The RBPi and the motor driver board control a stepper motor for driving the blinds. The RBPi merely drives a GPIO pin to let the motor driver board know if it must operate the stepper. The driver board already has the necessary parameters stored within it for driving the motor. By default, the motor remains off so that it does not waste power when it is not needed. The software takes care of this by turning off the Enable pin on the stepper driver board. When you need to operate the blinds, a script on the RBPi turns the GPIO pin on and off.

To operate the unit from remote, you need to connect the RBPi to the Internet via a wireless network. Use the Wi-Fi dongle for this, configuring the RBPi to switch on the wireless connection immediately after booting. Web access to the stepper motor controller is through Nginx and PHP.

The entire setup works when the RBPi connects wirelessly to the network. You access a web interface and use it to send commands to the controller script running on the RBPi. Depending on the commands sent, you can access either the blind opener or the AC control. For opening the blinds, the RBPi sends on or off signals to the stepper motor controller board.

On the other hand, the RBPi sends the appropriate commands to the air conditioner via the IR link. Depending on the code transmitted over the IR link, the AC will switch either on or off. Additionally, with proper codes transmitted from the RBPi to your AC, you can even set the temperature of the room before returning at the end of the day.