Tag Archives: adafruit

Using Raspberry Pi to Monitor the Environment

Many cities in the world are plagued with poor quality of air caused mostly by pollution form old diesel cars. This is true of Peru also, and James Puderer is using Raspberry Pis (RBPis) fitted in several taxis to monitor the air quality. James fitted the RBPis in the hollow vinyl roof sign almost all taxicabs use in Peru.

James uses the RBPi along with various Adafruit technologies, such as the BME280 sensor for temperature, humidity, and pressure. He has created a retrofit setup powered by a battery and GPS antenna that fits snugly into the hollow of the vinyl sign.

The completed air-quality monitor collects data on latitude, longitude, pressure, temperature, humidity, and airborne particle count. The data enters a data logger, which then pushes it on to the Google IoT Core, from where any computer may access it remotely.

At the Google IoT Core, Google Dataflow processes the data and turns it into a BigQuery table. Any user can then visualize the measurements the monitor collects, using several online tools available to study them and organize to figures depending on the results he or she expects to achieve. For instance, James uses Google Maps to analyze the data and produce a heat map of the local area that includes air quality.

On his project page, James provides the complete build process for the air quality monitor using the RBPi. This includes the technical ingredients and the code he developed. He also urges others to make their own air quality monitors for their local environment. His plans include designing an additional 12 V power hookup, which will enable connecting the air quality monitor to the battery of the vehicle. He also plans to include functioning lights when the air quality monitor is inside the sign, and companion apps for the drivers to use.

Others have also used the RBPi with sensors to track the world around it. This includes the Human Sensor costume series by Kasia Kolga. The dresses react to the air pollution by lighting up. Kasia created the Human Sensor in collaboration with Professor Frank Kelly and other environmental scientists at the King’s College, London.

Linked to an RBPi and a GPS watch, a small aerosol monitor is hidden within each suit of the Human Sensor costumes. These components work together and gather the pollution data at their location. Although the suits store their collected information to submit it later, in future the suits will be relaying the data in real time to a website for the public to access.

The RBPi works to control the LEDs attached to the suit. In reaction to the air conditions detected by the monitor, the RBPi flashes the LEDs, makes them pulse, or produce patterns and colors that morph accordingly.

Depending on the negative or positive effect of the air around the monitor, the suit’s LED system responds to the absence or presence of pollutant particles. For instance, when the wearer walks past a grassy clearing in a local park, the suit will glow in green colors to match it. As soon as the wearer goes behind the exhaust fumes of a car, the suit will pulsate with red light.

Raspberry Pi Goes Binocular

This project uses the popular single board computer, the Raspberry Pi (RBPi) and a spare pair of binoculars to view and take pictures. The LCD on the RBPi is touch enabled to make it easy to capture the images.

To start with, you will need the appropriate Operating System for the RBPi. Download the Wheezy Raspbian OS from the Adafruit site, which will make it easy to interface the 2.8” TFT LCD with a capacitive touchscreen from Adafruit. Once download is complete, unzip the image and install it on the SD card. For the RBPi, you will need the Pi camera with its cable.

Make a suitable arrangement to mount the RBPi and LCD securely on the binoculars and place the camera on one of the eyepieces. This will tell you if the default cable that came with the camera is enough for the purpose or you need to order a longer one. A Wi-Fi dongle (USB type) makes the entire arrangement suitable for transmitting images over the net. In the absence of a Wi-Fi dongle, connect the RBPi to your network using an Ethernet cable.

To configure the RBPi, initially you may have to start with the Raspberry Pi Software Configuration Tool, by logging in and running the command “sudo raspi-config.” This will allow you to set the language, time zone, and keyboard layout according to preference. Additionally, you will also be able to enable the camera, set up the IP address, and the Wi-Fi credentials, which the RBPi will use to communicate.

You can mount the RBPi over the camera in a number of ways, depending on the material available. It is possible to do this with stiff cardboard, thin plywood, and tape. Measure the binoculars and the RBPi to make a suitable cutout in the cardboard. This may require using jigsaw, drill, or laser cutters. If you have access to a 3-D printer, take more accurate measurements, make a suitable image using engineering software, and print a template. Whatever the method of mounting, make sure the RBPi is secure and does not fall over.

Power up the RBPi and the camera and you should be able to see the image on the LCD screen. Place the camera on one of the eyepieces so that light passes through the binoculars and falls on the camera lens. Adjust the position of the camera until you see a well-defined circle on the screen. Now secure the camera to the eyepiece with tape.

For transportability, use a rechargeable battery pack to power the RBPi. For instance, a 2300 mAh battery pack will allow around two hours of operation. To prevent corruption of the SD card, program the RBPi for safe shutdown well before the two hours is over. If the battery pack is also mounted on the binoculars, the total weight may increase, making it difficult to hold and adjust. It might help to have the battery pack on a long enough USB cable, to allow the pack to be kept in the pocket.

It is necessary to connect the RBPi to the Internet if you want the images properly time-stamped. As the RBPi does not have an internal clock, it has to synchronize the date and time with the Internet connection.

Raspberry Pi and a Simple Robot

Using a pair of DC motors and connecting them to two wheels can be the basics of a simple robot. Once you add a single board computer to this basis structure, you can do almost whatever your like with your robot. However, making a robot do more than simply run around requires many mechanical appendages that may prove difficult to get unless you have access to a workshop or you are proficient with 3D printing.

To simplify things for beginners, the robot chassis from Adafruit is a versatile kit. With this simple robot kit and a single board computer such as the Raspberry Pi or RBPi, you can start your first lessons in robotics.

As the kit is for beginners just starting with their first robot, there are no sensors. A Motor HAT (Hardware Attached on Top) controls two motors connected to two wheels on a chassis. The front of the chassis has a swivel castor, which makes it stable. The RBPi mounts on the chassis and a battery supplies the necessary power for the SBC and the motors.

Once you are familiar with generating a set of instructions in Python to make the robot move the way you want it to, you can start adding sensors to the kit. For example, simply adding a camera will allow the robot to see where it is going. Adding an ultrasonic range finder will allow the robot to avoid bumping into obstacles in its path.

The Mini Rover Robot Chassis Kit from Adafruit includes almost everything one needs to build a functional robot. It has an anodized aluminum chassis, two mini DC motors, two motor wheels, a front castor wheel, and a top plate with standoffs for mounting the electronics.

It is convenient to use the latest RBPi models such as the Model 2, B+, or A+, as these have suitable mounting holes that allow easy attachment to the robot chassis. Although it is also possible to use the RBPi Zero, its small size makes it unsuitable to mount the motor HAT securely.

The Motor HAT can drive DC and stepper motors from the RBPi and is suitable for small robot projects. The brass standoffs help to hold the Motor HAT securely to the RBPi. Power comes from two sources. One 4x AA battery pack supplies the motors. Another small USB battery pack powers the RBPi. The RBPi also requires a Wi-Fi dongle to keep it connected to the computer and to control the RBPi robot.

Your RBPi must be running the latest version of the Operating System – Raspbian Jessie. If you do not have this, allow the RBPi to access the Internet and download the necessary software.

The Motor HAT library examples included provide adequate software for this project to start. For example, you can use the example scripts provided to make the robot move forward, backward or to turn in different directions. Preferably, place the robot on level ground, where there are no obstacles. As the robot has no sensors, it can hit something or easily fall off the edge of a table.

The Raspberry Pi Zero Has It Simplified

The release of the new Raspberry Pi Zero or RBPi-Zero has taken the technical world by a storm. This tiny SBC has a 1GHz ARM11 System on Chip, 40 GPIO pins, micro-USB ports, a mini-HDMI port, a micro SD card slot and works with 512MB RAM. The 65×30 mm card has gone on sale with a price tag of a mere $5.00.

The Broadcom BCM2836, clocked to 1GHz, runs Raspbian Linux. Not only is the RBPi-Zero 40 percent faster than the original RBPi Model B, it is also 40 smaller than the B+ model of the RBPi. Although almost identical in size to the RBPi Compute Module, the RBPi-Zero has the real-world ports that the former lacks. However, like the A+ Model, the Zero lacks the Ethernet port.

People looking for the Broadcom chip on the RBPi-Zero will be disappointed at not finding it on either the top or the bottom side of the board. The Raspberry Pi Foundation has adopted the Package-on-Package or PoP manufacturing technology for RBPi-Zero. Therefore, although the Broadcom chip is present on board, the Elpida 512MB RAM chip sits piggyback on top of the Broadcom chip, hiding it from view.

The RBPi-Zero lacks the USB ports, DSI and CSI ports and the audio jack. That is because it is intended for IoT- and embedded-focused hackers. The manufacturers have kept the same 40-pin expansion header other modern RBPi boards possess. Therefore, users can attach available HATs or other expansion boards and adapters. Moreover, the Zero can run any application meant to run on the Model B+.

To use the RBPi-Zero, users will need additional cables. Although most users will have these lying around, others may need to buy them and some more. The best way to start is to go with the Adafruit kit, which is selling two versions in the US market – the Budget Pack and the more expensive Starter Kit. Other vendors offer different combos for accessories.

The Budget Pack of Adafruit comes with a RBPi-Zero board along with a 5V, 1A power supply, USB-A to USB-micro B cable, an 8GB Class 10 SD Card for the OS, a Micro-USB to USB OTG cable, 2×20 Male header strips and a Mini-HDMI to HDMI adapter.

The Starter Kit from Adafruit includes the above and adds more 2×20 male and female headers, USB Console cable and a Wi-Fi dongle. With the USB Console cable, you can put up an alternative display in place of the HDMI.

The Essential Kit from PiHut offers all the items of the Budget Pack of Adafruit (except the SD Card) and includes four rubber feet, one single row of 20-pin GPIO header, one dual row of 40-pin GPIO header, one dual row 40-pin female GPIO header and one dual row 40-pin right-angled GPIO header.

Pimroni offers similar kits to the two above, but offers useful zero-sized PiHATs. These include the Explorer pHAT, the Scroll pHAT and the pHAT DAC. The Explorer HAT is suitable for building a tiny robot as it can drive a motor over an H-bridge, has buffered digital IOs and four analog inputs for low-cost sensors. With the Scroll HAT, you can drive 11×5 LED matrix and the pHAT DAC adds a digital to analog converter to your RBPi-Zero.

The 4DPi-24-HAT for the Raspberry Pi

Once you have a Raspberry Pi or RBPi, you need a keyboard and a monitor to communicate with it. Provided the monitor has a touchscreen, you can dispense with the keyboard. Just such a touchscreen LCD is available from 4D systems and Newark Element14. Their 4DPi-24-HAT is a 2.4-inch, resistive QVGA LCD with a resistive touchscreen and designers claim this is the first device to use the full HAT design.

HATs or Hardware Added on Top boards enable the RBPi SBC to configure its GPIO signals and drivers for use with the external devices on the board. Users find this easy for installation, and the burden on developers reduces considerably. Although this is not the first touchscreen to use the HAT interface, the 4DPi-24-HAT has its own argument for being the first device to use the full HAT design.

For example, Adafruit offers PiTFT, a 2.4-inch TFT touchscreen supporting a HAT connection. This is 320×240-pixel kit, requiring soldering to attach the 2×20 GPIO header to the HAT board. Although this is fast and easy to do, the 4DPi-24-HAT does not require any soldering.

The 4DPi-24-HAT, with its 320×240-pixel resolution, is on the low end of the spectrum for available touchscreens for the RBPi. It also uses a 4-wire resistive touchscreen, rather than the more sensitive capacitive touch technology. With a typical video frame rate of 25 frames per second, the touchscreen supports full-color. According to 4D Systems, the frame rate can be increased with kernel compression.

Users can display the output of RBPi Models A+, B+ or the latest RBPi-2 Model B on the screen of the 30-gm, 65×56.5×14.4mm display. No external power is necessary, as the display sits directly on the 40-pin header and draws its required power from the RBPi.

4D Systems has optimized the 4DPi-24-HAT for operations with the Raspbian Linux. The RBPi communicates with the HAT via SPI connection at 48MHz. The display utilizes an on-board processor featuring a customized DMA enabled kernel. The processor interprets direct commands and takes care of the SPI communication.

An on-board jumper is useful for switching on or off the backlight of the display. Dimming of the backlight is also possible through PWM signals and controls. The RBPi is able to recognize the device quickly because of the EEPROM on board the HAT.

When you place the touchscreen on the RBPi, it sits on the entire bank of the GPIO connectors. It also almost covers the RBPi, excluding the Ethernet and USB ports. You can use standoffs to support the other end of the display to prevent it from hanging. The screen also fits neatly within the official RBPi case.

To power up the display from your RBPi, you have to download the 4DPi-24-HAT kernel from the 4D System’s website. By default, this kernel will replace the file config.txt at /boot. To get the display to work you now need to play around with the framebuffers on the device. This way, you can get it to display a higher resolution image and even enable other features on the screen.

For example, the file /boot/cmdline.txt will allow you to rotate the image on the screen to rotate by 0, 90, 180 or 270-degrees.

Infrared Thermopile Sensor for the Raspberry Pi

The usual process for measuring temperature is to place the probe directly touching the surface whose temperature is to be measured. That assumes the sensor is placed on the tip of the probe and must be in contact with the surface of interest. However, heat is a radiation and as infrared rays emanating from the surface carry information about how hot the surface really is, it should be possible to measure temperature remotely. Texas Instrument has designed a contact-less infrared thermopile sensor, the TMP006, and Adafruit is offering this on a breakout board suitable for the popular single board computer, the RBPi or Raspberry Pi.

Therefore, using this Infrared Thermopile Sensor with the RBPi, you can measure temperature of an object without touching it. The TMP006 is an embedded thermopile sensor that absorbs Infrared radiation emitted by a surface towards which you point it. It generates a small voltage proportional to the radiation falling on it, which the RBPi substitutes in a polynomial equation. The RBPi solves the equation, thereby converting the voltage into degrees, either Centigrade or Fahrenheit, as the user requires. TMP006 is capable of measuring over an area, so it is handy for determining the average temperature of an object.

As the TMP006 sensor comes in an ultra-small package, a BGA with 0.5mm pitch, it is impossible to solder manually. That is why Adafruit is offering this sensor already soldered on an easy to use breakout board. As the sensor works with three or 5V logic, no logic shifting is necessary to interface it with the RBPi. The sensor IC has two address pins and works with the I2C protocol. Therefore, you can hook up eight such TMP006 sensors to the RBPi, should you need to expand on the measurement. The Adafruit board has a 0.1” breakaway header to allow easy soldering, making it easy for using the sensor on a breadboard. The board also has two mounting holes for attaching it to an enclosure.

Users must note that TMP006 works by measuring the emissivity of an object. The sensor is suitable for measuring the temperature of a surface that has an emissivity greater than 0.7. The surfaces of most polished and shiny metal objects have an emissivity value too low for use with the TMP006. However, for measuring the temperature of surfaces with low emissivity, you can paint it with lampblack paint, which has an emissivity of 0.96.

The TMP006 accurately detects signals in almost the entire field of view of the sensor. For calculation of the final temperature, the sensor integrates all the signals present in the field of view. Therefore, more the signal that the IR sensor can capture from the target better is the accuracy of its measurement.

The percentage of signal absorbed by the IR sensor depends on the angle of incidence of the signal with respect to the sensor. Therefore, for best results, you must place the TMP006 directly underneath the target object. This will make the surface of the target parallel to the TMP006, and the angle of incidence between them will then be zero degrees, allowing the sensor to capture the maximum amount of signal.

A Portable Raspberry Pi Powered display

If you have a motor to control, the RasPiRobot Board is a very good fit. Apart from controlling motors, you can also use its switch mode voltage supply to power your RBPi or Raspberry Pi using a large range of battery types. Therefore, with a pack of AA type batteries and the RasPiRobot shield, you can make a very convenient and portable RBPi powered display.

To make an RBPi display that will show the current time as a scrolling text, you need to collect a few parts. These would be – the Adafruit Bicolor square Pixel LED Matrix along with its I2C backpack, A RasPiRobot Board version 2, a battery holder with on/off switch suitable for holding 4xAA batteries and the RBPi Model B+ with 512MB RAM.

Not much of wiring is involved in setting up the parts together. The only soldering you will need to do involves the LED Matrix display, as this comes in a kit form. This is not too difficult as all the instructions are included inside the kit. Once soldering is over, fit the LED Matrix display into the I2C socket of the RasPiRobot Board.

If you are using the latest version 2 of the RasPiRobot board, you have to be careful its extended header pins do not reach up to the bare connections on the underside of the LED Matrix module. In case they do, you will need to insulate the module by covering the header pins with a layer or two of electrical insulating tape.

Next, plug in the RasPiRobot Board on top of the RBPi. Just make sure the RasPiRobot board fits over all the GPIO pins on the right hand side of the RBPi. The RasPiRobot Board has two screw terminals marked GND and Vin. From the battery box, attach the flying leads to these screw terminals taking care of the correct polarity.

Fit four rechargeable AA batteries to the battery holder. Make sure they are fully charged and fitted with the correct polarity. When you turn on the switch on the battery holder, you should see the RBPi light up its power LED as well as the two LEDs on the RasPiRobot Board.

To operate the LED Matrix board from the RBPi, you will need to install the Adafruit I2C and the Python Imaging Libraries – follow the instructions here. The guide also has a few examples to allow you to check the working of your I2C interface and consequently the LED Matrix display. For example, you can have a slow display scrolling text on the LED Matrix, showing the current time.

The LED Backpack library has a number of sub-libraries that handle the low-level interface to the matrix display. The Python Imaging Library handles the job of writing text onto the display as an image. This uses the True type Font FreeSansBold size 9 from the library, although you can use other fonts as well that look good. You may need to experiment with the fonts, as they are not primarily intended to be displayed in the 8×8 pixels the matrix uses. You can select the color of the display also.

Prototyping Plate Kit for the Raspberry Pi

For new owners of the versatile inexpensive Raspberry Pi or RBPi, there is always a period of perplexity as to how they can try out an embedded computer project with the SBC. Although a breadboard helps to some extent, connecting the circuit on a breadboard to the RBPi involves many loose wires, making the experiment very cumbersome. An add-on kit, the Pi Plate from Adafruit, makes it very easy to prototype circuits for the RBPi.

The Pi Plate snaps on to the RBPi and the user can easily unplug it for making any changes to the circuitry. This is a double layer board and has a connector on the underside for fitting on to the GPIO pins of the RBPi. The specialty of the Pi Plate is the huge prototyping area, half of which is in the form of a breadboard style, and the rest in the form of a perfboard style. Therefore, users can wire up DIP chips, sensors and switches.

All the GPIO, I2C, SPI and Power pins from the RBPi are broken out to 0.1” strips along the edge of the proto area. The connections are all labeled, so the user has little difficulty in connecting them to his/her prototype circuit. In addition, all the breakout pins are also connected to 3.5mm screw-terminal blocks, all with labels. That makes it very easy to connect sensors, actuators, LEDs, etc. semi-permanently with wires. For general-purpose non-GPIO connections, there is also a 4-block terminal block broken out to 0.1” pads. For those with surface mount chips to be connected, the remaining space has a SOIC breakout area, therefore, if you can conveniently use an IC that does not come in a DIP format.

When you buy the kit, all parts come separated. Following a tutorial on how to assemble the kit, any first-time user can learn to put it together. One advantage with this process is the user learns to solder and thereby acquiring a new skill. This is in line with the philosophy of learning with the RBPi.

Those who regularly use add-ons to the RBPi will appreciate that the header breakouts on the Pi plate are taller than the typical custom header breakouts. Therefore, the prototype plate sits above the metal connectors on the RBPi, allowing for a large workspace. However, this does not prevent it from fitting within the RBPi enclosure. Therefore, the RBPi remains safe within the enclosure, with complete access to the terminal blocks, making prototyping simple. Adafruit plans to have stackable header kits, which will help in putting multiple plates on top of the RBPi.

It is very easy to use the Prototyping Pi Plate. Adafruit has designed it to be as simple as possible so that it is a good fit for any type of RBPi project – whether simple or complex. According to Adafruit, there is no extra power regulator on board and none of the pins is buffered, because that keeps the design simple and inexpensive. In addition, it also offers the maximum space for adding any circuitry for prototyping.

Raspberry Pi Lights up a 64×32 RGB LED Matrix

When you want to make a video wall such as those found on the sides of buses and bus stops in New York, you need a panel with a matrix of LEDs. These are very handy for displaying short video clips or animation. Adafruit has quite a few of them in different matrix sizes such as 8×8, 8×32, 16×24, 32×32 and 64×32. The last one is available in pitches of 3, 4, 5 and 6 mm.

LEDs on the panel are placed close together in a 3 mm pitch, so that you can appreciate it from up close. With the matrix being made of bright RGB LEDs, you have a 160-degree wide-angle view and the panel looks great both in either ambient light and indoors. You can use panels with a larger pitch if you want it to be read from still farther.

In the matrix on the panel there are 2048 gleaming RGB LEDs arranged in a grid of 64×32 in front. The backside of the panel sports a pair of IDC connectors – one of them is for input and the other for output. You can drive the display with a 1:16 scan ratio when the two connectors are chained together. For this, you need 12 numbers of 16-bit latches.

Along with each panel, Adafruit provides an IDC cable, a plug-in power cable, four mounting screws and mini-magnets (for mounting quickly on a magnetic base). You will have to buy the regulated 5V power supply unit separately. The panel consumes about 4A. The panels need 13 digital pins of which 6 bits are required for data and 7 bits for control. That makes the panels perfect for being driven with the tiny, inexpensive, credit card sized SBC, the Raspberry Pi or RBPi.

You cannot drive these displays by FPGAs or any other processors using high speed, as there is no PWM control built into the panel. Instead, you need to refresh the display manually by redrawing the screen repeatedly. For example, for displaying a 4096 color image (12-bits), you will require about 3200 bytes of RAM for buffering and the process will take up about 40% of CPU time. Adafruit provides support with complete wiring diagrams and library code for drawing pixels, circles, rectangles, lines and text.

An RBPi cannot directly drive the RGB LED display matrix directly. The GPIO pins on the RBPi cannot provide the necessary drive. Moreover, signals from the RBPi will have to be level shifted as the panel works off 5V, as compared to the 3.3V for the RBPi. Adafruit has a drive board – the RGB Matrix Hat. This sits on the RBPi and makes it easy for the RBPi to control the RGB matrix for creating a colorful scrolling display.

It is very simple to link up the RGB Matrix HAT with the panel on one side and the RBPi on the other. Plug in the HAT on to the RBPi, plug in the IDC cable and turn on the respective power supplies. Now, run the Python code from Adafruit. The 5V, 4A wall adapter plugs into the HAT, which protects against under, over and negative voltages to the display.