Distance sensor for an adjustable height desk?

I have a friend who got a geekdesk. http://www.geekdesk.com/geekdesk-v3-frame-only

Their cheaper model only has the ability to go up and down using a pair of buttons. It would be easy to tap into that and let a photon control it. We’d like to be able to set some predetermined heights and the photon would adjust the desk to those positions automatically.

The question is how to detect the height of the desk to know when to stop moving. I was thinking of just mounting an ultrasonic range finger to the bottom of the desk and point it at the floor. But which sensor to choose? If we can get the resolution/accuracy within a quarter of an inch, that would be ideal. The range of the desk is 23" to 48.75".

Adafruit has a bunch of them https://www.adafruit.com/categories/57 but I’m having trouble deciding which one to get. Does anyone have any experience with these and possibly know which ones would be easy to implement with a photon?

Does anyone have any better ideas for detecting the height of the desk?

1 Like

That sound like a fun project :slight_smile: Other ideas might be IR sensor inside one of the legs, or a rotary encoder on the motor output shaft (maybe it already has an encoder).

The legs are enclosed and we don’t want to do any permanent modifications to the desk. The legs are also three segments, so attaching anything to the legs is going to be tricky. Maybe I could draw some white lines on the part of the leg that telescopes inside and use an IR sensor there… hmm…

In a school project we used a cheap ultrasonic distance sensor. We used them with PIC-32 to read distances in front of a robot which was controlled from the web. The sensor proved to be reliable until ~150cm, from that point the data was random. This could be something with our code (we had to shift the 2 bytes coming in to create the 16 bits number). Since this sensor is also used a lot with arduinos this could be a good choice. HC-SR04

1 Like

I think the ultrasonic sensors are probably not going to be ideal for this application. They require a good hard flat unobstructed perpendicular surface to work reliably and only up to about 30-ish inches.

A string-pot optical encoder tucked inside one of the telescoping legs.

Don't buy one, they are ridiculously over priced.

Find a small plastic 6-10 foot tape measure (or other spring-reel-like device) and adapt a nice optical encoder to it (so you won't have to worry about mechanical switch bounce). Then fix it to one end of the table and the string to the floor. Use the encoder signals to wake up a sleepy microcontroller that will keep count. You can add a limit switch if there isn't one already so that you can "home" the system from time to time. This should only be necessary if you are too slow to start counting pulses... in which case you could just keep the microcontroller powered continuously.

Edit: Oh wow, sorry for digging this old post up :smile:

1 Like

@BDub I’ve actually got a working project with the ping sensor. I’ve been using multiple times a day for a few weeks and it’s actually very stable and accurate. We have low pile carpet at the office which doesn’t seem to cause too much interference. Any oddities can be handled in software.

I really like the optical encoder on a spring loaded tape measure. That’s really clever.

3 Likes

That’s a sweet desk! And you’re already making a breakout board for it… excellent work :wink: