WebSockets, Raspis, and GPIO

socket

A while back, [Blaise] tried his hand at getting the WebSocket protocol working with PIC microcontrollers, WiFi adapters, and a few pots, knobs, and switches. It was an excellent project for its time, but now [Blaise] has a Raspberry Pi, and the associated GPIO pins and Ethernet connection. He decided it was time to upgrade his build to the Pi, this time with a project he calls PiIO.

The basic idea of [Blaise]‘s project requires a Pi, a server, and a computer running a browser for the end user. On the Pi side of the build, [Blaise] connected a Microchip MCP3008 eight input, 10-bit ADC via the SPI bus. The Pi takes the ADC sensor values from pots, buttons, or any other analog source and sends them to a server with the WebSocket protocol.

The server hosts a web site written with Django, Autobahn, and Python to communicate with the Pi and host the web page for the data received from the Pi. There’s support for multiple Pis in [Blaise]‘s build, making complicated projects we can’t even conceive very possible.

[Blaise] put up an awesome demo video of PiIO up; you can check that out after the break.

[Read more...]

Award clock put to good use as a bench meter

award-clock-turned-voltage-meter

The motivation industry turns out these type of award trinkets by the millions. Here’s a way to actually put the thing to use. Instead of displaying time, the clock dial serves as the readout of a voltage meter.

When we first saw this post we assumed that the hack used some type of coil injection to drive the hands. But it turns out that this is mechanically driven. The image above shows the stepper motor which is mounted behind the clock. Its drive shaft is coupled with the adjustment knob on the back of the clock. The precision of the motor lets the PICAXE set the clock dial based on the number of motor steps. The hour hand shows the tens value with the minutes serving as ones (base 10, not base 60). This means the top measurable voltage is 12V — when the hour hand is at 12 the measurement is 0 volts plus tenths of a volt from the minute hand. With the dial taken care of the rest of the project focuses on measuring the voltage using the ADC, which has an upper limit of just 5V. This is overcome with a simple voltage divider.

After the break you can see the accuracy of the rig as it performs measurements next to a digital voltmeter.

[Read more...]

Standalone air quality monitor based around Raspberry Pi

rpi-air-quality-monitor

You can have a lot of fun tinkering with the Raspberry Pi. But in addition to the low-cost hobby potential it is actually a great choice for serious data harvesting. This air quality monitor is a great example of that. The standalone package can be taped, screwed, bolted, or bungeed at the target location with a minimum of effort and will immediately start generating sample data.

The enclosure is a weather proof electrical box. The RPi board is easy to spot mounted to the base of the case. On the lid there is an 8 Ah battery meant to top off an iPhone. It works perfectly as it provides a USB port and enough current to operate the Pi. On top of that battery is a 3G modem used to access the data remotely — although it can log to the SD card for collection at a later time if you’d rather not mess with a cell network.

Look closely at the GPIO header and you’ll notice that an ADC add-on board has been plugged in. This is used to take the readings from the gas sensor which is monitoring for air pollutants in Paris.

[Jeri] shows off a delta sigma ADC

[Jeri] has had a bear of a time moving up to Valve Software, but electron microscope is safely in her garage (!) and her electronics lab is slowly taking shape. Since she can’t bring out the real-life gravity gun she’s working on, she decided to show off a one-bit ADC that uses just a flip-flop to sample an analog waveform  into digital data.

By toggling the clock input of a 74xx74 (or any flip-flop, really) and feeding the complimentary output to back into the data input, [Jeri] can get an output that is a 50% duty cycle feeding into the input of the chip. Adding an audio input to this data input with 10k pot to this feedback loop will cause the duty cycle to change in relation to the analog input, making a one-bit ADC.

As with any electronic shortcut, there are a few drawbacks: the clock cycle feeding into the flip-flop has to be pretty fast; at least a few dozen kilohertz if you’re sampling audio. Still, if you don’t have a free ADC pin, or you’d just like to build a bitcrushing guitar pedal, it’s a very simple (and cheap) way to get analog into a digital micro.

[Read more...]

Using a 555 timer and ADC as a random seed

Most toolchains for embedded system include support for random number generation. But if you’ve read the manual you’ll know that this is really just pseudo random number generation (PRNG). When calling this function the same numbers will always return in the same order unless a different random number seed is supplied in advance. [Gardner] put together a simple and cheap solution for deriving better random number seeds. He reads a voltage from a 555 timer using the ADC on the microcontroller. At first glance it may not seem like a great source of randomness, but he performed some testing and the results look quite promising.

The project is aimed at Arduino-based circuits, but any chip with an ADC will work. The 555 timer is used as a free running oscillator. We know that this not be very stable when compared to even the worst of crystal oscillators, but that’s what makes it work so well as a random seed source. Add to this the low parts count and small size of the additional circuitry and you’ve got a winning combination. So keep this in mind when you need a random number but don’t necessarily need rock solid entropy.

[via Reddit and Freetronics]

A truly professional Raspi analog input

Much to the chagrin of hardware tinkerers, the Raspberry Pi doesn’t have analog inputs on its GPIO pins. Sure, you can blink a LED with just a few console commands, but reading sensors with a bone-stock Raspi requires a little additional hardware. [Brian Dorey] just released a board that allows for 8 analog inputs on the Raspberry Pi with a 16-bit resolution that is much higher than any Arduino-based build.

[Brian]‘s build is based on an earlier, similar iteration of a Raspi analog board we saw last July. Like the previous version, the new professionally made PCBs use a pair of Microchip MCP3428 analog to digital converter. These ADCs are able to sample four channels at a resolution of 16 bits; a vast improvement over the 8-bit ADCs included on every Arduino.

The boards communicate with the Raspberry Pi over an I2C serial bus using a neat stackable header. In theory, it should be possible to use several of these boards and measure dozens of analog channels, but we’ll leave a demonstration of that up to [Brian].

Arduino voltage measurement tricks

We think it’s a great learning experience to tear back the veil of abstraction and learn a bit more about the hardware found on an Arduino board. This project is a great example. [Scott Daniels] takes a look at the other voltage measurement options available to AVR chips used by Arduino.

If you’ve used the analogRead() function then you’ve already measured a voltage using the Arduino. But do you know what is going on behind the scenes to make this happen? The Analog to Digital converter on the AVR chip is being used to measure an incoming voltage by comparing it to a known voltage reference. That reference is by default the supply voltage line for the chip. This should be 5V but will only be as accurate as the regulator supplying it. [Scott] looks at the other voltage references that may be used. An external reference can be used by adding hardware, but that’s not the focus of his article. Instead he looks at using the 1.1V internal reference. He’s written some short example code that let’s you measure the incoming line voltage based on that internal reference. This is a very handy trick that can let you detect when the chips is running from a battery and how much juice is left in the cell.

Follow

Get every new post delivered to your Inbox.

Join 96,711 other followers