Tag 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.

Wear Your Raspberry Pi And Listen To Software Defined Radio

Carrying your radio along is nothing new, since a small and portable radio set is readily available. However, there is a different charm in carrying your single board computer with you while it is playing software-defined radio, and this is exactly what Miller Jacobson did with his Raspberry Pi (RBPi). There are two aspects to this project, the hardware and the software. While the software is simple enough, the hardware is somewhat involved.

To carry your RBPi around means to free it from the wall-mounted power supply unit. Power to the RBPi then has to come from batteries. Jacobson used lithium ion cells placed in an imported battery box. The enclosure uses four cells and can recharge USB devices and cell phones. It also incorporated charging voltage regulation and protection. He salvaged cells from a dead laptop battery unit, since these generally have quite a few good cells with only one or two cells bad, which render the entire unit useless.

To save space, Jacobson did not use connectors between the RBPi and the battery box. Instead, he soldered wires directly to the DC power jack on the battery box. The other end of the wires he soldered to the +5V and GND pins at the GPIO pins of the RBPi. He took the video output from the RCA port and used right-angled connectors everywhere he could, so that space used was at a minimum.

Jacobson used a second enclosure box, which was nearly the same size as the battery box, and fitted the two boxes one on top of the other, arranging to screw them together. Within the second enclosure box, he drilled holes to mount the RBPi board. He also cut holes on the sidewalls to take out the projecting wires and make the USB and HDMI ports accessible. Some ventilation holes in the enclosure allowed cooling.

For the display, Jacobson used a Nyxio Venture head mounted display. This is a cheap MMV or Mobile Media Viewer with a composite input. It features a slim profile with a full-sized image and has 2GB flash memory for storage. The virtual display simulates a huge virtual 62-inch screen in a 16:9 wide format on a non-radiation LCD panel.

For an input device, Jacobson used a generic wireless mini keyboard and trackpad. These are generally used for giving presentations and connect via a wireless interface. The tiny wireless receiver connects to the USB port of the RBPi.

Jacobson uses a Realtek RTL2832U based TV tuner as the front-end for the Software Defined Radio or SDR. The tuner covers a huge chunk of spectrum in the VHF and UHF range. The processor in the RBPi board was quite capable of handling the processing of the signals from the tuner.

GNU Radio, GNU Radio Companion and multimon are some of the software being used to receive and decode the APRS packets from the tuner. Jacobson is using Python for some of the other components such as for filtering the signals from the noise, extracting the raw audio and removing the DC offset, etc.

Home Protection with Raspberry Pi

Planning to go on a vacation, but afraid of who will look after your home for you? Worry not, for the mighty Raspberry Pi (RBPi) is here. Not only will RBPi look after your entire house, it will send you an email of what is happening in your home and let you see it on your mobile or on a PC. How cool is that?

Most alarm systems incorporate three primary sensors. The first is a temperature sensor to detect the rise in temperature in case of a fire. The second is an intrusion detection sensor to detect if an intruder has gained access to the insides of the house and third is a motion detection sensor. Apart from these primary sensors, you may add smoke detectors and cameras according to your necessity.

The software consists mainly of a database to store all the events with a time stamp, a dashboard to display the status of the sensors, configure them and to program the alarm system. The Raspberry Pi also acts as a web-server to send email alerts and to display the dashboard on a remote computer or Smartphone.

Depending on the size of the home, its vulnerability and the number of sensors being used, you could divide the area into a number of zones. This makes it easier to arm the sensors belonging to a specific zone. For example, a door and few windows of your home may be facing a busy street during the day and you may decide not to arm the sensors in this zone in the daytime. As night falls, the street gets deserted and you may want the sensors in that zone to be armed for the night.

Dividing the home into zones also has the advantage of knowing in which area or areas the alarm has been triggered. The camera for that zone can then be switched on to assess the situation visually.

Since RBPi runs on Linux, and Linux multitasks very well, the software runs in the background. The software is programmed to wake up RBPi about once every minute and check in on each of the armed sensors in all the zones. If there is no activity, it simply updates the logs for the database and the dashboard and goes back to sleep.

If a sensor trips, or generates an activity, Raspberry Pi records it in its logs, and sends you an email with the details. The dashboard then indicates the alarm condition in the zone where the alarm originated. You have a choice of turning off the alarm after checking it out.

You can login to the server from a remote PC using a username and a password. The web-browser will display the dashboard and a green button lets you know that the RBPi is running your home alarm software and is transmitting the information from the sensors. If the alarm system goes down for some reason, or there is a problem with the connectivity between the Raspberry Pi and your computer, this green button will turn red within a minute. You can now proceed to test, arm or disarm the sensors in each zone. For details of software and setup, refer here.

Gardening with the Raspberry Pi

Many of you may be garden enthusiasts and would welcome the idea of automating some of the maintenance requirements of your plants. For example, keeping tabs on the quantity of water that is required by the plants based on the moisture in the soil, the available sunlight and the environmental temperature might be easy for an experienced gardener. However, gardeners who have just started gardening find it a difficult equation to balance. Even an experienced gardener may have to depend on a novice if taking leave from his garden for a few days.

With a Raspberry Pi (RBPi), most of the above gardening issues can be fixed. The Raspberry Pi can take care of the garden’s watering requirements based on a few environmental measurements. This can bring relief to an experienced gardener forced to leave his beloved plants for a few days. The novice gardener can quit worrying if he is starving his plants or drowning them in water. This is how Devon approached the problem with his Raspberry Pi.

Avid gardening enthusiasts know that too much water to a plant can be as bad as too little. For the Raspberry Pi to determine how much water should be delivered to the plant, it is necessary to know how much moisture is present in the soil in the first place. That, combined with the temperature and the amount of available light can let Raspberry Pi control the pump that delivers the water to the garden.

Since Raspberry Pi is not capable of measuring analog signals that most sensors put out, an Analog to Digital Converter attachment is necessary. For this, using the MCP3008 ADC is a good choice since it allows eight sensors to be used at a time. For sensing the amount of sunlight available, a Light Dependent Resistor or LDR is useful. To measure the ambient temperature with some amount of precision, a temperature sensor such as the TMP35 or TMP37 will do. For sensing humidity in the soil, a homemade humidity sensor using a few long metal nails will be fine.

All the sensors will need a DC voltage supply and a return ground connection, with the signal from each sensor going to one of the channels of the ADC. The 3.3VDC from the Raspberry Pi board is good enough for the sensors. While only one temperature sensor and one LDR is enough, you may need more than one humidity sensor, depending on how big your garden is.

The humidity sensors check the resistance of the soil between a pair of probes inserted into the ground. As the soil dries up, the resistance increases between the two probes of the humidity sensor. If several such probes are placed at different places in the garden, the Raspberry Pi has a fairly good idea of the state of dryness of the soil in the garden.

The final and most important part of the entire system is the pump that delivers water to the garden. Using a tank and a submersible pump eliminates a whole bunch of issues that many gardeners face. You can experiment with drip-irrigation also if you like the idea. Devon has kindly shared the software and the code used, and you can download them here.

Sensing humidity using advanced technology

An approaching thunderstorm creates a very stuffy environment with oppressively heavy moisture in the air. The presence of water in the air is termed as humidity and this largely affects human comfort. The amount of water vapor influences many physical, chemical and biological processes. In industries, measuring and controlling humidity is critical since it can affect not only the health and safety of personnel, it can affect the business cost of the product as well.

Sleep apnea leads to repeated cessation of breathing during sleep. People, who suffer from sleep apnea, have to wear a mask to prevent nasal collapse. The mask is connected to a Positive Airway Pressure machine that sends pressurized air through the nasal passage of the patient, to prevent it from collapsing. It is important to monitor the humidity of the air the patient receives, keeping it at the appropriate level of comfort to allow the patient to sleep comfortably.

Traditionally, humidity or relative humidity was measured with the wet and dry bulb hygrometers. This method is neither accurate nor convenient in the industrial environment. With advancement in technology, solid-state devices are now available, which measure humidity with very high accuracy, repeatability and interchangeability. Solid-state humidity sensors are generally of two types, capacitive and resistive.

In resistive type humidity sensors, the resistance of the element changes responding to variations in humidity in the environment. The construction is in the form of two intermeshed printed combs, made of a thick film conductor of a precious metal such as gold or ruthenium oxide. The two combs form two electrodes, the space between them being filled with a polymeric film. This film has movable ions whose movement is governed by humidity. The film thus acts like a sensing film whose resistance changes with change in humidity.

The capacitive type of humidity sensor has an Alumina substrate on which the lower electrode is formed using either gold or platinum. A dielectric polymer layer such as thermoset polymer is then deposited on the lower electrode. This layer is sensitive to humidity. On top of this polymer layer, a top electrode is placed, and this is also made of gold or platinum. The top layer is porous and allows water vapor to pass through into the sensitive PVA layer. Moisture enters or leaves the sensing layer until the vapor content is in equilibrium with the environment. This sensor is therefore a type of capacitor whose capacitance changes with the change in humidity.

The arrangement of a hygroscopic dielectric material sandwiched between two pairs of electrodes, forms a capacitor whose value is governed by the dielectric constant of the hygroscopic material and the sensor geometry. At normal room temperatures, the value of the dielectric constant of water vapor is about 80, which is much larger than the constant of the sensor dielectric material. Therefore, as the sensor absorbs water vapor from the environment, it results in an increase in the capacitance of the sensor.

Both the resistive type and capacitive type of humidity sensors are available in the form of small surface mount SMD packages, and pre-calibrated to simplify, speedup manufacturing and reduce the cost for Original Equipment Manufacturers.

Why Are Industrial Sensors Going Wireless?

Industries are increasingly opting for low-power wireless photoelectric sensors with extended range of signals that carry for miles. Such improvements have been made possible with the proliferation of low-power micro-controllers that have boosted the range of the sensors and enhanced their battery life.

In general, wireless sensors conserve and extend battery life by switching themselves off when they are not taking measurements. This allows the sensor to spend most of its time not consuming any power. With this simple technique itself, the battery life of the sensor is boosted by a factor of 100 or more in comparison to that of a continuously powered sensor. However, as the sensor does not sense when it is off, the response time suffers.

To understand how much the battery life can be extended, consider a dry contact wireless sensor that typically dissipates about 100 to 200 µW of power. Such a sensor operates on two AA batteries, which last for five years with the dry contact wireless sensor sampling at 10 times or more every second. In comparison, a powered sensor system can remain on continuously and can respond more quickly. It is also possible to run them at higher power levels to produce a longer wireless range.

To provide reliable and interference-free communication, FHSS or Frequency-Hopping Spread Spectrum techniques are used in industrial wireless sensors. Basically, FHSS switches a carrier rapidly among several possible frequencies, using a pseudorandom sequence. When bound or paired devices communicate with each other, data and control packets are interchanged using these frequency channels randomly, but in a pattern known only to the communicating pair.

Typically, the bandwidth necessary for frequency hopping is much larger than that required for transmitting the same information on just one carrier frequency. However, the transmission takes place only on a small portion of the bandwidth at any given time. Since the effective bandwidth of any interfering signal is the same as that for a narrow carrier, frequency hopping greatly diminishes interference from narrowband sources. Usually, a site survey is conducted before installation of wireless sensors to determine if there is RF interference and whether this is strong enough to be a problem.

Modern wireless sensor systems have a radio master device or gateway that polls all its sensor nodes at specific intervals to ascertain radio communications are still operating. If there is no response from one of the sensors, the system reacts deterministically; the system enters a state to maintain control in a fail-safe way.

The radio master connects to multiple sensors allowing many dozens of wireless sensor nodes to work within a single radio network. Using a TDMA or Time-Division Multiple-Access technique, ensures that all the sensors in the network have adequate time to transmit their data and receive their individual instructions. This effectively eliminates the possibility of multiple sensors trying to communicate simultaneously.

One of the major advantages of using wireless sensors and indicator lights is the elimination of complex cable installation. Rearrangement can easily be done if the plant layout changes. The modern wireless sensor with its own battery, radio and sensor in a single housing, allows higher productivity with real-life status of the production line.

Transistors: What Is The Difference Between BJT, FET And MOSFET?

BJTs, FETs and MOSFETs are all active semiconductor devices, also known as transistors. BJT is the acronym for Bipolar Junction Transistor, FET stands for Field Effect Transistor and MOSFET is Metal Oxide Semiconductor Field Effect Transistor. All three have several subtypes, and unlike passive semiconductor devices such as diodes, active semiconductor devices allow a greater degree of control over their functioning.

Depending on their subtypes, operating frequency, current, voltage and power ratings, all the three types of transistors come in a large variety of packages, and all of them are susceptible to ESD or Electro Static Discharge. That means when you handle these devices, you must take adequate precaution against static charges destroying them.

he basic construction of a BJT is two PN junctions producing three terminals. Depending on the type of junctions, the BJT can be a PNP type or an NPN type. The three terminals are identified as the Emitter or E, the Base or B and the Collector or C. BJTs usually function as current controlling switches. The three terminals can be connected in three types of connections within an electronic circuit – Common Base configuration, Common Emitter configuration and Common Collector configurations. All the three connections have their own functions, merits and demerits. The BJT is Bipolar because the transistor operates with both types of charge carriers, Holes and Electrons.

The FET construction does not have a PN junction in its main current carrying path, which can be made from an N-type or a P-type semiconductor material with high resistivity. A PN junction is formed on the main current carrying path, also called the channel, and this can be made of either a P-type or an N-type material. The three leads of a FET are the Source (S), Drain (D) and Gate (G), with Source and Drain forming the ends of the channel and the Gate controlling the channel conductivity. Unlike the BJT, the FET is a unipolar device since it functions with the conduction of electrons alone for the N-channel type or on holes alone for a P-channel type.

The input impedance at the gate of an FET is very high, unlike the BJT, which comparatively has much lower impedance. Additionally, the conductivity of the channel depends on the voltage applied to the Gate, essentially making it a voltage-controlled device, unlike the BJT, which is current-controlled. The voltage applied to the Gate controls the width of the channel, allowing the FET to carry current between the Drain and Source pins. The Gate voltage that cuts off the current flow between Drain and Source is called the pinch off voltage and is an important parameter.

The MOSFET is a special type of FET whose Gate is insulated from the main current carrying channel. It is also called the IGFET or the Insulated Gate Field Effect Transistor. A very thin layer of silicon dioxide or similar separates the Gate electrode and this can be thought of as a capacitor. The insulation makes the input impedance of the MOSFET even higher than that of a FET. The working of the MOSFET is very similar to the FET.

You can read more about transistors in depth here.

Automate Your Home HVAC System from the Internet Using the Raspberry Pi

The HVAC devices in your home, typically the air-conditioner, thermostats, heating and ventilation, use one or more remote handheld devices working on Infrared (IR) technology. As the HVAC devices are from different manufacturers, you will most likely own a multitude of remote devices, making it difficult to handle and set each of them independently.

However, with the Raspberry Pi or RBPi, a small board called the IR Remote Shield and a wireless interface, you can control all the HVAC devices and that too from the Internet. Imagine setting up the environment in your home just as you are leaving office, so that you have a cozy atmosphere to relax at home.

There are two steps in this project. The first step involves teaching the Raspberry Pi and IR Remote Shield combination the codes that the remote handheld devices utilize to control the various functions of each of the HVAC devices. The second step is to connect the RBPi to the Internet through any one of the wireless interfaces such as Wi-Fi, 3G, GPRS, Bluetooth, and ZigBee or 802.15.4. These interfaces are available from Cooking Hacks, and you can choose one.

After you connect your RBPi to the Internet and feed in the IR codes used by your HVAC components, you can use a webserver, a laptop or even your Smartphone to control all your home HVAC appliances from anywhere in the world. But, a few words about Infrared technology first.

Started in 1993, IrDA or Infrared Data Association is the technology popularly used for controlling devices such as air-conditioners, TVs, radios, audio systems and many others. It is based on light rays in the infrared spectrum and invisible to the human eye. Using infrared transmitters and receivers, communication between two devices can be established in direct line of vision. The infra-red transmitters use special types of Light Emitting Diodes and the receiver uses a photocell sensitive only to the infra-red light.

Infra-red communication or control uses serial data transfer by emitting pulses of light, which is coded in binary, a language micro-processors are capable of deciphering. Therefore, for deciphering the binary code protocol that the remote is sending, you must hold the remote in front of the receiver on the IR Remote Shield mounted on your Raspberry Pi.

To decode and copy an IR code, press the “Receive” button on the IR Remote Shield. This will allow RBPi to capture the code the remote button is sending. In the software, you will have to tag each code with its individual function, for example, a certain code may be for raising the temperature and another for lowering it.

Once all codes from all the remotes are in the RBPi, it is a simple matter to map the codes and their functions on a web application. As the RBPi is connected to the Internet, any browser on the Internet can call up the web application, and the specific settings for the HVAC units altered. This allows the software program running on the RBPi to send the altered binary code to the specific HVAC unit via its IR link and change its status.

The Emergence of BBB: the BeagleBone Black

Many a time we have wished our bulky PCs that occupy so much of the desktop space could somehow be magically squeezed into a portable unit. Although such systems are there including the new smartphones and tablets, their sky-high prices are very discouraging for most of us.

Despair not, for such a package has arrived and is well within the reach of an average person’s pocket. Moreover, if you are technically oriented, you could build one yourself. Texas Instruments has provided the core processor and BeagleBoard has provided the packaging. The result is the low-cost, low power, fan-less, single-board computer called the BeagleBone, a latest addition to the BeagleBoard family.

The low-cost, fan-less, low power, single-board computers from BeagleBoard utilize the Texas Instruments’ OMAP3530 application processor. This offers laptop like performance and facility for expansion, without the bulk, the noise and the expense that are typical of desktop machines. Within the OMAP3530, there is a 600MHz ARM Cortex-A8 Micro Controller Unit (MCU), which predicts branches with high accuracy and a 256KB L2 cache memory.

The on-board USB 2.0 OTG port serves a dual purpose; you can transfer data out from the board or allow the board to read data in from an external source. Although the board has a separate 5V DC power socket, power to the board can be supplied through the USB port as well. The board also has a mini-A connector, to which you can connect standard PC peripherals using a standard-A to mini-A cable adapter. A DVI-D connector allows a HDMI display to be connected using a HDMI to DVI-D adapter. The third connector is the MMC/SD/SDIO card connector. To give you the best graphics experience, the BeageBoard has a state of the art POWERVR graphics hardware, which will render 10 million polygons each second.

For people who were not satisfied with the power of the BeagleBoard single-board computer, BeagleBoard has added the BeagleBone Black or BBB. This is the newest addition to the BeagleBoard family, and continues the saga of the low-cost, low power, single-board computers. To provide the additional features, an advanced MCU, the Texas Instruments’ Sitara AM3359 has been used. This is an ARM Cortex-A8 32-bit RISC processor, featuring a speed of 1GHz, and gives BBB the power along with a 512-MB DDR3L 400MHz SDRAM and 2GB 8-bit eMMC on-board flash memory. This frees up the micro SD card slot for further expansions.

The 92-pin headers are Cape compatible, meaning the existing family of cape plug-in boards can be used as well. The on-board HDMI allows direct connection to monitors and TVs. External electronics circuitry can be controlled by the UART0 serial port. For connecting to the Internet, a 10/100 RJ45 Ethernet connector has been provided.

You will need the latest Angstrom distribution eMMC flasher to load the latest Linux distribution. This is a 4GB image, that has to be uncompressed using unxz and written to a micro SD card. Connect an HDMI monitor, and after plugging in the micro SD card in the slot of the BBB, you can power on your single-board Linux computer. Take care to hold the boot button on while powering, and watch the LEDs on the BBB flash and then stay on.

How to measure temperature with a Raspberry Pi

Looking for another project to make with a Raspberry Pi? You can use your Raspberry Pi to measure temperature. Not only at a single point, but also at maximum of 20 points simultaneously. Of course, you will need 20 individual sensors for doing that. Raspberry Pi will poll all the 20 sensors one after the other, and read the temperature from each of the sensors.

If you are wondering how complicated it would be to wire up 20 sensors to the Raspberry Pi, you can relax, since you need only three wires in all. One of the wires will carry power to the sensors, one wire will be the ground or return path and the third wire is a unique 1-wire interface to control the sensor and to read the temperature measured by it.

This wonder sensor is a High-Precision 1-Wire Digital Thermometer, DS18S20, with a measurement range of -55°C to +125°C (-67°F to +257°F), a thermometer resolution of 9-bits and an accuracy of ±0.5°C from -10°C to +85°C. Maxim Integrated makes this thermometer and the smallest size is a little larger than a matchstick head (TO-92).

Not only can this tiny fellow read the temperature, it stores them in its non-volatile memory and can present them either as °C or as °F. You can set temperature limits in its memory and DS18S20 will tell you when the temperature it is monitoring goes beyond the programmed limits. You can use this thermometer with the Raspberry Pi to control thermostats, industrial systems, consumer products or any thermally sensitive system.

At this point, you may be wondering if there is only one single wire for all the 20 sensors, how is the Raspberry Pi able to differentiate the twenty temperature readings. Maxim has programmed each of the sensors with a unique serial number, and when Raspberry Pi wants to read the temperature from a specific sensor, it simply asks for it by the serial number of that sensor. Only the sensor whose serial number the Raspberry Pi queries, sends the temperature data, all the others remain silent.

The Raspbian Linux distribution that you are using in your Raspberry PI already has all necessary kernel modules installed for accessing the 1-wire bus. The programming details are rather simple and you can refer to them here.

What else can you do with a DS18S20 and Raspberry Pi? You may be measuring temperature at a remote place, or there is no space for the extra power supply to the DS18S20. So, instead of supplying power separately, you could make DS18S20 “steal” power from the 1-Wire bus. For this, you must connect the VDD pin of the DS18S20 to ground. According to the datasheet, do not use the parasitic mode for measurements above 100°C, as the DS18S20 will not be able to sustain communications.

If you have programmed temperature limits for some of the DS18S20s, they will raise a flag if the temperature they are sensing goes beyond the set points. By polling for the flags, Raspberry Pi can know, which sensor is sensing temperatures beyond its set point.