Sunday, September 25, 2016

IKEA Motion Lamp Hack Update

Back at it again, I decided to add a few more features before I deem this project complete and ready to be put into service. In case your are wondering, this is based on my previous work on the IKEA Motion LED Lamp Hack. This time around I just wanted to make a few hardware changes that will let me have full control of the light.

IKEA Motion Lamp Resistor Modification

Monday, September 12, 2016

USB HUB + WiFi Teardown

One day I come across an interesting product from Adafruit that I couldn't resist getting. It will make a nice addition to the Raspberry Pi Zero. It's a 3 port USB hub with inbuilt WiFi which takes the fourth port. Inspired by insideGadgets, here are some photos and part numbers.

USB WiFi Hub
Wish it was a bit more compact. I have a USB to OTG adapter in the USB plug.

USB WiFi Hub Inside

USB WiFi Hub PCB Top
Main Components
  • USB HUB - Terminus FE 1.1s
  • 3.3V Regulator - AMS1117
  • WiFi - Realtek RTL8188ETV

USB Wifi Hub IC
USB Wifi Hub WiFI
USB WiFi Hub PCB Bottom

Interesting thing to note is the fourth USB port footprint, this PCB can support the WiFi module or fourth USB port. Overall it is a simple design that would be easy to embed in another project without the housing.

Saturday, September 10, 2016

IKEA Motion Lamp Hack


Last year while visiting a friend for the Portland Mini Maker Fair I became the owner of an IKEA STÖTTA, a battery powered, motion activated, LED lamp. I knew it was ripe for hacking. After arriving home, it sat on my desk waiting to be disassembled to reveal its secrets. I figured the only way to get it off my desk was to get around to tearing it apart and seeing what I could do with it. Over the weekend I spent more time trying to decide which direction to take since there are plenty of features I could add. At least I can get something going now and add to it later. Who ever said a project had to be completed?

IKEA LED Light PCB Close Up

The lamp consists of a small PCB which contains the following main parts;
  • HS8A005 (BISS0001 Motion Detection IC)
  • PIR Sensor
  • LED Driver (Inductor and IC, powered by battery VCC and outputs 3V)
  • 3.3V Regulator
  • Voltage Detector (Disables trigger on low battery)
IKEA Light PCB Labeled

Thursday, September 8, 2016

Mooltipass

A year and a half ago I helped support the Mooltipass on Indiegogo. I originally heard about it on Hackaday.com, but what really captured my attention other than it being an offline password manager, is that it was going to be designed by the the community. Anyone could volunteer time to help with the project. Unfortunately I was unable to do so with the many other things I had going on. But at least I could support the project by backing it.



The Mooltipass is a USB encrypted (AES256) credential storage device that acts like an HID keyboard. It can be used with or without the Chrome app and the extension. The extension allows it to detect which site you are on and load that credential after an approval from the on board display, as well as manage the device settings and credential database. The goal of the Mooltipass is to minimize the possible attack vectors on your stored passwords. I use LastPass which has a larger attack surface and offers greater convenience, so for the time being, I am using both systems. Security for the Mooltipass is accomplished by being a physical device as well as having a removable smart card. Without the smart card and pin number, you cannot access the credentials even if you have the backed up binary blob. There is also a permanent lockout after three failed attempts of entering the pin. Which I find a bit short since with the touch buttons it is easy to mess up. I should also mention that the pin isn't limited to 0-9; it has used all of the possible hex values, 0-9, A-F. Pretty neat!

Since the Mooltipass is a physical device pretending to be a keyboard, it will work with sites in which the login form isn't detectable, such as a Flash based web app, which is another great feature. This is accomplished by using the onscreen display to send the credentials. An unintended use that I found is that is greatly reduces keystrokes for non web based logins which is helpful for people like myself who have tendentious.  I realized with the Mooltipass how many times a day I am entering in my credentials.

Monday, August 29, 2016

Living Room Node Upgrade

For over a year now the living room node and La Crosse Gateway has been sitting atop a plastic bin next to my patio slider in a mess of wires.  This is when you know you have too many projects lying around the house.  So this summer I decided to design a PCB with a nodeMCU that will replace both projects and mount atop of a power brick. I went with the nodeMCU since there is power nearby, ease of connecting directly to the MQTT broker, and I can broadcast more often without the power limitations of a battery. This project frees up two RFM12B boards so that they can be used for the other window and the front door.


Living room slider node and La Crosse gateway

Sunday, August 21, 2016

PCB Battery Clip

Just a small update to the battery powered nodes. Until now I had used a piece of tape to hold the PCB to the battery pack. It was always a pain when changing the batteries or accidentally hitting the node and watching it fall apart. I also wanted to try my hand at Fusion 360, so this seemed like the perfect opportunity.

Fusion 360 sketch of PCB battery holder clip

I still have a lot to learn in using Fusion 360 but I got the job done, um sort of. I had issues extruding the width less than I had initially and I didn't want to start over. So canceling the print worked good enough at the size I wanted.

Fusion 360 model of PCB battery holder clip

It came out quite nice. I just need to learn Fusion 360 properly.

PCB battery holder in action


Wednesday, June 22, 2016

C.H.I.P. by Next Thing Co


After a year of waiting it has arrived: the $9 computer from Next Thing Co. When it launched on Kickstarter, there was no reason to skip backing this one to at least see what it was all about. Now that it has arrived I am quite happy that I did. For such a large project it would hardly be worth calling it late. My reward was due May 2016 and I received it June 2016. Very good compared to most crowd sourcing campaigns. I selected the C.H.I.P. plus battery reward, but before it shipped you could add accessories. I added the VGA adapter and an extra C.H.I.P. That way I can use it on my desk attached to my monitor since the DVI input is already in use. With the Raspberry Pi I have to connect it to the TV if I want to mess with it directly. At this price it's cheap enough to buy more than one that you can dedicate to a project and just fuggedaboutit.

$9 C.H.I.P. and accessories


Monday, June 20, 2016

nodeLED

As a hacker, I know all too well how much workbench space is vital. Alongside my three monitors, I have an extended desk that houses my soldering irons, compartment shelving, and countless projects, among other tools and devices. One constant that seems to get in my way is an old desk lamp. That’s where this project came to light, ha! I decided to design my own lamp using an analog RGBW LED strip. This board I designed will give you the tools to design your own WiFi controlled light source.



The boards' controller is run by the NodeMCU which is connected to an N-Channel MOSFET for each color of the RGBW LED strip. Trimpot for brightness and two user buttons (that can be setup to change modes, possibly) were also added. A 5v regulator was then added so the power can be shared with 9-12v input for the LED strip. The nodeMCU will be updated by wireless as well.




My idea is to have the nodeMCU be a web server for direct control via a web page. The site will have various configurations including color options, number of channels, animations (like fade effects) and a timer. I’d like to have it connect to MQTT server to integrate with larger servers such as openHAB.

You can follow the details of the project on Hackaday.io

https://hackaday.io/project/11521-nodeled

Sunday, June 19, 2016

JeeNode to MQTT Gateway

It's been a few months since I have worked on openHAB but that is mostly due to focusing on FriedCircuits, Hackaday Prize and the Maker Faire. Not a dull moment around here! I finally sat down while watching some tube (or rather crystals) to start work on the JeeNode to MQTT gateway. Up to this point if you have read my other posts I have still relied on DomotiGA to get the JeeNode data into openHAB. This is because DomotiGA has support for JeeNodes. I noticed the sensor nodes weren't checking in again which usually is because DomotiGA is not running, this time I think it just needed a restart plus one node actually needs batteries. This prompted me to finally get around to writing the gateway. Once complete I won't need DomotiGA and the desktop UI so I can use Ubuntu server for my rebuild of openHAB.

After some research I was able to get receive the data over serial, split it and shift the bits into separate variables to publish over MQTT. Using the Paho MQTT python library it is trivial to connect and publish. I decided to map out it out as JeeNode/node#/name/value. Simple. I should mention this code is assuming the JeeNode is running the room node sketch or at least using the packet format. My remote nodes and receive node code is on Github if needed. Here is a graphical view of the tree for one node.

MQTT JeeNode Map

Thursday, June 9, 2016

Switchmate

Last year my friend and I backed the Switchmate on Indiegogo.  At the time I didn't have much of a home automation setup - just two window nodes and the slider.  Not even any connected bulbs and I was still on DomoitaGA so I didn't have any of the fancy rules I now have in openHAB.  Over the course of the campaign, they had different deals so I ended up with three rewards.  I had actually forgotten about them, in part because since switching to openHAB and getting connected light bulbs, the need for these switches seemed diminished.  But one day I was pleasantly surprised to receive a shipping notice.  A few days later I received the package in the mail and boy was I surprised!  The quality and presentation was excellent - not what I expected at all.  Curious about them?  Read on!



Sunday, April 24, 2016

Routing High Speed Signals and USB

Eventually in most hobbyists' path, one will end up working with high speed signals. These days so many microcontrollers support USB and even ones that don't can use software USB. Of course using a microcontroller is the answer to every engineering problem, right? Most of us just work with USB 2.0 connected directly to a microcontroller for uploading and serial communications. With advent of the USB Tester, I have learned more about USB than I ever thought I would. Recently I have dived into USB 3. Which compared to 2.0, is so much more sensitive to your PCB routing as I found through trial and error. I have seen many projects on the various blogs and for sale on the usual sites that don't follow or even try to route correctly. With USB 2.0 for the most part you can get away with it and it will still work. To help save you some time, I would like to share my findings that should help prevent PCB re-spins just due to USB not working. This is by no means an exhaustive guide to high speed routing as there are plenty of application notes across the web for that. I will list a few at the end of this post that I found helpful.

I am not by any means an expert on high speed signals, but I have learned enough to get the job done. In the end I was fortunate that my desktop PC had the first USB 3 controller made by Renasas which is much more sensitive than my laptop so I knew if it worked it would work for anyone. 

Diagram of USB Differential Pair (Wikipedia)


High speed signals use differential pairs instead of a single trace or a clock / data pair like I2C. By using a pair of traces you can cancel out noise. One is positive and the other negative. The idea is that electromagnetic interference would affect both signals and therefore would be canceled out since the receiving end looks at the difference of the two. Using a 2 channel oscilloscope you can connect to both signal and do a bit of math to see the resulting signal.

With USB 2.0 I was able to get away with branching (breaking out D+/D-). These are terms that you will come across with working with high speed signals. 
  • Branching is when the traces are not direct from one point to another and have a split.
  • Stubs is if the signal hits a via with a pin in it from the top layer instead of the bottom layer to from a straight path. 
USB 2.0 only uses 1 differential pair vs USB 3 which uses 2 for full duplex operation. If you are using the Type-C connector you have duplicates of each pair plus for reversibility and extra signals for detecting orientation and other signal types.

USB Type-C Pin Out (Credit someone on the internet)

Important things to consider while laying out your board. 
  • Calculate trace width and spacing to maintain 90Ohm differential (Calculator) This will also depend on the PCB you will be using. In my case OSHPark lists the specs of their PCB.
  • Maintain trace length of each pair. CAD tools have a differential pair routing tool along with meander to adjust traces for matching. A better way is to add a little length on the end of the short trace before connecting to your pad instead of having to meander which will affect the 90Ohm differential target. It can take a bit of time though to get it just right.
  • Use as few vias as possible as they affect signal integrity.
  • Route using 45degree angles instead of 90. I think this is to avoid reflections. 
  • Avoid stubs by using a via before routing to a through hole part so you are on the bottom layer. 
  • As much as possible, route above/below a continuous ground plane. On 2 layers boards this is pretty much impossible. With USB 3 it really should be a 4+ layer board. 
  • Signals should be on the outer layers. 
  • As always use the shortest path possible. (The Wozinack way ;))
  • Another one that may be hard to do is don't cross signals above or below another signal. Ideally there should be a ground plane there anyway. 
  • One way to avoid inverted pairs having to cross over each other is to mirror a part but then you have to deal with parts on both sides which may or may not be an issue for you. You should check with your assembly house if going that route. I have been able to reflow boards twice in this case. Surface tension usually keeps parts them from falling off. 
  • Remember that higher speed signals travel along the skin of the copper so surface area is your friend and reduces impedance and attenuation on the signal. (More info)
  • Type-C cable only has 1 pair of differential pairs for USB 2.0 on the A side of the connector. B is unconnected. So I believe that means you should tie A and B together or maybe there is a mux IC for USB 2.0.

USB 3 Differential Pairs Example


It seems a lot to take in for a hobbyist but after awhile it starts to make sense. PCBs are getting cheaper so if it doesn't work out you can keep trying different designs until it works. 

Here is my settings in Eagle CAD for a 2 layer board from OSHPark pictured above.

Eagle CAD Differential Trace Settings

Eagle CAD Length Settings

There is a minimum error in length but I always try to get it 100% matched.


Links I found during my research:
http://www.digikey.com/en/articles/techzone/2016/feb/usb-3-1-usb-type-c
https://www.fairchildsemi.com/application-notes/AN/AN-6103.pdf (PDF)
http://www.cablewholesale.com/cgi-bin/articlelink.cgi?article=SALES_ART_2015-03-30&key=653bc4866500468368db5e966ba1ea767ed58693&link=/support/technical_articles/introducing_10_gigabit_usb_31.php
http://www.edn.com/design/test-and-measurement/4438870/USB-3-1-testing-part-2--Type-C-cable-assemblies
http://www.cypress.com/file/151566/download
http://www.xmultiple.com/xwebsite-forum-USB-TypeC.htm (Good one with cable wiring)
https://en.wikipedia.org/wiki/USB_Type-C
https://www.element14.com/community/servlet/JiveServlet/previewBody/36206-102-2-218482/Introduction%20to%20USB%203.0%20Protocol.pdf (PDF)
https://www.synopsys.com/Company/Publications/DWTB/Pages/dwtb-convert-usb-design-type-c-2015q1.aspx
http://electronics.stackexchange.com/questions/125011/how-does-usb-type-c-handle-reverse-polarity
http://kevinzhengwork.blogspot.de/2014/09/usb-type-c-configuration-channel-cc-pin.html
http://www.mouser.com/publicrelations_techarticle_3cs_of_usb_2016final/
http://www.usb.org/developers/docs/hs_usb_pdg_r1_0.pdf (PDF)
http://electronics.stackexchange.com/questions/41851/how-critical-is-the-layout-of-usb-data-lines-how-does-my-layout-look
http://www.ti.com/lit/an/spraar7e/spraar7e.pdf (PDF)
http://www.belden.com/blog/broadcastav/understanding-skin-effect-and-frequency.cfm (Skin Effect)
http://www.appfruits.com/2015/03/building-your-own-custom-teensy/ (Links to calc)
http://www.multek.se/engelska/engineering/pcb-structures-2/differential-microstrip-impedance-calculator-2 (Calculator)

Monday, March 21, 2016

Quest for a Logic Analzyer

Since I started this adventure in hardware I have wanted to get an logic analyzer. I have an older but good oscilloscope that only goes so far when it comes to digital logic signals. I could go for the Saleae, but if I am going to do that I would rather sprint for the higher end model which is an easy $400+. In the mean time I was on a quest to find a low cost option. Upon my travels of the interwebs I found a few options. There's Dangerous Prototype's bus pirate (which I have) or their openbench logic. There are also the microcontroller options using, say, a Teensy or STM32. Then when I came across the BeagleLogic, it seemed like it fit what I had in mind. And actually, if I remember correctly, I saw it during the Hackaday Prize 2015. Funny how you end up somewhere on the Internet you've been before but have long forgotten.



The BeagleLogic is a logic analyzer based on the Beaglebone created by Kumar Abhishek, a semi-finalist of the Hackaday Prize Best Product 2015. What makes the BeagleLogic special is it uses the BeagleBone PRUs which are basically 200Mhz microcontrollers attached to the ARM CPU with shared memory. This is one thing that sets the BeagleBone apart from other SBCs. I have always been interested in the PRUs but they are a bit complicated and I've yet to have the time to investigate. I wish Ti would make an easy way to use them like Arduino did for microcontrollers. For me it's more of the lack of time to learn them when I have so much going on with other projects.


Features:

  • 100MSPS
  • 14 Channels (13,14 require you to disable eMMC)
  • 320MB Capture Buffer
  • 5V tolerant inputs
  • Web Interface
  • Capture interfaces from the BeagleBone itself
  • Opensource 

At the moment, you have to make your own BeagleLogic. There isn't a place to order it. In addition, you need your own Beaglebone. Hardware wise, all it provides is the ability to probe up to 5V. since the BeagleBone ADCs only accept 1.8V signals. The BeagleLogic is fairly simple to make with the help of OSHPark. With a bit of drag soldering it would be easy to hand solder as well. I opted to order a stencil from OSHStencils and use my re-flow oven just to make it look nice and professional.




OSHPark Shared Project: (Just click order now)
https://oshpark.com/shared_projects/PKPgfF7q

Bill of Materials:
https://docs.google.com/spreadsheets/d/12azxrOXTphC75ShBOmVUEJG1oJav0N1jhAYYi9JiIA4

Notes:
  • You don't need the EEPROM parts anymore but the footprints are on the PCB if needed.
  • The transistor BSS138 was out of stock on Digikey so I ordered samples from Fairchild. 
  • I did have some issues with the cape affecting the power on boot process. It's okay during a reset though. So you can't attach it till after you power up. 
Software is where the magic happens. There is a pre-made image for the BeagleBone with everything loaded and configured to use the BeagleLogic. It's a recent image based on Debian instead of the older Armstrong builds. The nice thing is that it doesn't flash the eMMC so you can leave your existing setup alone and just pop in the SD card when you need your logic analyzer. Which is another reason that makes it a good option. I can still use the BeagleBone hardware for other projects and not keep it collecting dust in between uses.



BeagleLogic is setup to be used in two ways. One is the web based interface. Just power it up and fire up your web browser. You can use the USB NIC which will put the BeagleBone at 192.168.7.2:4000 or plug in the on-board Ethernet or even use WiFi with a USB dongle. Plenty of options for connecting to it.


There aren't many options in the web interface but it's a great start to be expanded. In my case I couldn't get the "Dump Raw Data" option to work, unless it saves to the BeagleBone and it's not downloaded via the browser which is what I was expecting. If you have a I2C bus that only talks a few times a second, it can be challenging to find the data just by scrolling. There is software triggering but you can't use it via the web interface. You can by means of the command line, which is the second way to capture your data.

The command line tools are provided by the Sigrok software suite. The output file can be exported to the desktop app, PulseView to do protocol decoding.

First you have to capture from the command line and specify how you want to trigger, which channels and the sample rate / sample limit.

Example:
debian@beaglebone:~$ sigrok-cli -d beaglelogic -c samplerate=5m -o outputfile.sr -C P8_45,P8_46 --samples=10000 -t P8_45=e,P8_45=e

Using WinSCP on Windows you can copy the output file to your desktop and open it with PulseView. The PulseView binary for various operating systems are available.


From this point, select the protocol using the last icon on the toolbar. Finally just click the protocol tab to configure it. (This took a bit to figure out.) Select the pins that map to clock and data in this case.


If you need to, look at timing use the cursors tool.




The BeagleLogic is a great inexpensive logic analyzer especially if you have a BeagleBone laying around collecting dust as I did. (It was supposed to eventually be for a robot project but now I want to use the new BeagleBone Blue.) The BeagleLogic has a lot of potential to be a full feature tool. One big thing that is missing is the ability to connect to it directly form the host without having to copy a file each time. I haven't tried running PulseView directly on the BeagleBone then using VNC to connect. Even as is, it's a useful tool and a good place to start if you have never used a logic analyzer. Be sure to visit Kumar's blog http://theembeddedkitchen.net/ There is a lot of good info - especially on PRUs. I had actually came across it researching some STM32 SDIO stuff earlier this year.


Due to the nature of OSHPark, I have two extra fully assembled. If anyone is interested in them please send me an email. william at blog domain.

Here are some other links with more info on BeagleLogic and Sigrok.
https://github.com/abhishek-kakkar/BeagleLogic/wiki/Using-BeagleLogic:-Post-processing
https://github.com/abhishek-kakkar/BeagleLogic
http://beta.beaglelogic.net/use-beaglelogic/
https://sigrok.org/wiki/Supported_hardware
https://hackaday.io/project/4395-beaglelogic
http://hackaday.com/2015/02/19/turn-your-beagleboneblack-in-to-a-14-channel-100msps-logic-analyzer/


Correction: The BeagleLogic doesn't need the ADC's but the BeagleBone GPIO's are only 3.3V