Turn your LoctekMotion/FlexiSpot standing desk into a smart desk!

However, it seems that the HS11A-1 has a similar pinout as the HS13A-1 control panel. (source)

Feel free to report / track your progress here eventually, when you are ready :slight_smile:.

So @imick - I recently purchased a standing desk from Office Depot, and it has the HS13A-1 controller and dual RJ-45 ports. If I wanted to set your project up, what would I need to purchase aside from an ESP8266? I’m a complete novice to ESP32, but I’ve been meaning to give it a go.

Any videos you could recommend on how to get started?

I’ve watched a few videos and I’ve purchased an ESP32 which should arrive tomorrow.

I noticed that your instructions look like they’re for the ESP8266 which from the videos I watched is the predecessor to the ESP32?

With ESP Home and Home Assistant, I think I can get the board online, connected and running. I’m just not sure how to attach the RJ-45 to the board itself.

In your post above you used what looks like an RJ-45 Serial connector? On your github it looks like you connected the wires in the ethernet cables to the pins on the board itself? Should I be grabbing something like this to connect one end to the pin on the board, and then the other end twist it with the ethernet cable / electrical tape?

I think I’m most of the way there, just a little lost on how to connect the ESP32 to the wires. I’ve terminated ethernet cables before, so I should be good there. I can follow the pattern you set forth in the documentation for that.

Thanks!

Hi @stratotally, happy to help. Feel free to contact me on Discord (iMick#1903) as well. You can indeed also use an ESP32, just change the board in your ESPHome config.

There are multiple options to get this working. In my end solution I just used an ethernet cable which I cut, and I added dupont connectors to the end on one side. But during testing I used a RJ45 to RS232 adapter, which I connected to the dupont cables. This made testing convenient in the beginning.

Thanks, friend request sent!

So I think I’m almost there. GND = Ground, which makes sense because the control panel is powered by the RJ-45 cable from the controller. Would I take that to mean that the ESP32 could also be powered by the cables? (Update: Looks like thats a yes, read below!)

I’ve purchased some dupont connectors and I’m just waiting for them to arrive. Meanwhile I’m trying to match up your photo with the pinouts, and compare that to your documentation on github. Thinking through this aloud, if I take your mapping here:

The “original cable” is the cable that came with the desk, right? And you’re providing a mapping to a normal ethernet configuration in the last column.

So I should take this mapping, and compare it to the ESPHome mapping?

image

I see you have indicators like “D6” and “D5” in the first column. So I just need to match those up with the ESP32 pinouts, right? And since the ESP32 supports a 5V, that means I can power it from the desk itself?

Thanks again! Excited to hook this baby up!

I spoke with imick and the ethernet cable color column was added by a contributor. I think that the “original cable color” were the colors that were with imick’s cable, and what they corresponded to in the pins at the connector. Since the last column (T568B) follows the standard, I think thats what I’m going to use. As long as I line them up with the “Name” column to the cable color in the last column, and then match that with the second screenshot on the pinouts, I should be good.

However, ESP32 has different pinouts than ESP8266. I’ve been researching this and trying to take a crash course in arduino, and I think I might be close? I’m still waiting for my duponts to arrive to confirm it. From my research, I ESP8266 uses certain pins for certain functions. The four we need are:
GND - Ground
D5 - GPIO14 / SCLK (Slave Clock - but we have this mapped to TX for transmit.
D6 - GPIO12 - MISO (Master in, slave out - which I read as communication from the slave device to the ESP, we have this mapped to RX for Receive, so I think we’re good here.)
D2 - GPIO4 - SDA (Serial Data Pin, where communication is sent back and forth between the devices)

From my research, you can set (certain) GPIO pins to be whatever you want. I think I need to add the following to my yaml file for ESPHome to match the original ESP8226 config?

spi:
  clk_pin: GPIO14
  mosi_pin: GPIO13
  miso_pin: GPIO12

uart:
  id: desk_uart
  baud_rate: 9600
  tx_pin: GPIO14 
  rx_pin: GPIO12

And then I need to set an SDA pin.

i2c:
  sda: 21
  scl: 22
  scan: True
  id: bus_a

This should default the sda to GPIO21. I’d then replace this in the yaml where D2 is listed.


switch:
  - platform: gpio
    name: "Virtual Screen"
    pin:
      number: GPIO21
      i2c_id: bus_a # Don't know if I need to define this here...
      mode: OUTPUT
    restore_mode: ALWAYS_OFF
    internal: true

Hopefully I’m on the right track!

To be honest, I am not sure what i2c is and what you need to do? It should be as simple as just changing the tx and rx pins to the one that you did choose, and connecting the ground.

Thanks @imick - What about the PIN20 which is connected to D2? That isn’t needed?

switch:
  - platform: gpio
    name: "Virtual Screen"
    pin:
      number: D2
      mode: OUTPUT
    restore_mode: ALWAYS_OFF
    internal: true

That one is required as well, however you can just choose another GPIO port of your ESP32.

OK! Will do. Going to give it a try now and will report back.

Also, not sure why, but it wouldn’t compile until I added:

esphome:
  name: standing_desk
  platform: ESP32
  board: node32s
  includes: #<--- this
    - desk_height_sensor.h #<--- and this

…to the top. About to start crimping. :slight_smile:

I’ve crimped, and then re-crimped. Still couldn’t seem to make this work. I also removed the i2c and spi sections, since it sounds like I just need to identify which pin to work with. Still no dice.

I think what the contributor was trying to do with adding in the RJ-45 colors to the table in the last column was identify which wires in a typical RJ-45 correspond to which wire in the cable/display that comes with the desk. However, I’ve just realized that they have it backwards. :frowning:

Your original column with the colors Brown, White, Purple, etc. If I look at the RJ-45 end of the cable that comes with the desk, I see these colors. There isn’t a “purple” in typical ethernet wires, so they were trying to match what it’d be in a typical cable.

However, in your photo here:

image

…it looks like you’re using brown/white for your D2 pin? Then I compared the pin numbers to this diagram:

image

…and bam. The contributor listed the colors backwards! This would explain your photo…and why my setup isn’t working. Sigh. Time to do some more crimping and hopefully I’ll be submitting a correction to your repo README as soon as I get mine working. :confused:

Never mind. While the pin numbers were backwards compared to the diagram I found, the cross map looks like it is correct.

@imick Would you be able to take a closer pic of your board and/or list which ethernet wire colors are going to each pinout? Is that the white-brown that you’re using?

I can have a look after the weekend, but perhaps it is interesting to create a group to discuss some where. Another user on GitHub with an ESP32 did request something similar: Update Arduino / C++ sample · Issue #3 · iMicknl/LoctekMotion_IoT · GitHub.

I’ve got one of these on the way and am hoping your hack will work.

Will post results as I go…

hi what an awesome project thanks for sharing!

unfortunately i only have a flexispot with a basic keypad that only does up and down and has no RJ45 port. has anybody ever looked into making one of those smart?
could be a matter of just closing certain circuits depending on which direction you want to go?

image

1 Like

Can anyone explain what the switch “Virtual Screen” is meant to do?

Thanks

I have this exact same controller, but mine is officially broken. Sorry this is probably not the correct thread, but there isn’t much information out there on these Loctek controllers.

Has anyone been able to replace, or rebuild one?

Hi I‘m looking for some help. My desk seems to be different to the desks that have already been posted here. Therefore I opened a new topic. So if anyone is willing and able to help, I would really appreciate it! Thanks :blush:

Thanks for this awesome work Mick!

I managed to get this working really quickly thanks to your instructions along with comments of others regarding different boards etc.

I have a question regarding automations…what sort of automations are people using once this is integrated? For example, if you wanted to enforce a stand position after X amount of time sitting, how are you doing this?

In my case, my office is a log cabin, so i generally power down all plugs as part of my office alarm enabling script, which means when i start work the next day, the power to the desk comes back on and as such HA doesn’t know the position of the desk until I press a position button, however i rarely do until i want to stand again.

Just after some ideas on how to benefit from this integration and how you’ve achieved them - automation yaml examples would be greatly appreciated :slight_smile:

Thanks in advance

Hi will it also work with an hs13b-1 (E7) ?

1 Like