Tag Archives: Raspberry Pi Projects

Raspberry Pi Controls the Cardboard Dog

This is a project for beginners using the Raspberry Pi (RBPi) single board computer. The RBPi is used to control a servo for turning the head of a cardboard dog away whenever a person is looking at it. This is to mimic a begging dog that seems ashamed of its begging nature.

This project requires the SBC RBPi, its power supply with the 5 V micro-USB cable, a USB keyboard and mouse, a display, and an HDMI cable. For storing the OS, an 8 GB micro SD card is also necessary. Another computer will be necessary to write the OS to the micro SD card and edit the files in it. The official PI camera will help to recognize the faces looking at the dog, and a micro servomotor is required to turning the head.

The RBPi will be controlling the servo through its GPIO pins. The servo has three wires that need to connect to the GPIO pins using female connectors. The camera has a ribbon cable, which goes into the port labeled camera on the RBPi. The HDMI cable goes into its port on the outside of the RBPi, and its other end goes to the HDMI-compatible TV or monitor.

Download and install the latest version of the Raspbian (with Pixel) from the official website of the RBPi. While installing the image on to the micro SD card, the process will destroy all data on the card, so be sure there is nothing of value before you begin.

Once the OS is installed on the micro SD card, insert it into the slot on the reverse side of the RBPi. If the power cord is now plugged into the RBPI socket and the power turned on, there should be some code running on the monitor screen, with the desktop showing up at the end. At this time, right click anywhere on the desktop and select “Create a New File.” Name the file Dog Turn.py, and select it to open with Python 2 IDLE.  Now open IDLE, and paste the code from here into it.

To make the code in the file to work, the RBPi will need additional Python modules to be installed. These are the libopencv-dev, python-opencv, python-dev, and you must use the sudo apt-get install command to download them.

The cardboard dog for this project uses four 9×6 inch cardboard rectangles, and two 6×6 inch squares, which form the main body. A hole at the top of the box allows the servo to go through. Another 5-inch cardboard cube forms the head, and attaches to the servo. Some cardboard legs make the dog look more realistic.

The entire electronic hardware can fit within the body of the dog. It may be necessary to use standoffs to hold the RBPi in place. The camera should look out from one of the eyeholes in the dog head. Fix it in place so that the cable has sufficient play when the servo moves the head. Simply running the python code should be enough to let the dog do its trick. To stop, turn off the power.

Sleep Better with a Raspberry Pi

Sleep is an integral part of our lives, and lack of quality sleep quickly leads to a whole host of issues related to physical, emotional, behavioral, etc. Quality sleep is linked to a good environment that includes proper bedding, clothing, temperature, humidity, and lighting among other things. Although electronics may not be able to help much with the proper choice of bedding and clothing, a cheap but versatile single board computer such as the RBPi or Raspberry Pi is a good contender for controlling temperature, humidity and lighting during sleep hours.

When using the RBPi for controlling the environment of the bedroom, it is necessary to build an RBPi-based temperature-monitoring network in the house. This helps to get some hard data on the existing temperature trends at different places, so it will be easy to know whether the solutions tried did actually work. Since temperature is to be monitored at different places at the same time, it is necessary to use remote sensors.

You can use temperature sensors such as the single-wire DS18B20 thermometers for inexpensive and accurate temperature measurement. This model has two types of sensors – transistor-sized and waterproof, and you can use either for the purpose. However, people have found the waterproof sensors were easier to position and calibrate, and they were slightly more accurate as well.

Testing the sensors on the RBPi is simple as this SBC supports the DS18B20 sensors by the built-in w1-gpio library. The RBPi allows easy readouts of the 1-Wire devices. You can wire up a few DS18B20s to multiple RBPI, Model A+ and position them at all main parts of the house. It also helps to integrate data from your Nest Thermostat API, if you are using this and collect the local outdoor temperature data as well – use the Weather Underground, for instance. Monitor the temperatures from the different sensors on a rolling 24-hour graph, and you can make out if there is a trend.

It is possible to even out temperature variations in the house by sealing vents and leakages in areas where the temperature dips. However, this may not be enough to raise the temperature to comfortable levels at locations distant from central heating ducts. Moreover, not all walls of the house may receive equal amounts of sunlight, and this may be another reason for the temperature dropping in certain rooms after sunset.

You can use unobtrusive wall-mounted space heaters to boost the temperature up in these areas. Usually, these are slabs of stone with heating wires running through them. Stone has high thermal capacity, meaning it retains and radiates heat for a long time. This arrangement is also safe for use in children’s bedrooms. When used on a thermostat-triggered outlet, the heater only turns on at a select temperature that you choose. You can fine-tune the settings after monitoring the temperature data for a couple of nights.

This project is useful if you are planning to have an extended network, with remote-controlled HVAC using branch air ducts. Individual controls on the branch ducts can control the airflow, so the system efficiency goes up, such as by turning down the airflow to sections of the house where there is no one present.

The Popp-Hub Home Automation Gateway with the Raspberry Pi

Sometimes it is necessary to monitor the home remotely, such as when you are away on a vacation. For this, you need to hook up all the sensors in the home to the Internet for remote monitoring and control. To avoid the complexity of wiring, people prefer wireless devices for monitoring the sensors. As wireless devices could also be in the form of nodes, with each node monitoring multiple sensors, you need a gateway acting as a bridge for connecting many wireless nodes to the Internet.

Launched by Z-Wave Europe and Popp & Co., Popp Hub is one such home automation gateway. What distinguishes it from others available on the market is it is based on the famous Single Board Computer, the Raspberry Pi or RBPi running Linux. The Z-Wave Plus home automation Popp Hub supports Z-Wave and IP smart devices.

The reference design of the Popp Hub gateway includes a software stack certified by the ZigBee Home Automation. It also includes tens of APIs for simplifying the ZigBee integration and the development of applications within a Linux system. The APIs incorporate TCP/IP for the ZigBee bridge as this enables easier integration of low power connectivity solutions and faster development of applications. The included USB dongle is CC2531-based and it runs the ZigBee HA1.2 certified Protocol Stack, MAC and PHY – this has been extensively tested for interoperability.

Z-Wave Europe GmbH is Europe’s largest distributor for all devices based on the Z-Wave wireless technology. They sell and distribute the Popp Hub smart IP home gateway on behalf of the UK-based Popp & Co. The Single Board Computer RBPi2 in the Popp Hub runs the Z-Way Middleware. According to Z-Wave Europe, Z-Way Middleware happens to be the first Z-Wave controller certified to the new standard, the Z-Wave Plus.

Z-Wave Europe claims you can connect Z-Wave wireless enabled devices sourced from more than 300 device manufacturers to the 89x71x25mm Popp Hub. These devices could be remote controlled devices, for windows and blinds, alarms, lighting, security or HVAC. Additionally, Popp Hub is capable of working with several non Z-Wave devices as well, such as IP based devices, plugins and IP cameras.

Users can use a mobile Android or iOS application, a remote control or a single wall switch to control up to 230 Z-Wave devices connected to the Popp Hub. This includes features such as selectively activating the heating system or closing windows automatically depending on changes in the weather conditions. If a sensor device has set off any alarms, you will receive a notification from the application.

The RBPi2 is a 900MHz, quad-core Cortex-A7 SoC that runs on 1GB of RAM and Linux-based firmware. All major ports of the RBPi are exposed to the user. Besides, it has an audio jack, an Ethernet port and four USB ports. You can use Wi-Fi or other wireless devices on the USB ports. The internal SD slot handles the 8GB SD card that holds the Operating System.

Within the Popp Hub, a Sigma Designs SM5202 chip augments the basic RBPi2 functionality. This is a static controller certified by Z-Wave Plus and it provides 48 command classes and adds enhanced security.

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.

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.

Cayenne on a Raspberry Pi

If you are building projects for IoT or the Internet of Things, a single board computer such as the Raspberry Pi, also known as the RBPi, can be a great asset. Moreover, with Cayenne installed on the RBPi, you have a drag-n-drop IoT project builder that the developers of the Cayenne software, myDevices, claims is the first in the world.

Therefore, now it is easy to connect your RBPi to a mobile or online dashboard. On the other side, you have a breadboard ready to connect relays, lights, and motion sensors. Of course, you have always had the freedom to write an application, read multiple pages of documentation, and take time to learn new programming languages, write pages of code, and then debug them to make it all work together. Alternatively, you can reduce the time you spend preparing for your project, because Cayenne helps to get your project up and running in a fraction of the time, and you can build your automation projects in minutes.

With Cayenne, myDevices makes all this possible, because they created Cayenne for makers and developers eager to build and prototype amazing IoT projects with their RBPi, as quickly as possible. Users get a free Cayenne account, which allows them to create unlimited number of projects. There is also a full-fledged IoT maker support capability that allows remote control of sensors, actuators, motors, and GPIO boards.

On the free account, you can also store unlimited amount of data that the hardware components collect including triggers and alerts, providing all the tools necessary for automation. That allows you to set up custom dashboards and threshold alerts capable of highlighting your projects with fully customizable drag-n-drop widgets.

According to myDevices, Cayenne is the first of its kind of builder software that empowers developers to use its drag-n-drop features for creating quick IoT projects and host their connected device projects. Cayenne allows remote control of hardware, displays sensor data, store data, analyze it, and do several other useful things.

In the Cayenne platform, users can find several major components, such as:

The main Application – useful for setting up and controlling IoT projects with drag-n-drop widgets.
The Online Dashboard – set this up through a browser to control your IoT projects.
The Cloud – useful for storing devices, user and sensor data, actions, triggers, and alerts. Additionally, it is also responsible for data processing and analysis.
The Agent – useful for communicating with the server, hardware, and agent for the implementation of outgoing and incoming alerts, triggers, actions, and commands
Whenever you press a button from the online dashboard or the Cayenne app on your mobile, the command travels to the Cayenne Cloud for processing and travelling to your hardware. The same process takes place in the reverse direction as well. Cayenne offers users plenty of features.

You can connect to your IoT through Ethernet, Wi-Fi, or mobile apps. It is possible to discover and setup your RBPi on a network via Ethernet or Wi-Fi. Dashboards are customizable and widgets are drag-n-drop. It is possible to remotely access your RBPi, shut it down, or reboot it. Users can add sensors, actuators, and control extensions connected to the RBPi, and many more.

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.