Homeautomation: programmable Buttons from the junkcontainer #2

Last evening I finished the case, electronics and software for the buttons.

I didn’t want to make my own pcb just for 9 buttons, so it was time for some reverse-engineering. Sure it’s nothing fancy, because the buttons are connected in a simple matrix.

To poll the button states I just needed 6 wires (the other jumper wires have already been there for the LEDs).

To control the LEDs too, I added some more wires.

The button pcb fits snugly in the 3D printed case. The white part is a cancelled print from the Makerbot. The orange case has been printed on our Prusa i3. I glued both parts together with superglue. As it turned out later, the case has the perfect depth for the electronics, without the cancelled print glued on, there wouldn’t have been enough space for the electronics.

As CAN module I am using a cheap MCP2515 CAN Module you can get very cheap from eBay. I just glued it to an Arduino Nano.

This DC-DC converter is configured to output 5V for the Arduino Nano. I removed the trimpot to save some space.

Next thing to design was a mounting plate. I didn’t want to print one, because it was late and I didn’t want to wait for a print to finish. So I just used our laser-cutter to cut the plates shown below. The left one is used as mounting-plate for the electronics and prevents short-circuits on the button pcb. The right one carries four M3 nuts so it can be screwed onto the case and also onto a wall or something else (in my case a bed).

The nuts didn’t fit very well, they were too tight, but it still works.

The final result:

I am pretty happy with it. I think I’ll redo the buttons some day, but for now it’s just fine.

Next step was to get the software up and running.  I am scanning each column. This is how it works:

  1. Set all row pins to input with pull-up high.
  2. Set column pin as output and write LOW.
  3. Check each row pins and write current state to button register.
  4. Reset column pin to input (high impedance)
  5. Go on to next column pin and finish after last column is done

The way the button matrix is connected, hazards are possible. Because of this, the microcontroller cannot readout multiple button presses at the same time. (In some cases it’s possible, but in others it’s not).

The LEDs were working (this is why I drilled holes in some button caps), but I’m not going to use them, because they’re not bright enough and it really doesn’t matter for me.

After having the electronics and software finished I moved on to the CAN module for my Raspberry PI 2. With a lot of hassle I got it up and running, it seems like there’s too much outdated information out on the internet. My problem was to get the MCP2515 overlay for Raspbian properly running. But since Kernel 4.4.x+ some things changed. (I got it working using this information here: http://www.embeddedpi.com/documentation/isolated-canbus/mypi-industrial-raspberry-pi-can-bus-card-configuration).

How to get the MCP2515 CAN Module running on a Raspberry PI on Kernel 4.4.x+ ???

I will cover this in an extra blogpost very soon…
https://vimtut0r.com/2017/01/17/can-bus-with-raspberry-pi-howtoquickstart-mcp2515-kernel-4-4-x/

Around at 4’o clock in the morning I got candump up and running to receive the can messages from my button controller:

You can see a short video below:

Leave a Reply

Your email address will not be published. Required fields are marked *