Category Archives: Customer Projects

A USB Hub with a Raspberry Pi Zero

Computers available today come with only one or two USB sockets. With the multitude of USB or Universal Serial Bus devices we use today, it is easy to run out of sockets. For example, you may have to connect your mouse, keyboard, printer, webcam and microphone, all operating on USB technology, to your computer. With only two ports available, it is obviously a difficult task.

However, there is an easy solution. You can use an inexpensive hub. According to the USB standard, which also covers USB hubs, they can support up to 127 devices. Typically, a USB hub has four ports, but some models can have more. Operation of a hub is plug-n-play. You plug the hub into your computer and plug your devices, including other hubs, into its ports. Chaining hubs allows you to build up dozens of available USB ports on your computer.

USB devices can use their own power supply or they can draw power from the computer they are connected. Devices that draw power from the host computer are mostly low power devices such as mice and digital cameras. According to the USB standards, a USB 2.0 port can power devices drawing a maximum of 500 mA and a USB 3.0 port allows devices to draw up to 900 mA maximum.

Self-powered devices connecting via the USB port do not need to draw power from the host computer. For example, your computer does not need to supply power to printers and scanners connected to it. For connecting many unpowered devices to your computer, you will need a hub that has its own power supply, so that the devices do not load the computer’s supply. Such hubs have their own power supply that supplies power to the bus.

If you have the single board computer, the Raspberry Pi or RBPi, especially the Zero version, it is easy to convert it into a USB hub. Frederick had a LogiLink UA0160 USB hub lying around and he used it together with an RBPi Zero to make a powered hub with four ports. He removed the board from its casing and connected the power points to the power points of the RBPi Zero. Since the form factor of the hub board matches that of the RBPi Zero, the entire assembly looks neatly done.

For supplying power to the hub, you will need to connect PP1 of the RBPi Zero to the 5V point of the hub and PP6 of the RBPi Zero to the GND of the hub. Next, you have to connect the USB OTG from the RBPi Zero to the USB port of the hub. For this, use two wires to connect PP22 of the RBPi Zero to the D+ on the hub and PP23 of the RBPi Zero to the D- of the hub.

Use an ohmmeter to check for any shorts between the hub and the RBPi Zero. Additionally, make sure all connections are correct. Use some insulating material such as a plastic board between the hub board and the RBPi Zero, before bundling everything together. If possible, get a case to house the combination and you are done.

Connecting To a Raspberry Pi via an Ethernet Cable

You can use your Raspberry Pi or RBPi single board computer in different ways. Sometimes you may have a keyboard, mouse, and display to connect to your RBPi to use it as a regular computer. At other times, you may prefer to communicate with it through another computer such as a desktop or a laptop. Your method of communication may also vary. For example, if your RBPi is at a distance, you may have to connect to it over the Internet via Wi-Fi.

However, Wi-Fi may be an unreliable and a slow way of connecting to your RBPi if you are communicating with it often using SSH or a remote desktop application. Rather, a faster method would be to use a direct Ethernet connection, which would also be a lot more stable. Since you are connecting to your RBPi directly with an Ethernet cable, you are actually bypassing your local network and not sharing the bandwidth with other computers. Moreover, a direct Ethernet connection allows you to connect to your RBPi even when you are away from your home network, experiencing slow connectivity and or network time outs.

For this, all you need is an Ethernet cable. You will need to assign a static IP address to the Ethernet port of the RBPi. The static IP address will depend on the IP address of the computer and its Ethernet adapter that you will be using to connect to the RBPi. The process of assigning a static IP address is straightforward and should be easy for any OS.

If you are using a Windows computer to connect to your RBPi, open up the Network Connections window from the task bar or by accessing the Control Panel. Now look at the Properties of the Ethernet connection under Internet Protocol Version 4. This will show an IP address of the form 10.0.0.6 or similar.

In some cases, the internet connection may also be set for automatic assignment. Here, you need to connect your RBPi to the computer via an Ethernet cable first. Now access the Windows command prompt and use the ipconfig command to see the address your computer has automatically assigned to the connected RBPi. Next, you will also need to note the default gateway IP, which is the local IP address of your network router.

Apart from the above, you will also need to find out the IP addresses of the domain name servers used by your RBPi for finding websites on the Internet. This you can find out by executing the command cat /etc/resolv.conf on the command prompt of your RBPi.

Now you must edit the /etc/dhcpcd.conf file on your RBPi and modify the three IP addresses in the file. Change the last number of the IP address of your computer’s Ethernet adapter, to any other number between 0 and 255. This becomes the static IP address you will use to SSH or connect remotely to your RBPi.

The static router is the IP address of the default gateway IP you noted earlier and the static domain name servers are the IPs you noted from the /etc/resolv.conf. Save the dhcpcd.conf file and reboot your RBPi. Enjoy your connection.

Controlling RGB LEDs via the Raspberry Pi

Digital gates are great for switching LEDs on or off. Micro-controllers are even better and so are single board computers. That is because they contain several gates to control the LEDs. To top it all, you can program single board computers such as the RBPi or Raspberry Pi to control several LEDs individually to run at different on/off cycles. Additionally, multiple color LEDs are available, such as RGB LEDs, with which you can generate any combination of the basic red, green and blue colors.

Although the GPIO pins of the RBPi can switch on an LED, the pins cannot supply beyond their limit. Therefore, when driving LEDs from the GPIO pins, a current limiting resistor is necessary in series with the LED, to prevent the IO pin from being damaged. The resistance value will depend on how much current the IO pin can source or sink, and the supply voltage of the RBPi or LED.

The RBPi has a 40-pin GPIO header among which, you can control several pins through software. The most common use of external circuits and LEDs with GPIO pins is to indicate status visually. For example, you may be controlling a remote circuit with software, and an LED nearby can indicate its status. The LED lights up to indicate the remote circuit is powered.

It is a good thing that human eyes have something called the persistence of vision. When we see something, its image persists in our eyes for a brief time. Therefore, we can see flashing lights only when they are flashing relatively slowly. Beyond a certain speed, our eyes cannot make out the individual flashes and the flashing light looks as if it is steadily lit. Using a technique called PWM or Pulse-Width Modulation, and controlling the on time of a GPIO pin through software, we can make an RBPi drive an LED such that it looks as if the LED is breathing. Doing the same with an RGB LED, the RBPi can cycle the lights to produce any color in the rainbow.

You can build a simple RGB LED board with a single bright RGB LED, three current limiting resisters and a four-pin connector on a prototype PCB. RGB LEDs have four pins and come in two configurations, common cathode and common anode. In the common cathode configuration, the package combines the cathodes of all the three LEDs into a single pin with the anodes individually available. For the common anode configuration, all the three anodes are combined into one pin, while the cathodes are individually accessible.

To drive an RGB LED you will need to connect its individual anodes or cathodes to three GPIO pins through current limiting resistors. If you use a common anode RGB LED, you will have to connect its common anode to a supply voltage. For a common cathode RGB LED, you will need to ground its common cathode. Now, you can switch on an individual LED of the combination by switching on the corresponding IO pin. See this tutorial for writing simple Python scripts for controlling the LEDs via the RBPi.

The Raspberry Pi Sense HAT

If you are targeting the Astro Pi mission, it makes sense to get the Sense HAT as an add-on board for your tiny single board computer, the Raspberry Pi or the RBPi. With a fantastic RGB LED matrix, not only is the board beautiful to look at, but it also comes with a plethora of sensors on-board. That makes it useful for the applications in the International Space Station where it is headed to in December 2015.

The Sense HAT looks like an ordinary board with an 8×8 RGB LED matrix on it. You can use it to display graphical information in color. For example, using the display you can indicate geomagnetic North. Apart from the matrix, the Sense HAT also has a five-button joystick, which allows the user to interact with the programs the RBPi is running. That includes playing games such as Tetris, Snake or Pong on the RBPi.

The Sense HAT includes several sensors such as a gyroscope, accelerometer and magnetometer. It also has sensors to read ambient temperature, barometric pressure and humidity. A Python software library that comes with the board provides the user with an easy access to everything on the Sense HAT.

Using the software library, you can conduct a huge range of projects for the Sense HAT and RBPi combination. For instance, if you are traveling with the combination, it can measure and show your speed. At the same time, it can tell you the direction it is facing, how humid is the atmosphere nearby and even the temperature of your surroundings.

The Sense HAT kit comes with the fully assembled Sense HAT board, four mounting posts and eight screws so you can mount the HAT on your RBPi securely. Mounting the board on the RBPi is simple. First, fit the four mounting posts with four screws on the board. Now, align the 40-pin connector on the HAT to fit on to the GPIO connector of the RBPi and push in firmly. The four posts will align with the mounting holes of the RBPi. Secure those with the remaining four screws and you are done.

To install the software, visit the AstroPi and the Swag websites. Here, you can find out of the world projects, a host of ideas and instructions related to the RBPi and the Sense HAT, fit for the applications on the ISS or the International Space Station.

Technical specifications of the Sense HAT are impressive, considering the inexpensive setup. The Gyroscope measures angular rate at +/- 245/500/2000 dps. The Accelerometer measures linear acceleration at +/- 2/4/8/16 g. Temperature accuracy measured in the 0-65°C range is +/- 2°C. The Relative Humidity sensor has an accuracy of +/- 4.5% within the 20-80%RH range, with a temperature accuracy of +/- 0.5°C in the 15-40°C range.

You must take care while measuring temperature with the Sense HAT. When the LEDs are lit for some time, they, together with the board, tend to get warm. That heats up the air nearby and the measurement may not reflect the ambient temperature accurately.

Create a Baby Monitor with the Raspberry Pi

The arrival of a baby nearly always alters the entire timetable for all the members of the family, whether willingly or otherwise. For the parents, if they are first timers, the joy of seeing the tiny human is never-ending – they want to see the baby even if they are away from home. That is where a baby monitor comes in and what better to use for the project other than the versatile single board computer, the Raspberry Pi or RBPi.

As a simple, cheap, and low power computer, the RBPi works as a perfect fit for a baby monitor that has a motion detector and a simple web browser interface. That allows you to see the little one on your phone or laptop any time you want.

You will need the entire RBPi kit for this project. The kit will have the RBPi, its SD Card, the USB charger, and the micro USB cable. Additionally, you will need a USB webcam, an Ethernet cable, and a Wi-Fi dongle or an Ethernet power line adapter. Although not part of the project, you will also need a laptop or a desktop to prepare the SD Card for the RBPi. To interact with the RBPi, you will also need a keyboard, mouse, and a monitor.

From the official site of the Raspberry Pi, download the latest Raspbian image on your laptop. Now transfer the image to your SD card, making sure you have backed up anything important on the SD card beforehand. Writing an image wipes off whatever you have on your SD card, so be careful. If this is complicated for you, pre-pared SD cards are also available. Insert the SD card into the slot on your RBPi, plug in the keyboard, mouse, monitor, and the Ethernet adapter and power up the RBPi.

If you do not have a keyboard, mouse, and monitor for your RBPi, you can still connect to it using your laptop. If you are using Linux or Mac on your laptop, connect using SSH. For Windows, you can use Putty. Once you have powered on the RBPi, there will be only a few LEDs blinking, but nothing else. That is why it makes such a good baby monitor – it is silent.

To connect to the RBPi, you will need to know its IP address. As the RBPi is connected to the Ethernet adapter, your router will be the best place to look – search in the connected devices, and make a note of the IP address. Now, to connect via SSH, issue the command from your laptop: ssh pi@xxx.xxx.x.x, where the xx denote the IP address you noted down from the router. When prompted for a password, enter raspberry, as this is the default.

Update and upgrade your OS to ensure you have all the updates and security patches. Now, install motion, as this is the package to allow you to monitor the baby with the webcam. Configure motion to operate in daemon mode with a low frame rate, and start it working with the command: sudo service motion start. Now browse to the webcam from your laptop with: http://xxx.xxx.x.x:8081.

Using OpenHAB with a Raspberry Pi

Nowadays it is common to have smart home products that you can remotely command to control, adjust, and to switch on and off. The single board computer, Raspberry Pi or RBPi is suitable for building a touchscreen command center to interface with such smart products and to provide a suitable interface for control and task scheduling. As an introduction, the project will consist of a Wi-Fi enabled RGB LED strip. It will interface with an RBPi running OpenHAB. This will allow wireless control to switch the LED strip on or off from a smartphone or any other computer on the network.

With OpenHAB, you can interface with over 150 different existing smart home products. Moreover, OpenHAB is very flexible, is open source, and is free to use. Although you can use OpenHAB on an RBPi, it can easily run on any platform – Linux, OS X, or Windows. That means the same setup can be run from any old laptop or desktop you may have lying around.

For this project, the main components you will need are an RBPi and its touchscreen. An RBPi2 is recommended and you can use the 7-inch Raspberry Pi Foundation touchscreen. Some of the additional things you will need are a microSD card, a USB Wi-Fi dongle, a power supply for the RBPi, the NeoPixel LED strip starter pack, a logic level shifter, an ADAfruit HUZZAM ESP8266, and some hookup wire.

To begin, assemble the screen to the RBPi. This can be somewhat tricky if you do not have instructions. There will be two flat ribbon cables, a large one for the display, and a smaller one for the touchscreen. The large cable from the display connects to the display controller board, and the smaller cable from the display controller board connects to the display. Once this is done, you can screw the display controller board with the RBPi on its back on to the standoffs on the back of the screen. The ribbon cable from the controller board connects to the display connector on the RBPi. Power to the display comes from the GPIO pins on the RBPi, for which you need to connect the 5 V and the GND pins via two jumper wires of red and black color, respectively.

Flash the microSD card with the latest build of Raspbian from the Raspberry Pi website and boot up the RBPi with it. You can now connect your keyboard, mouse, and the Wi-Fi adapter. Configure the RBPi to connect to your Wi-Fi network and get the touchscreen to work. For this, you may need to update and upgrade your OS.

The next step is to install the home automation control software, OpenHAB, and its add-ons – follow the instructions here. Next, solder the logic level converter between the ESP8266 and the NeoPixel LED strip. This is necessary, as the strip works on 5 V, whereas its controller, the ESP8266 works on 3.3 V. Make sure the logic level converter is connected the right way. After this, you will need to flash the ESP8266 with the Arduino IDE.

Now, you can download and install the OpenHAB app on to your phone and set it up to control the RBPi on its IP address.

Volumio: Control Your Hi-Fi through a Raspberry Pi

Traditionally, amplifiers connect to loudspeakers through wires. The wires carry the electric currents that make the loudspeakers work to produce sound. So far, wires were also necessary to feed amplifiers from different sources such as CD players, TV sets and others. By placing amplifiers within the speaker enclosure, part of the ugly wiring was taken care, but the wires from the source persisted until wireless methods were discovered.

Introduction of the Walkman and other portable players changed the music scenario forever, bringing it out of the living room and allowing people to carry their music with them. However, there was a limit to the number of songs one could carry on their person. The advent of the smartphones and the Internet opened another door. People could stream music over the net, leaving their collection at home. This was the age of iTunes, Spotify and Beats Music, facilitating listening to music wherever you may be.

Most often, these new methods prove expensive for those on a budget, and they are forced to bypass the newer ways of consuming music. An RBPi (Raspberry Pi) is a great help in these cases, simply because the single board computer is affordable, flexible and of a convenient size. Its flexibility makes it a perfect fit for use as a home audio solution and you can control your music wirelessly without having to invest in expensive high-fidelity stuff.

An RBPi gives you many modes of selecting songs to play and the manner in which they are played. For this, the RBPi uses a specially tailored Operating System by the name of Volumio. The major attraction is the nice and simple cross-platform web interface through which you can control music.

The RBPi sits as a controller just in front of the amplifier. It can pick up songs from a USB stick plugged into one of the USB sockets, select it from your local home NAS or take your picking from Web Radio. For the last part, you will need a Wi-Fi dongle to connect the RBPi to the Internet.

Volumio is easy to set up, as not much of advanced functions or graphics are to be handled. Simply download the Volumio disk image, transfer it to your microSD card and use it to boot up the RBPi. You will not require a keyboard, mouse or monitor to set up the software, as the entire configuration is possible through the web interface of Volumio.

Use your computer to connect to Volumio. You can find it by connecting your computer to the same network where you have your RBPi plugged in. You may also use Volumio over a wireless network, for which, you will have to first connect to the RBPi via Ethernet to configure its settings for use with a Wi-Fi dongle. This also allows you to control the software with the browser on your smartphone – simply type in the URL ‘http://volumio.local’ in your browser.

Using the RBPi makes it simple to select songs and set up other parameters for playing them on your home Hi-Fi system. As an advanced arrangement, this is affordable and one can easily modify it to suit specific needs.

Raspberry Pi and Mathematica Control Telescopes

The single board computer, the Raspberry Pi or RBPi is a versatile device helping youngsters learn computer programming. Its advantages do not stop there, because many hobbyists and DIY enthusiasts also use the RBPi for their numerous innovative projects. For example, Tom Sherlock, an amateur astronomer, has put the RBPi to good use for controlling his telescope. Along with the RBPi, Tom uses Mathematica and the Wolfram language for his telescope control.

Amateur astronomers such as Tom use Mathematica in their hobby to process and improve the images they take of planets and nebulas. They use the Wolfram language to control their astronomical hardware. This consists mainly of controlling the drive on the telescope mount, as this is necessary when automating an observing session.

The process is an important one for the amateur astronomers who use their computerized telescopes for hunting down transient phenomenon such as supernovas. Existing software can take care of the several tasks required by astronomers such as locating objects, managing data and performing image processing, However, automating all the various tasks that an observation session needs, is a great help.

Mathematica is a very useful tool for astronomers. It helps in automating and unifying many of the above operations. Within Mathematica, you have a huge amount of useful astronomical data, which includes the coordinates of several thousand planets, asteroids, galaxies, nebula, and stars. The image handling and processing capability of Mathematica is extremely useful when processing astronomical data.

Tom had earlier interfaced with telescope mounts using an existing library of functions known as ASCOM, a powerful tool for driving domes and filter wheels, mainly associated with astronomy. However, ASCOM has to be pre-installed on a PC and therefore, is rather limited in its use. Using Mathematica allows one to drive the telescope mount directly from any platform and does not need any special setup.

According to Tom, most telescope mounts follow one of two serial protocols for their control. These are the Celestron NexStar protocol or the Meade LX200 protocol. Many non-Meade telescope mounts, such as those from Astro-Physics and Losmandy, also follow the LX200 protocol. Those produced by the Orion Atlas/Sirius family of computerized mounts follow the NexStar protocol just as the Celestron telescopes and mounts do.

The LX200 protocol requires the right ascension (RA) function specified by a string such as HH:MM:SS and the declination (Dec) by a string in the form of DD:MM:SS. These are the basics for slewing the telescope to a target at coordinates specified by the RA and the Dec strings.

You will need an inexpensive USB-to-Serial adapter for creating the RS232 port that the RBPi does not normally have. You also need a small wireless network adapter that fits in the RBPi USB socket. As RBPi uses the Linux operating system, it is easy to use the Wolfram language code for controlling the telescope through the serial port. Additionally, the RBPi can be networked wirelessly. That makes it possible to control it from inside the house, necessary when the weather outside is cold.

EEG Controlling Music through Raspberry Pi

Imagine controlling Pandora with your brainwaves. Whenever a song comes up that you do not enjoy, make it switch to the next one. All you need is an EEG sensor, a pianobar and a single board computer such as the RBPi or Raspberry Pi. Once you train the RBPi to differentiate the bad from good music, you are good to go.

You need to train the Bayesian classifier to recognize good music from the bad. However, basic machine learning techniques do not always turn out very good. Therefore, with this time-series data, you can use it in sequences to reduce false positives.

Using an EEG headset to control songs you dislike is great, especially when you are moving around or doing something away from your computer. You simply slip on the Mindwave Mobile headset from the Brainwave Starter Kit and use the included app to see your brainwaves change in real-time on your mobile. You can monitor your levels of relaxation and attention while watching the response of your brain when you are listening to your favorite music. The Brainwave store has multiple brain training games and educational apps, which are classified according to age and personal interests.

Data from the Mindwave Mobile headset travels via Bluetooth to communicate wirelessly with the RBPi. Using the free developer tools available online from NeuroSky, you can write your own programs to interact with the Mindwave Mobile headset. On the Mindwave Mobile, you can see the EEG power spectrums of alpha, beta and other waves from your brain. With the NeuroSky eSense, you can even sense eye blinks and differentiate between attention and meditation states.

When using the EEG headset with the RBPi and a Bluetooth module, you can record data of some labeled songs that you like and some that do not appeal to you. From the Mindwave headset, the RBPi will get data on waves from your brain such as the delta, theta, low alpha, high alpha, low beta, high beta, mid gamma and high gamma. It will also get an approximation of your meditation and attention levels using FFT or Fast Fourier Transform. Additionally, the headset also provides a skin contact signal level.

It is difficult to make out much from the brainwaves unless you have received adequate training to do so. Machine learning helps here, as you can use software to differentiate good music from the bad. The basic principle is to use Bayesian Estimation to construct two multivariate Gaussian models, one based on good music and the other representing bad ones.

Initially, the algorithm may only be accurate about 70-percent of the time. Although this is rather unreliable, you can use the temporal data and wait for say, four simultaneous estimates before you decide to skip the song. The result is a way to control the songs played, using only your brainwaves.

Pianobar on the RBPi controls the music stream to Pandora. You start pianobar and then start the EEG program using python. It will tell you if the headset is placed properly on your head since it gives a low signal warning. Once it detects a song, it will skip it once it detects four bad signals in a row.

Monitor Your Solar System with a Raspberry Pi

Most photovoltaic systems contain parts such as the solar modules (panels) to provide the electrical power, a battery charger for converting the panel output to the battery voltage, a battery pack to store energy during the day and provide it during the night time, an inverter to transform the battery voltage to the proper line voltage for operating home appliances and an line source selector to switch between the solar and grid power.

When the sun is shining during the daytime, the solar photovoltaic cells convert the sunlight falling on them into electricity. Although the efficiency of the conversion may be only about 17%, solar power can easily reach 1KW/m2 and suitable panels can produce 5000 Watts in these conditions.

Solar panels typically produce a high voltage, 120V DC being a common figure. The battery charger has to convert this to match the battery voltage, generally 48V DC. Solar light power charges the batteries continuously during the daytime; therefore, the charger has to keep tracking the maximum power point to optimize the yield of the system. As the charger has to charge the battery also, this device forms the most elaborate part of the system.

With the above arrangement, the solar panels charge the battery during the daytime and the battery discharges during the night. The size of the battery depends on one day of consumption plus some extra to tide over an overcast day. That also decides the size of the solar panel. Batteries are essentially heavy and the lead-acid types generally have a lifespan of about 7 years.

The batteries feed the inverter, which converts the 48V DC into the line voltage – usually 230V AC or 110V AC. With a 5KW continuous rating, inverters can essentially run almost all household appliances such as the clothes dryer, the washing machine, the dishwasher and the electric kitchen oven. When the inverter is supplying a large load, the battery current may climb up to 200A.

Multiple sensors measure the solar field power from and temperature of the solar modules divided into arrays. The information comes to a PV panel via a CAN bus, which unites all the sensors. The PV panel also acts like a gateway between the CAN bus and a single board computer.

The tiny, versatile single board computer, the Raspberry Pi or RBPi is suitable for gathering data from the PV panel and storing them in a database. On the RBPi is a web server connected to the home Ethernet network.

Another set of sensors monitor the battery voltage, current and temperature. These are also on CAN bus and the information collects on a PV battery monitor board. A Wi-Fi module on the board acts as a gateway between the CAN bus and the Ethernet.

The boards and modules of the monitoring subsystem do not provide any interface with the user, except for a few activity modules. The system is meant for being supervised and controlled remotely. This is possible with a Web User Interface or an Android application.