Category Archives: Raspberry Pi

Balance your robot with a Raspberry Pi

You may have seen the amazing two-wheel scooter, the Segway Human Transport system. It has only two wheels, a platform for a person to stand and a handle to guide the vehicle. The scooter operates on batteries located under the platform and between the wheels. Dean Kamen is the inventor of this amazing transporter, which can carry a person around while balancing on its two wheels without toppling over.

After watching the amazing Segway scooter, Mark Williams tried his hand at balancing a two-wheeled robot using the tiny credit card single board computer, the Raspberry Pi or RBPi. You can watch his success in the video clip here – it is almost like watching a human baby learn to take its first tottering steps.

Mark’s PiBBOT, or Pi Balancing roBOT, carries its own power source and the electronics, but unlike the Segway, does not have room for a passenger. The TFT displays the angles from the accelerometer, the gyro, the complimentary filter and the power drawn by the motors. There are two buttons on the top – one for turning on/off the motors and the other for resetting the gyro.

The PiBBOT uses the concept of an inverted pendulum to work. This is similar to how children balance a vertical stick on a finger on their outstretched hand – they move in the direction the stick is about to fall, thus attempting to keep its center of gravity below it. The balancing robot keeps itself vertical by using a control algorithm called PID or Proportional Integral Derivative. It does this by trying to keep the wheels under its center of gravity. Therefore, if the robot leans forward, the wheels carry the robot forward, trying to correct the lean. As the bottom of the robot moves forward, inertia keeps its top in the same place, thus righting it.

PiBBOT has an accelerator and a gyroscope to measure the angle of its lean. One axis of the accelerometer measures the current angle, while one axis of the gyroscope measures the rate of rotation. A well-timed software loop running in the RBPi keeps track of both. The RBPi makes calculations based on the measurements to provide power to the motors via the PWM. The RBPi must move the motors in the right direction to keep the robot upright.

Accurate angle measurements need readings from both the accelerometer and the gyro, which are then combined. Individual readings do not provide the necessary accuracy. The gyro measures the rate of rotation and requires to be tracked over time for calculating the current angle. The tracking usually includes noise, which causes the gyro to drift. However, gyros are useful for measuring quick changes in movement.

Unlike a gyro, accelerometers do not need tracking and they can sense both static positions as well as sudden movements – with gravity defining the static position of the robot. However, accelerometers are notorious for their noise levels. Both gyro and accelerometers perform well over certain sensitivity levels.

Mark is using a measurement range of 250dps with a sensitivity of 0.0875 dps/LSB for his gyro. For his accelerometer, he is using 8g full-scale, corresponding to 4mg/LSB and a full scale of 10. Read the full details here.

Rapiro the Customizable Robot with Raspberry Pi

If you have a kid aged 15 or above with a Raspberry Pi and he is clueless about his next project, Rapiro, the customizable robot may be very suitable for him. Designed for the tiny credit card sized single board computer, the Raspberry Pi or RBPi, Rapiro is a humanoid robot kit. It is an affordable kit and is very easy to assemble, needing only two screwdrivers. With an Arduino compatible controller board, the kit comes with 12 servomotors and limitless possibilities.

Even if you are not a programmer, Rapiro is easy to assemble and set up. The assembly instructions are simple and given in a step-by-step method, so anyone can follow them. Rapiro’s controller board is pre-programmed, so that Rapiro will come alive as soon as you have finished assembling it. However, if you are a programmer, you could make Rapiro sweep your desk or have him dance to a tune. For this, you will need to use the Arduino IDE to reprogram Rapiro.

Rapiro is highly customizable. Limited only by your imagination and the sensors you have at hand, simply install the RBPi board and go on expanding the capabilities of Rapiro. For example, you can add image recognition, Bluetooth, Wi-Fi and anything else you can think of to make Rapiro livelier.

Rapiro has 12 servomotors to make it move. There is one servomotor in its neck, one in its waist, two each in its feet and three each in its two arms. There are six servos in its neck, waist and feet have a torque of 2.5kgf-cm each. The servos in its two arms have a torque of 1.5kgf-cm each. The operating speed for all the servos is 0.12sec/60° and the maximum angle they can move through is 180°.

You can program it’s eyes to give its face a full and colorful expression. Its eyes are made of bright LEDs, which can be programmed for different colors as they are of the RGB type. Plastic parts of Rapiro suit both models of RBPi – A and B. With small modifications, Rapiro can accommodate RBPi model B+ as well.

Rapiro’s controller board is very similar to an Arduino board and you can program it using the Arduino IDE. Anyone familiar with C++ development environment can use the Arduino IDE to program the 8-bit AVR based micro-controller on board Rapiro. However, that does not mean only those with programming skills can work with Rapiro – beginners can also learn how to program.

Once you have installed RBPi inside Rapiro, you can make it do more functions. With RBPi, you can use your favorite programming language on Linux to program Rapiro. For example, you could program Rapiro to watch over your home while you are away and to keep in touch by sending you text messages over Wi-Fi. You could have Rapiro acting as a security robot for your house if you give it vision by installing a camera module.

Rapiro requires five AA Ni-MH batteries to function. You can replace this with an AC adapter also. For transferring data, you will also require a USB cable to connect Rapiro to your PC.

Expansion Board for Wi-Fi Connectivity for Raspberry Pi

The tiny credit card sized single board computer, the mighty Raspberry Pi or RBPi is mostly self-contained. However, the small footprint of the SBC has not allowed many important functions to be integrated within it. For example, the RBPi lacks an in-built Wi-Fi. This has led to several developments of Wi-Fi add-on kits, with the xPico Wi-Fi Plate from Lantronix leading the pack.

This pluggable, simple and easy-to-use expansion board from Lantronix provides a feature-rich and robust Wi-Fi solution that few can match. It enables the RBPi to attain several mobile-ready capabilities very easily and quickly. Not only does the xPico completely offload all Wi-Fi connectivity from the RBPi, it also provides many advanced capabilities such as Soft Access Point or Soft AP and Client Mode, along with QuickConnect and Wi-Fi connection management.

Combining xPico with RBPi allows developers to concentrate on the main application for RBPi. This is possible because xPico takes care of all the concerns about wireless connectivity management and wireless stacks while providing hassle-free Wi-Fi connectivity. Users get a robust and true 802.11 b/g/n solution, which provides a painlessly enabled Wi-Fi access either as a client or as a Soft AP. In fact, xPico offers a whole gamut of features along with industrial-ready quality and ease-of-use. Therefore, whether you are a hobbyist, a student or an engineer, you can readily enable your RBPi platform to achieve mobility by offloading the TCP/IP stacks and networking applications such as a web-server to the xPico Wi-Fi.

The xPico expansion board is an embedded wireless device server and has several useful functions. For example, it can provide a universal wireless technology to your tablets and smartphones. Your product designs can be faster now with the simplification of Wi-Fi implementation and integration. It provides unmatched flexibility as the footprint is compact and power consumption is very low. The proven feature-set includes simultaneous Soft AP and client mode, configuration by customization and zero host load. The user improves his competitive position by saving on cost and time-to-market. In short, xPico is designed with the necessary functionality to differentiate your Wi-Fi enabled products by providing flexible, mobile-ready Wi-Fi solutions for IOT and M2M applications.

If you are looking for a robust, full-fledged networking solution, the Lantronix xPico Wi-Fi module provides an extremely compact and low-power alternative. It will provide wireless LAN connectivity on virtually any platform that has SPI, USB or serial interface, such as on an RBPi.

Being one of the smallest embedded device servers in the market at present, you can utilize the xPico Wi-Fi module in designs that require chip solutions, as it befits the advantages to cost and time-to-market. The connected micro-controller need not have any drivers as xPico provides the zero-host-load feature. Therefore, implementation becomes very simple, since not a single line of code has to be written. That translates to a considerably reduced development cost and complexity. Additionally, xPico Wi-Fi meets all EMC and safety compliances such as EN, UL and FCC Class B.

Another advantage with the xPico Wi-Fi module is that it is compatible to a huge range of embedded microprocessors and controllers.

Building a UPS with Raspberry Pi and Supercapacitors

It is always a dilemma when integrating a Raspberry Pi (RBPi) Single Board Computer into a project that works on the mains voltage and the RBPi has to turn it on or off. The difficulty is in deciding whether to power the RBPi separately or maybe power it from a UPS.

Lutz Lisseck solved the problem in an ingenious way. He was looking for a way to shut down his RBPi gracefully, after it had turned off his ambient-lamp. Since the lamp operated directly from the mains and Lutz wanted to turn it on/off from the mains power switch, he would normally have two choices. He could either use a mains wall adapter to power his RBPi or use a battery pack as a traditional UPS. He decided he did not like either, and instead opted for a third alternative, building a UPS with supercapacitors.

Lutz used two 50F supercapacitors to make his UPS. When the lamp was on, the capacitors stored enough charge to outlast the RBPi. When the SBC cuts the power, a GPIO pin senses the loss and informs the RBPi to begin its shutdown sequence. The RBPi takes about 30 seconds to shut down, and the capacitors happily power it for the time. Supercapacitors are usually rated at 2.7V; therefore, Lutz had to put them in series for the RBPi to get 5V. An alternative would be to place the capacitors in parallel and use a step-up converter to jack up the voltage. An upside to this is the capacitors will supply the RBPi for a longer time.

Since the project was a very simple one, there are some shortcomings in using the RBPi this way. First, the capacity is just about enough to shut down the RBPi in 30 seconds. However, when switched on, the capacitors take time to charge and the RBPi has to wait for about 10 seconds, before it gets adequate voltage to boot. Another drawback is that although the RBPi has only 30 seconds to shutdown, the capacitors discharge very slowly, and the system has to remain unplugged for about 10 minutes after shutdown, before it will boot up again. For this ambient-lamp project, Lutz does not consider that as a handicap.

Using supercapacitors over batteries has some advantages as well. The capacitors have a lifetime that far surpasses that of batteries. For example, you could charge and discharge supercapacitors completely several 100,000 times. Moreover, supercapacitors can be charged and discharged at rates that are not possible with a battery. A completely discharged supercapacitor can be fully charged up in just 2 minutes.

Therefore, with the supercapacitors in place, you do not need to worry about improper shutdown when the mains supply collapses. A GPIO pin on the RBPi senses when the mains voltage has been removed and the RBPi immediately begins a shutdown sequence. Whether using the supercapacitors in series or in parallel, a low value resistor (0.5-2.0 Ohms) must be placed in series with the batteries to limit the inrush current at startup. As the resistor can get hot, preferably a high wattage type should be used.

Battle the Sun with a 21W LED and a Raspberry Pi

Lighting up an LED or an array of LEDs and controlling their brightness is a simple affair with the tiny credit card sized single board computer popularly known as the Raspberry Pi or the RBPi. The RBPi runs a full version of Linux and you can use it to drive an array of bright LEDs with it. If you construct it like Jeremy Blum did – he put up the LEDs on his graduation mortar board and wore the RBPi on his wrist on his graduation day – you can be sure of getting a lot of excited remarks from friends and onlookers.

Jeremy wanted to let others interact with the LED on his cap. Therefore, he developed the idea of “Control my Cap” project. His control system consists or a wrist computer comprising an RBPi together with an LCD/button interface. That allows Jeremy to monitor the status of the cap, adjust the brightness of the LEDs, change the operation mode and toggle the wrist backlight. If there is any trouble in connecting with the LED interface, the reasons will be listed on the LCD.

The RBPi is programmed to connect automatically to a list of pre-allowed WPA-protected Wi-Fi hotspots as soon as it is booted. This allows Jeremy to set the wrist interface and the LEDs to a web-controlled mode, let the LEDs take on a static color or have them follow a rainbow color pattern. The cap has a total of 16 LEDs, rated at 350mA each, with four each of Red, Green, Blue and White in four strings. A constant current driver that has a PWM control drives each string of LEDs. A separate on-board switching controller generates the 5V for the RBPi.

As the whole project is portable, a battery powers it. Jeremy used a laptop backup rechargeable battery for his project. At full brightness, the array of LEDs consumes a total power of 21W and is easily visible is bright sunlight. With an 87 Watt-hr. capacity, the battery is able to power the cap for an entire day and more. Additionally, it has a 5V USB port, which Jeremy uses for charging his phone.

Jeremy put up a mobile website controlmycap.com to allow anyone to submit colors for the color queue of the cap to be used in the web-controlled mode. In this mode, the wrist computer grabs the 10 most recently submitted colors from the mobile site constantly, displaying them on the cap. Additionally, when using a color set for the first time, the RBPi informs the requester by a tweet that their color combination is about to be displayed. The RBPi communicates with the cap via a single USB cable, which doubles as it power supply cable as well.

Jeremy used the FoxFi app on his Samsung Galaxy S4 smartphone to generate a Wi-Fi hotspot and the RBPi was able to connect to the Internet through this. The remote webserver hosting the controlmycap.com website also stores the color requests in an MYSQL database, which the RBPi queries for updating its commands.

Bicycle Speed Projection Using a Raspberry Pi

A bicycle is the in-thing today considering the large amounts of pollution caused by vehicles using fossil fuels. Since one needs to use muscle power to ride a bicycle, cycling has health benefits as well. Many cities now have special lanes reserved exclusively for cyclists, and touring with cycles is one of the favorite sports people of all ages enjoy all over the world.

Cycles have been around for quite some time, and people have invented many gadgets and attachments for improving the travails of the cyclist. Earlier, the gadgets were mostly mechanical, and then electronic, now there are apps on smartphones that help in planning the route, and keeping track of so many things a rider may need. Apart from convenience, safety is another important factor that a cyclist should consider.

People who like to cycle fast usually also want to know their speed. However, glancing at a speedometer on the handlebar of your bike is not a very safe idea if you are going at high speeds. Taking your eyes off the road, even for the brief moment it takes to read the speedometer, is asking for trouble; you might hit a pothole or are doored. Well, someone had a brainwave to project the speed on to the path ahead, so the rider knows how fast he is going, without inviting trouble.

That someone is Matt Richardson, from Brooklyn and he has used a Raspberry Pi (RBPi) for making his bike speed projector as a do-it-yourself project. He has mounted the tiny Single Board Computer on his bicycle, where it reads the speed of the bike and projects it dynamically on to the ground in front of the rider, while still illuminating the way. The headlight also helps to make the rider more visible to other road users. Richard is calling his project the Raspberry Pi Dynamic Headlight.

At present, Richard’s prototype only shows the speed, but almost anything can be shown that a rider would find useful. For example, it could be used to show a turn direction or a map from a GPS program, weather info, estimated time to reach the destination, total distance covered and even proximity warnings if another vehicle approaches to close at the rear.

Although with more information displayed, chances of distraction will also increase. However, with the minimalistic data projected, this headlight is surely a great benefit to cyclists. Richardson has housed the RBPi and other electronics on a triangular piece of wood hung from the center frame of his bicycle. A pico projector clamped on the handlebar handles the projection. A HDMI cable connects the pico projector with the RBPi. A battery pack, meant to power mobiles, powers the entire electronics via a USB cable. The speed sensor is mounted, as it should be, on the wheel.

Richardson is keen to add to the next phase of his project. He wants more animations and visualizations in his Raspberry Pi Dynamic headlight project. Such DIY inventions such as this only goes to show what all is possible with a cheap Single Board Computer, some programming and some ingenuity.

Solar Powered FTP Server with a Raspberry Pi

Why would anyone want an FTP server and that too powered by the sun? Well, with an FTP server, you can access all your digital files from anywhere with an internet connection. The sun-powered bit has two advantages, the sun charges those standby batteries and the expense does not show up in your utility bills.

For the project all the parts used are standard items. The Single Board Computer used is the Raspberry Pi (RBPi), a convenient case with all the right slots for the output ports and a small solar panel. Additionally, you will also need a solar charger and a battery box to house the four AAA sized rechargeable NiMH batteries and a micro-USB cable.

A word about the solar panel; you can buy the solar panel from Cottonpickers. The advantage is you get a solar panel with a built-in battery box and a box for the RBPi together. All you have to do is to slide in the RBPi and plug in the batteries. This model has an on/off switch, so you do not have to pull out the cord to switch off. The batteries keep charging even with the switch in the off position.

A blue LED on charger lights up when the sun is charging the batteries. There is also a USB socket, which you can use for charging other USB devices such as mobile phones. Cottonpickers also supplies a USB cable along with the solar panel, so you have almost everything you need for the project.

The solar panel supplies a little more than 300mA, which means that it is perfect for charging 3000mAH NiMH batteries, since they require a C/10 charging rate. The panel has blocking diodes to prevent the batteries from discharging through the cells.

The RBPi model B, with all its keyboard, mouse, TV and networking plugged in and running consumes about 400mA, which the solar panel can easily meet if the sun is shining in its full glory. When the sun goes down, the battery takes over seamlessly. The solar panel can fully charge four AAA cells of 750mAH capacity within three hours. This allows an operation time of more than one and a half hours on the battery.

Charging four AA cells rated at 3000mAH takes the panel about 10 hours to complete. That means if the panel is left in the sun the whole day, the battery will be fully charged for the night. The options you have are:

Powering your RBPi directly from the sun and use the four NiMH cells as a buffer when the sun hides behind clouds. Let the solar panel charge the battery of cells during the day and you can use your RBPi at night.

Next, you will need a static IP address. This is essential, as the address will let your network firewall know it has to allow incoming FTP requests from there. You will also need a vnc-server and load it up as a service every time the RBPi boots up. For the FTP, use the Very Secure FTP Daemon or VSFTPD. Setup all the software as per the instructions found on CNET and you are ready to go. Don’t forget that your RBPi needs a lot of sunshine!

Let Raspberry Pi Read You an Audio Book

People who have grandmothers (and grandfathers) are fortunate. Although most of these old people are healthy and strong despite their advancing years, not all are so lucky and may be impaired in some way, mostly because of their failing eyesight and trouble with arthritic hands. Since they have a physical handicap, they find it difficult to operate a laptop, a DVD player or a tiny MP3 player. A Raspberry Pi (RBPi) with a large play button is actually helpful if it can read back an audio book.

This can be done in two ways. The RBPi player can have a single large button to pause and play, or have no buttons at all and be operated by NFC tags. The tags are best attached to empty CD or DVD cases, on which the details of the Audio book are printed in large letters for easy reading. Simply passing a case over the player will cause the specific audio book to start playing from its last state.

The player saves its state after every two seconds. Therefore, when the listener is bored or otherwise wants to stop listening, he or she can simply disconnect the player from its mains socket. Reconnecting it allows the player to get back to playing from its last saved state.

The RBPi player with a single large button works as a play/pause button when pressed. Going back to the previous track is easy if the listener holds the button pressed for more than four seconds. Copying files into the player is also a simple affair with a thumb drive. The files are copied into the thumb drive under a special volume label. As soon as it is plugged into the RBPi USSB port, the books are copied into the SD card and starts playing when the drive is unplugged.

For the single button RBPi player, apart from the RBPi and its enclosure, you will need a blue LED, some wires, a pair of speakers and of course, the large button. Among the software that you will need are – Raspbian image (Wheezy), mpd, mps, mpd-python, pyudev and a python script.

When the RBPi player is first powered up, it boots, starts the python script and waits with the audio book in pause. Since at a time only one audio book is stored, pressing the button starts the player. If the button is held pressed by more than four seconds, the player goes back one track. The player always remembers its last playing position.

As soon as a USB thumb drive is plugged in, the player stops playing, mounts the thumb drive, deletes the old audio book, copies the new one from the special name/label on the thumb drive and rebuilds the playlist. A flashing blue LED signals the end of file copy. Once the thumb drive is removed, the new audio book starts in pause mode, proceeding to play when the play/pause button is pressed briefly once.

Use of mpd allows the RBPi player to support wave, Musepack, MOD, MP4/AAC, MP3, MP2, OggFLAC, FLAC and Ogg Vorbis file formats.

Using a Raspberry Pi to Hack an Apple Time Capsule

You may have an old Apple Time Capsule lying around, which you may not be using because it has a failing hard drive. These were expensive at the time Apple first introduced them and for many people, a failed power supply or hard drive might have forced them to stop using the device. If you are not familiar with the Time Capsule, it is a backup arrangement for everything on your Mac. Apple coined the name Time Capsule for the hardware and Time Machine for the software. Windows users will not have seen anything like it, and you can read about Time Capsule on Apple’s official link.

You can bring your dead Time Capsule back to life using the low-cost credit card sized single board computer Raspberry Pi (RBPi). Even if you do not have a Time Capsule to modify, you can simply add a Solid State Drive to your RBPi, house the two in a suitable box and make a Pi Capsule for using on your Mac with the Time Machine software. For information, Linux users may backup to the Pi Capsule using any one of the 21 backup software programs listed here.

Backing up over the wireless may be slow, depending on the Wi-Fi speed. However, you can get much faster speeds using the Pi Capsule over wired Ethernet. Of course, the first time you start a backup, the process will take a long time, so try not to interrupt it. Future backups will be faster because they will be only incremental.

You will need a power supply suitable to power up both your RBPi and the Time Capsule (in case the power supply in the Time Capsule has given up the ghost). Connect the SSD hard drive using a SATA to mini-USB cable via a powered USB hub. It is essential to connect only the wireless mouse and the powered USB hub to the RBPi. Anything else you want to connect to the RBPi, such as the keyboard, SSD, wireless card, etc., goes through the powered USB hub.

For the RBPi, you will need an 8GB SD card with the latest “Wheezy” Linux operating system on it. For instructions on how to load Linux on the SD card, see instructions here. Connect a display through the HDMI. When booted the first time, you will be taken to “Raspi-config” automatically, allowing proper setting for the keyboard connected to the RBPi. Now connect the Hard Drive or the SSD to the RBPi using a SATA to mini-USB cable via the USB hub. For getting the RBPi working with the Time Machine on a Mac, follow the guide here.

Pi Capsule has some extended features over the Apple Time Capsule. For one, it can plug into your TV or any other display. Apart from using it only as backup device, the Pi Capsule is actually a full-fledged computer, which you can simultaneously use for web surfing or emailing. If you are not using an Apple Time Capsule and if you have the ability to make cases, build one to house both the hard drive and the RBPi, taking care to leave openings for the RBPi connectors.

Some of the Best Raspberry Pi Add-Ons

To most people, the Raspberry Pi or the RBPi Single Board Computer is only a cheap desktop. That is because by the time you have added a monitor, a keyboard, a mouse and the SD card, it would have cost as much as a cheap laptop and would still be a lot less powerful.

However, the real innovation of the RBPi lies not in its cost, but in its form factor. You can run the tiny RBPi on a few batteries or solar cells and use its exposed General Purpose Input and Output pins. This trio of combinations does not have any precedents in computing, at least not in the price range of the RBPi.

Being a new type of device, the RBPi is a lot easier to understand with some of the readily available components that connect to it to enable some function or to add some feature.

Most of these add-on components are not from large companies, but developed by hobbyists who saw the need for and filled it. One of these add-on components is the multi-purpose LED display Pi Lite. This is a simple board full of LEDs allowing people to use the RBPi to turn them on or off individually. This has made the RBPi SBC different from the regular PC and forced people to think differently for using it in its particular niche.

Pi Lite has 126 red LEDs, with a white LED version on its way. You plug the board into the GPIO pins on the RBPi. Pi Lite nearly covers the main RBPi board and has about the same form factor. Of course, you need a little configuration to enable the board to use the RBPi serial port, but that is well documented.

You send commands to the Pi Lite via a minicom terminal. Once connected over the serial port, anything sent over will scroll across in beautiful red light. Not only can you send text, you can also send commands preceded by three-dollar signs. You can turn all pixels on or off, display horizontal and vertical graphs and manipulate individual pixels.

You can improve the connectivity of your RBPi by expanding its ports. As the GPIO pins are exposed, any circuitry can be added to the RBPi. That may cause accidents and fry your RBPi very easily. Although there are several add-on boards that provide access and protection to the RBPI GPIOs, Quick2Wire has a board that uses the I2C and SPI features of the RBPi.

These are the Inter-Integrated Circuit and Serial Peripheral Interface and the board comes in two parts. The main board provides the I2C and SPI ports, adds protection for the RBPi and voltage selectors. Additional boards provide more GPIO ports including analog inputs and outputs that RBPi lacks. You can daisy-chain the boards to allow even more ports to be added to the RBPi.

To control the ports, you need to program the board with the Python programming language. For this, you may have to install the python3-setuptools package. You can find additional details of the above two add-on boards in openmicros.org and Quick2Wire.com.