davidknezic / desk

:arrow_up_down: A height-adjustable desk controlled by Siri using Homekit
https://github.com/davidknezic/desk
MIT License
109 stars 5 forks source link

Simplify this project using a Raspberry Pi Zero #3

Open davidknezic opened 5 years ago

davidknezic commented 5 years ago

Currently, this project is quite complex to implement due to the Hub/desk module combo and the ZigBee communication.

I think it might be time to simplify this project using a simple Raspberry Pi Zero. There, WiFi and GPIO handling can all happen on one device.

MartinNuc commented 5 years ago

I am definitely going to control by desk from a RPI itself... I will eventually let you know when I progress further. I am still waiting for the table.

davidknezic commented 5 years ago

Awesome! Let me know how it goes šŸ™‚

MartinNuc commented 4 years ago

Finally had time for this during the quarantine šŸ˜·

It turns out that Raspberry GPIO pins are only 3.3V while Arduino is 5V. I am afraid that LogicDesk sends 5V which would destroy my RPI and I don't have currently a multimeter to measure it šŸ™

davidknezic commented 4 years ago

Hi @MartinNuc, good to hear from you!

The Raspberry Pi has two 5V pins (2 + 4) that come directly from the 5V power supply.

With a step-down or step-up level shifter circuit you can interface with the LogicDesk circuit. They consist of simple components and I've used them on several occasions.

Maybe this will work for you too?

MartinNuc commented 4 years ago

@davidknezic ordered step down/up yesterday. Should arrive in following days šŸ¤ž

MartinNuc commented 4 years ago

FYI I am almost done with the driver for raspberry. Its my first project in Rust therefore the code is šŸ’©

https://github.com/MartinNuc/logic-data-controller

It exposes REST API for controlling the table. Honestly to avoid step-up/down shifter I would prefer Arduino šŸ˜€

davidknezic commented 4 years ago

Thank you very much for sharing! Rust seems to be very cool.

The only reason I though migrating to Rpi Zero W was because it's cheap, has Wifi and runs Linux (for HomeKit). But I guess the same things can be achieved with an Arduino. If you find a model, I'd love to know which one you went with. I totally agree with you that it makes sense to use the board that makes things easiest.

MartinNuc commented 4 years ago

Unfortunately you cannot run linux on Arduino. So using raspberry is really "one-package" solution but the setup of wires is rather complicated šŸ˜± ... see the photo šŸ™ˆ

IMG_4240

MartinNuc commented 4 years ago

There is an issue with raspberry that it doesn't manage to keep the loop under 1ms. Especially when there is something else going on on the device. Therefore it reads the signal wrong.

At first I wrote the driver in Typescript and I thought the reason it run fast enough is Javascript - maybe garbage collector. But even with Rust I see lagspikes which causes to skip reading bit or even more from the signal channel time to time. Which results in delays when reading the table height.

Really looks to me that using Arduino for this is much better solution :-)

MartinNuc commented 4 years ago

After using it for some time it mostly works ... I am pretty much sure there is still the problem with delayed reading of the signal channel.

I am wondering - using Arduino - does it happen that the table controller display stops showing height values? And sometimes that it resets memory positions?

davidknezic commented 4 years ago

Glad to hear that it's been working so far.

Yes, at some point the controller stops sending the height. I noticed that I just have to give a very short impulse (up or down) to make it send the height again. If the impulse is short enough, the desk won't really move.

About the memory positions, I'm not sure. Do you mean the programmable heights you can set on the hand switch? Unfortunately, I don't have those.

ryanschmidt commented 4 years ago

Just stopping by to say this project is amazing and Iā€™d love to try it. How is the setup working out?

visini commented 4 years ago

I'm currently waiting for parts, but will give this a try (using RPI only). Many thanks @MartinNuc and @davidknezic for the amazing work on their respective projects. Looking forward to get this going!

davidknezic commented 4 years ago

Hi @ryanschmidt @visini thank you for the kind words!

How is the setup working out?

@ryanschmidt I myself still run the original setup described in this repository and it is very reliable.

Still have the plan to migrate to a Raspberry Pi Zero W only setup, but the lack of real-time processing that @MartinNuc has mentioned earlier will be a challenge. I wonder if running the kernel in real-time mode would help there.

@visini just saw your issue over at MartinNuc/logic-data-controller#1. Will compare it to my wiring an let you know what I find out.

dpinna13 commented 3 years ago

@davidknezic I was thinking to simplify this by separating the device into two. An ESP32 or ESP8266 running the arduino code and connected directly to the wifi. The rpi (or anything really) acting as a server that connects to the ESP and exposes it to homebridge. I have a similar setup for an IR emitter that acts as an AC remote so it shouldn't be too hard -- (last famous words).