tjhorner / upsy-desky

Make your standing desk smarter
https://upsy-desky.tjhorner.dev
Other
561 stars 31 forks source link

Adapter Cable Research #5

Open tjhorner opened 2 years ago

tjhorner commented 2 years ago

There are many different standing desk brands out there, and most of them use the RJ45 pinout that this project does. However, there are a few that do not! How do we add support for them? I think the best solution is to create adapter cables which can easily and cheaply modify the pinout or physical connector so that the Upsy Desky can communicate with the desk.

For example

I think this is a good way to solve the problem, but I'm not entirely sure how to manufacture these at scale. I'll be researching different ways to do this.

Edit: Ah, I just thought of something. What about the passthrough? I guess I would need to ship cables in pairs, since you would need two if you want to use the original keypad. Wondering if there's a more economical way to do that?

tjhorner commented 2 years ago

Autonomous Desk Adapter

Pin Functions

Position Color Function
1 N/A N/A
2 N/A N/A
3 N/A N/A
4 Red Sleep
5 N/A N/A
6 N/A N/A
7 Orange GND
8 Yellow RX
9 Green TX
10 Blue +5V

Pin Mapping

Function RJ45 Position RJ50 Position
Sleep 1 4
RX 2 8
GND 3 7
TX 4 9
+5V 5 10
N/A 6 N/A
N/A 7 N/A
N/A 8 N/A
tjhorner commented 2 years ago

Reached out to a cable manufacturer to get prototypes of the Autonomous adapter cables made based on the above info.

rosstadude commented 2 years ago

I would be interested and willing to test on my Autonomous desk. Please let me know how much for the cable. Thank you

Jolanrensen commented 2 years ago

Also willing to test on my locktech desk! I don't have an upsy desky yet, but I'm on the waiting list

Jolanrensen commented 2 years ago

I now do have one :) Also, I have some ethernet (RJ45) plugs and a crimping tool, so I can modify and test a cable to see if it works on HS01B-1 Locktech desks. Did follow this but it seems to have gone silent. I'm also curious if one or two cables would need to be modified. Since the upsy desky is a passthrough I think the cable to the controller/screen of the desk would also need to be modified as well as a cable to the desk motor itself. Is that right?

tjhorner commented 2 years ago

Yes, getting the original keypad to work will be tricky and might require some kind of other adapter. For now I am focusing on getting the Upsy Desky working with the control box

Jolanrensen commented 2 years ago

Alright :) If ever needed, I did find some extra info about passthrough for the keypad: https://github.com/iMicknl/LoctekMotion_IoT/tree/main/packages/esphome#hs01b-1-with-esp32-as-passthrough-and-keypad-support

Jolanrensen commented 2 years ago

Alright, so I created an adapter cable based on the sources available to me:

RJ45 Modified Cat5 Modified colors (desk side) RJ45 OG Cat5 OG colors (upsy desky side) HS01B-1 purpose (after rewire)
1 orange/white 1 orange/white RES (needs passthrough for keypad)
6 green 2 orange RX (needs bridging for keypad)
7 brown/white 3 green/white GND (needs bridging for keypad)
8 brown 4 blue TX (keypad should have different GPIO)
2 orange 5 blue/white 5V (needs passthrough for keypad)
4 blue 6 green SWIM (needs passthrough for keypad)
3 green/white 7 brown/white (unknown) (needs passthrough for keypad)
5 blue/white 8 brown PIN 20 (keypad should have different GPIO)

Some clarification: "Passthrough" can mean either ouside the upsy-desky or through it without touching the signal. I don't know if it's needed for the desk to operate but it's what mentioned here https://github.com/iMicknl/LoctekMotion_IoT/tree/main/packages/esphome#hs01b-1 "Bridging" means the upsy desky needs the connection but it also needs to be passed through to the keypad. Not sure what needs to be done with TX and PIN 20 since they are wired to different GPIOs altogether, both from/to the keypad as from/to the desk controller.

But let's start with just the desk controller as I created the cable for it. I have the modified colors side connected to the desk and the unmodified side in the upsy desky. Connecting the upsy desky gives it power (since it now has 5v at pin 5), but where do I go from here? I have programming experience for sure, but haven't worked with esphome before, so if I could be pointed in the right direction, that would be great :)

tjhorner commented 2 years ago

@Jolanrensen excellent research! To test out the firmware you can follow ESPHome's setup guide then try installing the various configs from the repo you linked above (here).

Jolanrensen commented 2 years ago

So the plan is to get that to work as best as possible and then adapt your template to it? :) Cause that sounds doable. I'll report back when I have something working!

Btw a question regarding the keypad: the two ethernet ports of the upsy desky are bridged right? Which means that we cannot send a signal (say over line 4) and make it just go towards the desk or just the display. If we follow the Loctek IOT project, we need access to 5 different GPIO ports, 5v and GND which is 7/8. For RES, SWIM and (unknown) this means that they would have to be disconnected (if they're not needed) or passed through outside of the upsy desky. (Unless we could maybe combine 5v and PIN20 since that needs to be powered? Or is that a stupid idea)

This would also mean my adapter needs some changes 😂 however, at least for controlling the desk itself it could do fine. I'm currently in the process of creating a little setup for myself where I can play around with swapping and testing the cables a bit easier since I'm running out of ethernet connectors to crimp 😅.

Jolanrensen commented 2 years ago

Small update: I'm able to control the desk from home assistant! (using https://github.com/Jolanrensen/LoctekMotion_IoT) It does seem to stutter a lot XD Not yet sure if that's because of my wiring or the software. (I think it's the software since the switch keeps turning off in Home assistant)

Edit: ah yes, it's because of the uart switch. If i put uart.write in a while loop (from for instance cover: ) the desk moves smoothly :) (and then the upsy desky crashes 😂). I'll try to see if I can make your slider approach work instead.

Jolanrensen commented 2 years ago

Just as a redundancy test, connecting a similar adapter from they keypad to the upsy desky does light up the keypad and displays the correct height, but the desk is uncontrollable, both from HASS, as well as the buttons. Thought so :) However, to be able to connect both the desk and the keypad to the upsy desky I probably have to make another adapter cable, disconnecting a couple of lanes to free up GPIO ports.

Unfortunately, I'm running out of tools, so I ordered some extra connectors and cables (and finally a breadboard), which will take a couple of days to arrive, to further explore the possibilities :) Cos currently I cannot tell whether my hacky cable is the problem or the desk.

ajfriesen commented 2 years ago

My desk also comes with a RJ50 connector.

Will build a custom cable myself.

Just an idea: For mass production it may be easier to look into an adapter board where you punch down cables by yourself?

Something like this: PXL_20221114_145234084.jpg

This is a rj45 jack to ethernet PCB with a case. You could modify this model and just punch down cables according to your desk model.

Jolanrensen commented 2 years ago

@ajfriesen That's exactly what I ordered :) But I would still need a sort of special cable-adapter since some cables need to bypass the upsy desky going straight from the keypad to the desk and some need to go through.

Something like (forgive my drawing): WhatsApp Image 2022-11-09 at 02 05 42 Where UD: upsy desky K: Keypad b: Desk

But hopefully I can soon do some more testing :)

tjhorner commented 2 years ago

Just an idea: For mass production it may be easier to look into an adapter board where you punch down cables by yourself?

That's a great idea! Never thought of that. I'll see how the cost compares to custom cables.

Jolanrensen commented 2 years ago

@ajfriesen That's exactly what I ordered :) But I would still need a sort of special cable-adapter since some cables need to bypass the upsy desky going straight from the keypad to the desk and some need to go through.

Something like (forgive my drawing): Where UD: upsy desky K: Keypad b: Desk

But hopefully I can soon do some more testing :)

Well, I've got something working :D Using my branch of LocTekMotion https://github.com/Jolanrensen/LoctekMotion_IoT/tree/main I can now control the desk both from the keypad and home assistant :) There are still some problems:

However, these problems are most probably software problems :) My wiring (hopefully including all coloring standards, haha):

cat5 B cat5 B HS01B-1 Upsy Desky side (from desk) Upsy Desky side (from keypad)
1 orange-white brown    
2 orange white 5/blue-white/green (RX GPIO17) 5/blue-white/green (RX bridged from desk GPIO17)
3 green-white purple 7/brown-white/blue (GND) 7/brown-white/blue (GND)
4 blue red 6/green/black (TX GPIO16)  
5 blue-white green 8/brown/yellow (5V (VVD)) 8/brown/yellow (5V (VVD))
6 green black   6/green/black (TX or RX from UD pov GPIO19)
7 brown-white blue   4/blue/red (pin 20 GPIO21)
8 brown yellow 4/blue/red (pin 20 GPIO22)  

Connected straight from desk to keypad:

Yes, I changed my wiring method a bit to make it easier to work with for my breadboard.

Jolanrensen commented 2 years ago

My beautiful adapter! It's completely based on the table above. PXL_20221119_150624454 MP

Simply plug the two male plugs in the Upsy Desky and connect the female plug to the keypad and the male plug in the desk controller: PXL_20221119_151747027

It's easy to replicate if you have a small ethernet extension cable (male to female, adhering to cat5 B) where you strip out the middle bit, cut all wires except 1,2, and 3 and then attach two male ethernet plugs using the table above. If you don't have an ethernet crimping tool, there are also toolless options available: PXL_20221119_152631597

Not sure if it would be possible to manufacture something like this, but doing it yourself can be done in less than an hour :)

rosstadude commented 2 years ago

This is great!

MrTechGadget commented 1 year ago

@Jolanrensen I just found this as a result of the blog I posted on reddit. Ironically, I think I had this working the same week in November you were, I just didn't finish the write up and post it until this past weekend. I decided to replace the regular controls completely. https://www.mrtechgadget.com/2023/01/upgrading-standing-desk-controls.html

In case you want to compare my ESPHome sketch (I got smooth motion using a rotary encoder in my solution but had to play with timing a little.) https://github.com/MrTechGadget/LoctekMotion_IoT/blob/main/packages/esphome/flexispot_e5b_esp32.yaml

Jolanrensen commented 1 year ago

@MrTechGadget 108ms is very specific timing indeed haha. Very cool! I will definitely try that too. I'm currently using a delay of 0ms which is smooth but sometimes "hesitates" a bit. I do think that these timings are very specific to your own setup on the cables, connectors, the motor etc.

backslashV commented 10 months ago

Hi there, I have a similar desk with an RJ50 keypad connector. I'd like to use an Upsy Desky to make the desk smart, but that device uses an RJ45 connector. Can anyone suggest a way to identify what each of these 5 pins do so I can make a custom RJ50 to RJ45 adapter? image

tim-vk commented 4 months ago

Silly question: but what is the pinout that the upsy desky expects? In the documentation it mentions pin 3 = GND and pin 5 = 5v. But which ones are the RX & TX pins? I couldn't find that in the docs (and i'll probably need to open the pcb files: which i can't).

JesperKuipers commented 1 month ago

Silly question: but what is the pinout that the upsy desky expects? In the documentation it mentions pin 3 = GND and pin 5 = 5v. But which ones are the RX & TX pins? I couldn't find that in the docs (and i'll probably need to open the pcb files: which i can't).

https://github.com/tjhorner/upsy-desky/blob/master/firmware/base.yaml line 19 and line 35