Skip navigation
1 2 Previous Next

Sci Fi Your Pi

28 Posts authored by: Frederick Vandenbosch Top Member

 

Introduction

 

This is it, the end of the Sci Fi Your Pi Design Challenge. It's been a long journey, with lots of learning, building, sharing and blogging. I hope you have enjoyed tagging along as I made progress on project PiDesk!

 

This post is the final summary of the project.

 

Blog posts

 

Over the course of the challenge, a lot of content was created. I experimented with a new blogging approach with which I separated project updates from guides. The guides were kept as generic as possible, so that readers would not be required to know about the challenge to understand the content. With the challenge over, I'll be renaming the guides and moving them to the appropriate sections of the website, hopefully making them easier to find for others. They will however remain linked in the project updates, so no information is lost in the process.

 

These are the blog posts created during the challenge.

 

Project Updates

 

 

Guides

 

 

Project Summary

 

If this is the first time you stumble upon a PiDesk blog post, have a look at the blog posts above. To get a quick idea of what the project is about, have a look at the pictures below.

 

The collages represent different parts of the project in different stages. The final result is unveiled at the end of this post. To summarise though, the goal was to create a futuristic desk. I did so by integrating things such as LEDs, a wireless charger and capacitive touch controls inside the desk. There is even a computer that pops out of the desk when the correct button is touched!

 

summary-desk_build.pngsummary-stepper_motors.png

summary-magic_lamp.pngsummary-capacitive_touch.png

 

Components

 

A lot of different components and technologies are used in this project: stepper motors, addressable LEDs, capacitive touch, wireless charging, etc ...

 

DescriptionQuantityUsed in
Raspberry Pi B+Raspberry Pi B+1Desk controls
WiPi USB DongleWiPi USB Dongle2Desk controls / Desktop computer
No brand USB Sound Card1Desk controls
Adafruit Mono 2.5W Class D Amplifier (PAM8302)1Desk controls
GertbotGertbot1Desk controls
NEMA 17 Stepper MotorNEMA 17 Stepper Motor2Desk controls
WS2812 LED Strip2 metersDesk controls
AT42QT1070 Capacitive Touch ICAT42QT1070 Capacitive Touch IC1Desk controls
Micro Switch ON/OFF2Desk controls
Mini Speaker 8ohm1Desk controls
Raspberry Pi 2 BRaspberry Pi 2 B1Desktop computer
Adafruit Stereo 2.8W Class D Amplifier (TS2012)1Desktop computer
Recuperated Laptop LCD Display1Desktop computer
LCD Display Controller1Desktop computer
Speaker 8ohmSpeaker 8ohm2Desktop computer
Qi Wireless Charger1Magic Lamp
Qi Wireless Receiver1Magic Lamp
Adafruit NeoPixel Ring WS 2812 (12)1Magic Lamp
Adafruit Trinket 5V1Magic Lamp
12V to 5V DC-DC Converter2Desk controls / Desktop computer
12V Power Supply1Desk controls / Desktop computer / Magic Lamp

 

I made these image, trying to illustrate how everything fits together and interacts:

 

Slide1.pngScreen Shot 2015-08-25 at 21.49.14.png

 

From left to right, top to bottom, we have:

  • Raspberry Pi B+: This is the heart of project PiDesk, as it is in charge of controlling all the different components involved in the project. I originally opted for the Raspberry Pi A+, but was forced to move to B+ as the workaround required to have both audio and neopixels work, required a USB sound card.
  • Dual channel relay board: The relay board is controlled by the Raspberry Pi GPIO pins. It makes it possible to turn a 12 power supply ON or OFF, powering the laptop display, and a 5V power supply for the Raspberry Pi 2 desktop computer.
  • Capacitive touch IC (AT42QT1070): The custom breakout board is used to convert Raspberry Pi GPIO pins into capacitive touch input sensors. The touch sensors have been created using copper tape and conductive paint.
  • LED strip (WS2812): The LED strip is controlled by the Raspberry Pi and has been built into the desk's surface. It displays animations depending on the ongoing action.
  • Gertbot: The gertbot has two functions: raising and lower the screen assembly by controlling two stepper motors, and knowing when to stop using end stops.
  • Wifi dongle (WiPi): Wifi connectivity, mainly used during programming and testing.
  • Soundcard with amplifier (PAM8302): Play sound effects depending on the action to be executed.

 

Slide2.pngSlide4.png

The pictures above represent on one side, the Pi 2 desktop computer, on the other, the magic lamp. As you can see, these items are very straightforward compared to the desk controls and require very little explanation.

 

For the desktop computer, a Pi 2 is used in combination with a recuperated laptop screen for which a controller board was found. A combination of a stereo amplifier and speakers are used for sound.

As for the magic lamp, a Trinket microcontroller and NeoPixel ring are powered via a wireless receiver. The circuit is powered on when placed on top of the wireless charger.

 

Power distribution

 

Slide2.png

 

The main power supply is a beefy 12V one. It is used to power the stepper motors via the Gertbot and the LCD screen via the controller board. The other components of the project require 5V, which is achieved using DC-DC converters. The 12V input to the desktop components (Raspberry Pi 2 & LCD controller) are interrupted by a relay which is controlled by the Raspberry Pi B+. Two channels have been foreseen, although only one is currently in use.

 

Code

 

All of the different components illustrated above require some code to work.

 

To get the NeoPixels and Gertbot to work, external Python libraries were used. Here are the links:

 

 

Two scripts are in charge of combining the different features and make everything work together. The full code is available on GitHub.

 

PiDesk Main Script:

 

PiDesk LED Animations Script:

 

Demo

 

Finally, the "moment supreme", the moment you (may) have been waiting for, the final result.

IMG_7234.jpgIMG_7236.jpg

 

Because it wouldn't be a real demo without an actual video, here it is. The first part is a montage of various stages of the build, followed by some demonstrations.

 

 

Thank you

 

I'd like to thank element14, the sponsors, the judges and anyone involved in this challenge for setting this up, providing the kits and allowing me to participate. I had fun, I hope you did too following this project and you like the end result.

 

To my fellow contestants and members: thank you for following the project, liking the posts and providing feedback along the way.

Previous posts for this project:

 

 

Project Update

 

Problem!

 

I was testing the combination of audio and light effects today, only to find out that they are affecting each other!

 

Playing audio messes up the animations and the LED strip starts blinking randomly. There is also a nasty jitter in the audio output. I don't know the exact cause of the problem, I just hope it won't affect anything else ... There's a video at the bottom of this post, demonstrating the problem.

 

Solution?

 

The current workaround involves a USB sound card. It's a super cheap, low quality sound card I got from eBay for about $2, which I had around. The device is plug an play, and all that is required is to specify it as the output device when playing out sound files.

photo 4.JPG

 

Listing the device, ensuring it is detected properly:

 

pi@PiDesk ~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0



 

It is the last one in the list, card 1, device 0. These are the two parameters required when playing out, using the "-D" option:

 

pi@PiDesk ~ $ aplay -D hw:1,0 example.wav
Playing WAVE 'example.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo



 

The workaround is not that nice, but due to the time constraints, I'll stick with that for now. Another disadvantage of this solution is that it requires an extra USB port on the Pi. As I was planning on using the A+ (with a single USB port), I'll either have to use a USB splitter or move to the B+.

 

Anyway, problem solved for now, let's hope no other surprises pop up ...

 

Video

 

A short video demonstrating the problem using the onboard audio, and the solution with USB audio.

 

Previous posts for this project:

 

 

Project Update

 

With the challenge coming to an end soon, so must my futuristic desk.

 

I've worked on the following things this week:

  • paint screen assembly
  • install screen and Pi 2
  • attach LED strip to desk with diffuser
  • install wireless charging base for magic lamp
  • test code for lift and LED strip

 

I'm nearly there! I still need to cover the desk's surface with a sheet of white acrylic, hiding all the guts of the desk and giving a clean finished look. Once the code is finalised, test everything and prepare for final demonstration.

 

To summarise, the remaining to-do's are:

  • place acrylic surface
  • connect capacitive touch control to Pi
  • finalise power management
  • finalise code
  • test, test, test
  • make video and post for final demo

 

Here are some pictures of the current state of the desk, hope you like it

 

photo 1.JPGphoto 2.JPG

photo 3.JPGphoto (28).JPG

Previous posts for this project:

 

 

Project Update

 

It's been a busy week for me, not so much for the desk though. First, I went on holiday with my wife and kids to the belgian coast for the week, and I closed the weekend by introducing a visitor from New Zealand to belgian beers and strolling through Brussels together with another belgian member. First one to guess both members gets 10 points. (No real points, no prize can be claimed!)

 

Anyway, back on topic ... there have been little bits of progress on the desk. Let's go over them ...

 

Touch controls

 

The conductive pads and tracks have been laid out on the desk. All that is left to do is to hook them up to the prototyping board I made last time and hope they work as expected!

I started off by laying out the copper tracks and then drew the shapes of the contact pads using a drinking glass and a marker. Afterwards, I carefully painted the pads using conductive paint.

photo 1.JPGphoto 2.JPG

 

Power distribution

 

To simplify things, I'd like to power the entire setup from a single power supply. The two voltages required are 5V (Pi, LED strip) and 12V (Stepper motors, laptop screen), so I plan to use a single 12V power supply and have a converter to step it down to 5V for the components that require it. This also means that different splitters are required to ensure every device gets powered.

photo 3.JPG

 

Motors and endstops

 

I've mounted the motors at the bottom of the frame using some MakerBeam pieces I had around. With my printer still giving me headaches, I ended up taking a piece of wood, drilling holes for the threaded rods to fit through and make a larger hole on the bottom side holding the two captive nuts. First tests indicate the stepper motors have no trouble handling the weight and can lift the screen assembly as expected. I'll try to get a video out for this in the coming days.

 

The endstops have been installed on the side of the frame, the first one triggering when the screen is lowered flush with the desk, the other one when it's been raised enough. You can see both switches on the picture in the next paragraph.

photo (25).JPG

 

Cable management

 

Another thing I managed to do, is some basic cable management, ensuring the wires of the motors and endstops are tucked away neatly. I used a plastic cable guide for that, which I attached on the side of the screen's frame.

photo (26).JPG

 

Python

 

Finally, I started merging the different bits of code I created over the course of the challenge, combining all the different features like sound effects, neopixel control, capacitive touch, etc ... I haven't been able to test it yet, that's planned for next week. If everything ends up working as expected, I can start finalising the build and get testing and tweaking. I'm not using a particular IDE for this, as I've found the Sublime text editor to do the necessary syntax highlighting and completion.

Screen Shot 2015-08-09 at 22.00.44.png

 

Introduction

IMG_7050.jpg

 

In a previous guide, I covered how to control stepper motors using Gertbot. For this post, I'd like to cover the built-in endstop functionality.

 

Endstops (also know as "limit switches") can be very useful to stop motors when an end position has been reached. This is for example the case with 3D printers or CNC milling machines where the motors controlling each axis, back up until the endstops are triggered. This defines a reference point, also called "home position" with coordinates 0,0,0.

 

There are different types of endstops, just to name a few:

  • mechanical: an ordinary switch makes or cuts a connection when triggered
  • magnetic: a hall-effect sensor is used to measure the magnetic field
  • optical: a sensor reacts to sudden changes in light levels

 

For this guide, I'll be using mechanical endstops, such as the one on the right.

 

Gertbot

 

The Gertbot add-on board for the Raspberry Pi offers the possibility to activate endstops, which when triggered, will automatically stop the associated motors without having to code any additional functions.

 

Pins

 

Four pairs of endstops can be defined: one pair per motor channel, covering two extremities. Seen from the top of the Gertbot, the endstop pairs are positioned as such:

photo (24).JPG

 

The endstop pins are connected to 3.3V using a 4.7kOhm pull-up resistor.

 

Modes

 

The endstops can be configured in three different modes:

  • OFF (0): don't enable the endstops
  • ENDSTOP_LOW (1): enable endstop, stop motor channel when switch to GND is closed and pin is LOW
  • ENDSTOP_HIGH (2): enable endstop, stop motor channel when switch to GND is open and pin is HIGH

 

When using endstops, the safest option is to use the ENDSTOP_HIGH mode, as a broken endstop wire would result in the motor channel to be disabled, ensuring the safest state.

 

Code

 

Activating endstops for a single motor channel is straightforward:

 

// gb.set_endstop(BOARD, CHANNEL, ENDSTOP_A_MODE, ENDSTOP_B_MODE)
// Configure first board's first motor channel with two endstops, triggered with the pin is HIGH
gb.set_endstop(0, 0, 2, 2) // board 0, channel A, endstops A & B in ENDSTOP_HIGH mode





 

Multiple endstop pins can also be hooked up to the same switch. For example if two servo motors are used, with motor #1 on channels A & B and motor #2 on channels C & D, the setup would be as follows:

 

// gb.set_endstop(BOARD, CHANNEL, ENDSTOP_A_MODE, ENDSTOP_B_MODE)
// Configure first board's first motor channel with two endstops, triggered with the pin is LOW
gb.set_endstop(0, 0, 1, 1) // board 0, channel A, endstops A & B in ENDSTOP_LOW mode
gb.set_endstop(0, 2, 1, 1) // board 0, channel C, endstops A & B in ENDSTOP_LOW mode





 

Demo

 

Here's an animation of an endstop being triggered, resulting in the motors to stop. (You may have to click the image)

endstop.gif

 

Conclusion

 

This is a very useful feature of the Gertbot, as the endstop functionality only needs to be activated and works independently from that moment on, without requiring specific code to manage them.

Previous posts for this project:

 

 

Project Update

 

I was having so much fun playing with the Beaglebone Black and TI SensorTag that I almost forgot to write this update!

 

Anyway, got some sliders to mount the screen to and made a (rather bulky, but strong) frame to mount to the desk and hold everything in place. The next step will be to add the stepper motors and limit switches to automate the lift. My 3D printer is still acting up, so I'll probably end up making the piece manually. Don't worry, I have a plan ...

 

Here's a short video showing some assembly stages and testing the sliders manually.

 

Previous posts for this project:

 

 

Project Update

 

For this week's update, I worked on bringing the different components of the desk controls in a smaller and less messy form.

 

Making use of a prototyping board, the breakout boards I used and some stackable headers, the result is rather compact. As you'll see, I replaced the B+ for an A+, and the WiPi for a smaller wifi dongle.

 

Enjoy the gallery

 

{gallery} PiDesk

photo 1.JPG

Prototyping board: Started from a prototyping board for Raspberry Pi, combined with Arduino stackable headers

photo 2.JPG

Headers: Not having other stackable headers at my disposal, I used a combination of 1x6 and 1x8 stackable Arduino headers to create a 2x20 header

photo 3.JPG

Test: Testing the headers before soldering them on. Fitting the headers required some sanding on the sides.

photo 4.JPG

Capacitive touch: desoldered the headers on the breakout board to fit new, straight ones.

photo 5.JPG

Boards: The Pi and two add-on boards providing all the necessary features for the desk controls.

photo 11.JPG

RPi A+: In charge of providing wifi connectivity via USB and control add-on boards via GPIO pins.

photo 10.JPG

Proto board: In charge of capacitive touch controls, NeoPixels and audio amplification. Still requires actual soldering of the breakout boards.

photo 9.JPG

Gertbot: In charge of stepper motors and end stops (limit switches).

photo 6.JPG

Stack: The stacked result, providing the full solution.

photo 8.JPG

Stack: The stacked result, providing the full solution.

Previous posts for this project:

 

 

Project Update

 

I started working on the lift assembly this week. After figuring out how to mount everything to the desk, I designed a piece meant to hold the screen and attach it to two threaded rods capable of lifting it.

 

The piece was designed in Sketchup after I had measured the size of the nuts used on the threaded rods and the width of the screen assembly. This is the result:

Screen Shot 2015-07-08 at 10.55.38.pngScreen Shot 2015-07-08 at 10.55.54.png

 

There are two slots to pass the threaded rods through and to keep the nuts in place, and four holes meant to screw the piece to the bottom of the screen assembly. By having the nuts locked in place, turning the rods using a stepper motor will result in the assembly going up or down.

 

The next step was to print the piece. Something I expected would go rather smoothly ... I was wrong. Everything that could go wrong, did go wrong:

 

1) Slipping: one of the timing belts (X-axis) started slipping, resulting in inconsistent results. Perhaps the result of the high summer temperatures resulting in looser belts ?

2) Running out of filament. Annoying, but luckily, I had a spare roll. Prints will no longer be white, but light blue now!

3) Nozzle clogging. Due to incorrect bed levelling. I placed the nozzle to close to the build platform, not allowing enough material out of the nozzle. Fixed by levelling more accurately.

 

photo 1.JPGphoto 2.JPG

 

I hope I can resolve the slipping issue as soon as possible, so I can print te piece and start putting together the lift assembly! And even though the print failed, I was able to validate most of the measurements based on the first layer.

Previous posts for this project:

 

 

Project Update

photo (19).JPG

 

Part of the kit we received is the Cirrus Logic Audio Card. It is an expansion board for the Raspberry Pi, that adds audio output and input with various types of connectors. I will however not end up using it in my project for the following reasons:

 

1) I originally planned to use it for the Pi2, used as a desktop computer. From what I understood from this discussion though, is that it is not yet supported on the Pi2 due to incompatible kernel versions. Users have come up with a minimalistic software image capable of using the card on the Pi 2, but it is not suited to be used as a desktop image.

 

2) The second Pi I'm using, the A+ to manage the desk controls, is compatible with the card and the software is available. The card would however be overkill, as the only audio function required is to play sounds when certain buttons are pressed. Taking into account the low cost requirements of the project, the audio card has been deemed unsuitable.

 

I searched for a cheap alternative to get amplified audio output from both Pis and came across the Adafruit breakout boards. There are two boards that seemed affordable and suitable for my project:

 

The mono amplifier would be used for the desk's special effects sounds, the stereo one for the Pi2 desktop computer.

 

photo (20).JPG

To hook everything together, I made a custom stereo cable with female headers capable of connecting to the breakout board's male headers. Power for the breakout board is taken from the Pi's GPIO pins. And finally, the connectors for the speakers were stripped off, and the wires connected in the breakout board's screw terminals. The same process is valid for the mono and stereo breakout boards, except for the fact the the mono breakout board only supports one speakers (obviously ...).

 

As a test, I put one of the sound effect MP3s on the Pi and played it out with following command:

 

pi@PiDesk ~ $ omxplayer -o local example.mp3
Audio codec mp3 channels 1 samplerate 22050 bitspersample 16
Subtitle count: 0, state: off, index: 1, delay: 0
have a nice day 



 

The solution for both Pis combined is still cheaper than one audio card, and is compatible with any model or revision Pi.

Previous posts for this project:

 

 

Project Update

 

The sun was shining and I had some time to myself, ideal conditions to start cutting things and annoy the neighbours with the sound of powertools. I started working on the enclosure that will hold the computer that will slide in and out of the desk. Because the dimensions were beyond what my CNC can handle, everything was done by hand and I finally gave the router a try. I messed up here and there, but the result so far is more than acceptable

 

Check out the picture gallery below to get an idea of the work that was done.

 

{gallery} Screen Enclosure

photo 1.JPG

Two pieces: I cut out two pieces with the same dimensions out of a larger MDF board. The screen and Pi 2 wii be contained in between the two layers.

photo 2.JPG

Dimensions: A cutout will be made for the usable part of the screen, grooves will be made to have the screen held in place.

photo 3.JPG

Cutting: Using the same oscillating multitool as I used to cut the desk, I cut out the rectangle for the screen.

photo 4.JPG

Pop: The cuts are very slim and straight enough for something done by hand. The piece popped out easily.

photo 5.JPG

Guide: Using clamps and a spare piece of MDF, I made a guide for the router.

photo 1.JPG

First time: My first time using the router, ever! Slipped away from the guide a few times, but no problem.

photo 2.JPG

Smoother: The second side went a lot smoother as you can see from the picture above.

photo 3.JPG

It fits: With the grooves routed on all four sides, the screen fits nicely.

photo 4.JPG

Front: View from the front with screen inserted. As you can see, I messed up on one of the sides when the router cut too deep.

photo 3.JPG

Fixed: Managed to fix the mistake from earlier using some wood filler. I'll be applying the same method to the corners to fix the cuts.

Previous posts for this project:

 

 

Project Update

 

How about a Sci Fi Your Pi / Enchanted Objects cross-over post for a change ?

 

Let me introduce the Magic Lamp! What's special about it, is that it is turned on or off depending on where you place it on the desk! It also creates colourful effects on walls and ceiling when turned on. An Adafruit Trinket and NeoPixel Ring are powered wirelessly by having the charging base hidden inside the desk's surface. By moving the circuit above the base, the Trinket is powered on and animates the NeoPixels.

 

For details on the build, check out this post: Sci Fi Your Pi: PiDesk - Guide: Magic Lamp with wireless charger, Adafruit Trinket & NeoPixels

 

lamp.JPG

Concept

 

The idea for this little project is to have a lamp which can be turned on or off simply by moving it on a desk.

 

A wireless charging base is built into the desk's surface, and a circuit with microcontroller and LEDs gets powered wirelessly using the charging coil.

 

Components & Circuit


Screen Shot 2015-06-19 at 21.14.48.png

The electronic components used in this project are the following:


The Qi Wireless Charger was bought on eBay for a couple of euros. According to the specs, it is capable of outputting 5V/1A, which should be more than sufficient for this simple circuit.Connecting everything together is simple:

  • the coil's positive terminal is connected to the Trinket & NeoPixel USB+/PWR pins
  • the coil's negative terminal is connected to the Trinket & NeoPixel GND pins
  • the Trinket's #0 pin is connected to the NeoPixel IN pin

 

Program & Testing


The Trinket is programmed using the Arduino IDE in order to animate the NeoPixel Ring. But before this can be done, the necessary libraries need to be installed.Adafruit already has excellent tutorials covering this on their learning system:

 

Once the hardware is supported and the library installed, it is possible to program the Trinket. An example program is provided with the NeoPixel library, called "strandtest". This sketch cycles through different animations and colors and is perfect to understand how the NeoPixel Ring is being animated.

 

Below are some animated gifs (you may need to click to see the animation) showing a quick tests with the wireless charger first and then with the Trinket and NeoPixel Ring.

 

2015-06-21 19_34_10.gif2015-06-21 19_33_26.gif

 

Assembly & Demo

 

To hold the electronics, a simple housing is required. This can be done using a readily available container or can be custom created using cardboard, plastic, or even using 3D printing. I opted for the latter and created a simple hollow cylinder just big enough to hold all the parts. The wireless charger coil is at the bottom and the NeoPixel Ring at the top. I'm also using a crystal ball on top of the circuit to diffuse the light.

 

photo 1.JPGphoto 4.JPG

 

I hid the wireless charger base in the desk's surface, under my cutting mat. When the circuit is placed above the charger, it lights up without requiring a wired power source. Magic.

 

photo 5.JPGphoto 4.JPG

 

Because of the crystal ball sitting on top the NeoPixel Ring, some effects are also reflected on the ceiling, gradually changing color.

 

Video

 

The video below provides an overview from start to completion, to end with a demo of the magic lamp.

 

 

 

 

Previous posts for this project:

 

 

Project Update

photo 2.JPG

Project Update #10 already and only one week away from the challenge's halfway point. Time to kick things in a higher gear. That's why I've done something slightly more technical for this week's update: I've created my own capacitive touch breakout board!

 

As you may have seen over the course of the project, I've been using the Touch Board as a capacitive touch input sensor for the Raspberry Pi. I used it because I had one and thought it was the perfect opportunity to use it, since I never had (like many other boards I own ...). Unfortunately, for others trying to recreate (parts of) this project, it is an expensive investment at about €76 (post-kickstarter). That's why I set on a quest to reduce the cost of that component and ended up succeeding with a cost reduction in the range of 95%!

 

I've used the Atmel AT42QT1070 touch sensor ICAtmel AT42QT1070 touch sensor IC on a custom-made breakout board to convert up to five of the Pi's GPIO pins into capacitive touch inputs. The cool thing about this little breakout board is that it could be used in combination with other SBCs or microcontroller boards! The board was designed in Eagle and produced via SeeedStudio for €10 including shipping, for 10 boards (I did receive 20 though ...).

 

For more details and a demo, check out this post: Sci Fi Your Pi: PiDesk - Guide: Capacitive Touch with Atmel's AT42QT1070 Touch Sensor IC

 

Rather than using an out-of-the-box capacitive touch solution for my projects, I thought I'd attempt making my own little breakout board. The idea is to use a sensor capable of triggering normal digital input pins using touch.

This post covers the selected touch sensor IC, the circuit used, getting a custom PCB made and how to use it in a project. At the end of this post, you'll find a video covering the soldering and a brief demo of the custom board.

 

Touch Sensor IC

 

While searching for capacitive touch solutions, I quickly came across two different ICs: the Freescale MPR121 (as used in the Touch Board) and the Atmel AT42QT10XX. The MPR121 comes in a QFN package, immediately making it more difficult to use. It has up to 12 inputs and an I2C interface. It can operate from 1.7 to 3.6V making it slightly more difficult to work with when using a 5V host.

 

Comparing the specs of the MPR121 with the AT42QT10XX IC, I decided to pick the latter.

 

Atmel AT42QT1070

 

Some of the features worth mentioning are:

  • SOIC14 package
  • up to seven inputs
  • fully debounced outputs
  • suppresses effects of external noise
  • touch sensing using single pin
  • different operation modes (see next paragraph)

 

According to the datasheet, the keys can also be operated behing panels of glass (up to 10mm thick) or plastic (5mm).

 

And finally, because it can operate at voltages from 1.8V to 5.5V, it can be used in combination with a wide variety of boards, such as Arduino (5V logic level) or Raspberry Pi (3.3V logic).

 

Operating modes

 

There are two modes the touch sensor IC can operate in:

  • comms mode
  • standalone mode

 

In comms mode, the sensor can have up to seven input keys and interfaces with a master microcontroller or SBC via I2C. The I2C interface can for example also be used to configure sensitivity of the different input keys. A typical connection diagram for comms mode is the following (as provided in the datasheet):

Screen Shot 2015-06-14 at 15.06.29.png

 

The other mode, standalone mode, does not make use of the I2C interface but rather converts up to five capacitive touch inputs into digital outputs. This is useful to convert digital inputs on a microcontroller board or SBC into capacitive touch inputs. Because the I2C interface is not used, sensitivity of the touch inputs cannot be configured and is static. The connection diagram for standalone mode is the following:

Screen Shot 2015-06-14 at 15.15.31.png

 

Different versions

 

Depending on the application's required number of inputs, different ICs of the same family can be used.

 

Just to name a few:

  • AT42QT1010: single channel
  • AT42QT1040: four channels
  • AT42QT1111: eleven channels

 

A full list can be found here: Dedicated Touch Devices

 

Schematic and Board

 

I chose to make a breakout board for the standalone mode. The circuit is simple as it only involves the touch IC, a couple of resistors and a capacitor. It was a bit trickier to fit everything in the smallest form factor possible, but that worked out well as you can see below.

 

The schematic and board were created using Eagle and the AT42QT1070 component was downloaded from the Farnell page of the part (AT42QT1070-SSU - ATMEL - SENSOR, QTOUCH, 7-KEY, 14SOIC | Farnell element14).

Screen Shot 2015-04-07 at 16.03.00.pngScreen Shot 2015-04-07 at 16.01.48.png

This is only a first version. I'll be releasing the files after some possible improvements, such as:

  • including pull-up resistors for the input pins rather than relying on the attached microcontroller board/SBC using internal pull-ups
  • LED indicators to show which input is active, as this may be useful for easy troubleshooting

 

 

PCB

 

To get the PCB done, I used SeeedStudio. The service is cheap, at about $12 for 10 boards, including shipping. The only downside is perhaps the fact that it takes two weeks between ordering and receiving the boards. While waiting for the PCB to arrive, I ordered the parts so I could populate the board once it got here. I purchased the AT42QT1070AT42QT1070 from Farnell, the other bits I had available.

 

Once all the pieces were available, I took out the soldering paste, heated the pre-heater and hot air rework station, laid out the components on the board and reflowed the solder. The result can be witnessed in the pictures below. To see the whole process, be sure to watch the video at the end of this post.

photo 2.JPGphoto 1.JPG

 

Before hooking up the board to something else, I used my multimeter to check all the connections were correct and no shorts were introduced while soldering.

 

Code

 

For testing, I decided to used the breakout board in combination with a Raspberry Pi. The board was powered using the Raspberry Pi's 3.3V and GND pins. The touch sensor's first output was connected to the Pi's GPIO17 and the sensor's first input to a jumper wire.

 

Using the code below, GPIO17 is configured with internal pull-up resistor and is pulled low when the sensor's first input is touched.

 

import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(17,GPIO.IN,pull_up_down=GPIO.PUD_UP)

#initialise a previous input variable to 1 (assume button not pressed last)
prev_input = 1
while True:
  #take a reading
  input = GPIO.input(17)
  #if the last reading was high and this one low, print
  if ((not input) and prev_input):
    print("Button pressed")
  #update previous input
  prev_input = input
  #slight pause to debounce
  time.sleep(0.05)


























 

The code can easily be extended to support all five inputs, as long as the GPIO pins are configured with internal pull-up.

 

Video

 

In the video below, you can see me populating and soldering the custom PCB, followed by a little demo of the board used with a Raspberry Pi.

 

Previous posts for this project:

 

 

Project Update

 

Ikea desk meets multitool. There's not much more to say about it, enjoy the picture gallery and be sure to check the description

 

Hope you like the result so far!

 

{gallery} Ikea desk meets multitool

photo 1.JPG

Desk & Multitool: The desk I picked for the project and the multitool I planned on using to carve out futuristic shapes with.

photo 1.JPG

Sketch: Sketched where the different components like Pi, buttons and futuristic shape for LED strip would be.

photo 2.JPG

Tape: Used tape to better visualise the shapes and serve as reference when cutting.

photo 3.JPG

Internals: That's what the inside of a cheap Ikea desk looks like. A block in each corner to screw the legs to and a cardboard mesh for the rest.

photo 4.JPG

Cutting: Cutting using the multitool was rather easy, but tricky at times where the blade was larger than the shape to cut out.

photo 5.JPG

Done: Most of the cutting work done, waiting for the final dimensions of the screen before cutting out that part.

photo 4.JPG

Test: A quick test to fit the Pi and LED strip and have a look at the result. Once the final LED strip arrives, it can be installed. In the mean time, I'll be testing various diffusors.