Embedded Devices | Controlling adjustable desk with my phone

Embedded Devices | Controlling adjustable desk with my phone

At work we have very nice electric adjustable standing desks made by Workrite.  There is a button on the side the of the desk that allows you to control the high of the desk.  You can use it to go from a sitting desk to a standing desk in only seconds!  One day I accidentally ripped out the cables that were connected to the up and down switch show below.  This happened when the arm of my chair got wedged underneath the wires and when I lifted the desk up they were ripped off.   Time to fix it …



The quick fix solution was to just solder the wires back together, however after inspecting the switch I thought I could come up with something more interesting.  I wondered if it was possible to control the switch through my phone by connecting some small embedded device to the wires instead of the switch.  The embedded device would have Wi-Fi connectivity and have the ability to act as the switch.  I wasn’t too sure how I could do this or what would be needed, so the first thing was to figure out what was happening with the switch.  Shown below is the inside of the switch after I took off the casing.  The two buttons are to make the desk go up and down.


The yellow and red wires were the ones that had been ripped off.  The black wire had somehow still remained in tact.  As I have tried to show above, The yellow wire had a high voltage of 6.5v and the black and red had no voltage.  I tested this by using a multimeter.

The yellow 6.5v is connected to both the up (red wire) and down (black wire) switches.  So, when one of the buttons is pressed the switch is closed and the 6.5v from the yellow wire is transferred to what ever wire is connected to the switch (either red or black).  This is how the embedded device in the desk knows when to turn on the motors to move the desk up or down.  It watches for a high voltage (6.5v) from either the black or red wire.

Now that I had figured out the internals of the switch, the next step was to try and control the switch by an embedded device.  After searching around for a while, I found a very affordable and great solution.  The Particle Photon is a very small embedded device which has Wi-Fi connectivity and a already built out App that allows the device to be controlled anywhere with your phone!

The Photon shown above is extremely small and with a price point of only $20 I couldn’t go wrong!

I thought this would be a very simple process from this point.  I connect the red wire to pin D0 and the black wire to pin D1 on the Photon.  It doesn’t really matter what pins you choose, I just picked the first ones.  Then, I installed the Particle App on my phone which would allow me to control the output voltage of the D pins without ever having to program 1 line of code!  I was very impressed with the Particle App as it easily connected to my device and worked very smoothly.

I got everything set up and using my phone I switch the D1 port to high voltage, but nothing happened!  Time to trouble shoot …

Well, the first problem was my desk was not plugged into the wall 😉 so I fixed that and tried again, still no movement.  I double checked my connection to the Photon and made sure everything was secure and in the correct place.  Next, I took my multimeter out and tested how much voltage was coming out the Photon when I turned one of the D pins on.  As expressed on the datasheet, the output was 3.3v.

I knew this when I purchased the photon but I had expected the desk to look for a high voltage on the wire and thought 3.3v would be ok.  My problem now was that I needed a higher voltage on the output pins (closer to the original 6.5v).

After some research and help from my uncle, the solution that was suggested to me was to use a relay.  I had never used a relay before so this was something new to learn about.

Shown above is a high level diagram of what a relay looks like inside.  It is a fairly simple device that has the great ability to create a switch and transfer a variety of voltages.   This was very helpful for me because now I could transfer the 6.5v from the yellow  wire and keep the exact voltages that were used in the original desk switch.

After I figured this out I purchased this set of relays from Amazon.


I only needed 2 relays, however it was pointed out to me that you never know when you might was to control more stuff and the price from 2 to 4 was pretty much the same so I purchased the set of 4.

So the next task was to figure out how to connect the Photon, relay and desk wires together.

The relays are controlled by connections called IN1, IN2, IN3, IN4.  The circuit looks for a high/low voltage coming from these connections and that is how the relays are turned on/off.  Since I only needed to control 2 of the relays, I connected the IN1 from the relay board to D1 on the Photon and IN2 to D2.  The relay board also needs power to the board so I connected the VCC (5v) on the relay board to the 5v output on the Photon board.  The GND (ground) on the relay board was then connected to the GND on the Photon board.  This takes care of the connections from the Photon to the relay board.  This allows me to still control the relay from the Photon App by turning on/off the D1 and D2 ports.  Below is the image of the wired connection on the relay board.


Next, the 3 wires from the desk (yellow , red, and black) need to be connected to the relay.  In the images below I try to show where I have connected the wires.  The yellow (6.5v) goes into one of the relay inputs and then a jumper wire makes a connection to the other relay.  This is how I set up both of them to have the 6.5v coming from the yellow wire.  Then The red and black wires are connected to the other input of their respective relays.



Now, everything is connected together.  The Photon controls the relay board through pins D1 and D2, also giving power to the relay board through the 5v output port.  The relay board acts sort of as the middle man between the desk and the Photon.  The relays are connected to the desk wires and act exactly as the switch did before, passing the 6.5v through when the relays are activated.

The moment of truth, will it work?  I made sure everything was plugged in and that the wired connections were secure.  Started up the Particle App and here is the video of the final result!

Leave a Reply

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