Giter Club home page Giter Club logo

dreamdesk's Introduction

The Dreamdesk Project

The aim of this project was to create a framework that makes compatible any electrical standing desk with a home automation solution like Apple Homekit, Google Home, or Amazon Alexa, allowing your desk to be controlled by your phone, a computer, or a home speaker.

It has been tested and currently works with any desk relying on the Dynamic Motion system by Logicdata, like the Yaasa Desks, Gravit iDesk, or the Lidle LifeUP in addition to the IKEA Bekant desks.

The code was developped in C for the ESP32 microcontrollers family. A detailed write-up about the project is available at

Config

Select Features

Edit the CMakeLists.txt file to select what kind of desk you want to control and other optional features. The project version will be used to check if a newer version is available during the OTA update process.

# REQUIRED: Choose your desk type (LOGICDATA | IKEA)
set(DESK_TYPE "LOGICDATA")

# OPTIONAL: Choose your home automation ecosystem (HOMEKIT | NEST | ALEXA | NONE)
set(HOME_AUTOMATION "HOMEKIT")

# OPTIONAL: Enable sensors (ON | OFF)
set(SENSORS ON)

# OPTIONAL: Set the temperature scale (C | F | K)
set(SENSORS_SCALE "C")

# OPTIONAL: Enable Over The Air (OTA) updates (ON | OFF)
set(OTA_UPDATES ON)

# OPTIONAL: Set the project version
set(PROJECT_VER "2.4.0.4")

# OPTIONAL: Enable a dynamic DNS service provider (ON | OFF)
set(DDNS ON)

Setup

Espressif SDK

git clone -b v4.4 --recursive https://github.com/espressif/esp-idf.git esp-idf-v4.4
cd esp-idf-v4.4
bash install.sh
source export.sh

HomeKit ADK

ESP-IDF currently uses MbedTLS 2.16.x, whereas HomeKit ADK requires 2.18. A branch mbedtls-2.16.6-adk is being maintained here which has the required patches from 2.18, on top of 2.16.6.

cd $IDF_PATH/components/mbedtls/mbedtls
git pull
git checkout -b mbedtls-2.16.6-adk origin/mbedtls-2.16.6-adk
cd $IDF_PATH/../
git clone --recursive https://github.com/espressif/esp-apple-homekit-adk.git

HomeKit Setup Code

cd $IDF_PATH/../esp-apple-homekit-adk/homekit_adk
make tools
cd Tools
./provision_raspi.sh --category 14 --setup-code 133-71-337 --setup-id DDSK Dreamdesk
cd Dreamdesk
cp ../../../tools/accessory_setup/accessory_setup.csv .
python $IDF_PATH/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py generate accessory_setup.csv accessory_setup.bin 0x6000
esptool.py -p $ESPPORT write_flash 0x34C000 accessory_setup.bin

Resetting HomeKit Pairing

The accessory pairing information is stored in the NVS (Non Volatile Storage) partition. Once paired, the accessory cannot be paired again, without clearing this pairing information first. It can be done as below:

esptool.py -p $ESPPORT erase_region 0x10000 0x6000

Dreamdesk

cd $IDF_PATH/../
git clone --recursive https://github.com/ma-lwa-re/dreamdesk.git
cd dreamdesk
idf.py set-target esp32s3
export ESPPORT=/dev/cu.usbserial-0001
idf.py build flash

Wi-Fi

The wifi credentials were previously hardcoded in the wifi.h header, but are now directly written in a standalone partition on the ESP32.

It has the advantage that no secrets are stored in the code section anymore, and thus allows the same code to run on multiple devices, over-the-air (OTA) updates, or modification of wifi credentials without having to reflash the device.

cp wifi.csv $IDF_PATH/components/nvs_flash/nvs_partition_generator
cd $IDF_PATH/components/nvs_flash/nvs_partition_generator
# Edit the wifi.csv and replace the DEFAULT_SSID and DEFAULT_PASSWORD strings
python3 nvs_partition_gen.py generate wifi.csv wifi.bin 0x3000
esptool.py -p $ESPPORT write_flash 0x340000 wifi.bin

Dynamic DNS

Dynamic DNS, or DDNS, is a DNS service that provides the option to change the IP address of one or multiple DNS records automatically when the IP address of your device is changed dynamically by your internet provider.

This feature can be enabled in the CMakeLists.txt file and is compatible with most of the well-known dynamic DNS providers. It is compatible with all services that allow updating a record using an HTTPS GET or POST request.

You can in some cases choose to set a specific IP address or leave it blank and let the server detect the incoming source IP.

Example of some configurable URLs scheme provided by DynDNS, DuckDNS, No-Ip, or Freemyip.

https://{user}:{updater_client_key}@members.dyndns.org/v3/update?hostname={mydomain}&myip={ip_address}
https://www.duckdns.org/update?domains={mydomain}&token={updater_client_token}&ip=
https://{username}:{password}@dynupdate.no-ip.com/nic/update?hostname={mydomain}&myip={ip_address}
https://freemyip.com/update?token={updater_client_token}&domain={mydomain}

The URL needs to be configured in the wifi.csv, by replacing the DEFAULT_DDNS_UPDATE_URL placeholder with your fully formatted URL. Then, generate a partition file and flash the device as explained in the Wi-Fi chapter.

Code Signing

The integrity of the application can be secure and checked using an RSA signature scheme. The binary is signed after compilation with the private key that can be generated with espsecure.py or openssl, and the corresponding public key is embedded into the binary for verification.

espsecure.py generate_signing_key --version 2 secure_boot_signing_key.pem

The bootloader will be compiled with code to verify that an app is signed before booting it. In addition, the signature will be also proofed before updating the firmware and adds significant security against network-based attacks by preventing spoofing of OTA updates.

Octal SPI Flash

If you're using a chip version that uses an Octal SPI interface to connect Flash/PSRAM, like the ESP32-S3-WROOM-2, you need to enable its support using the command below.

idf.py menuconfig
Serial flasher config ---> Enable Octal Flash

Console Output

sudo cu -l $ESPPORT -s 115200

Project

dreamdesk
├── CMakeLists.txt
├── LICENSE
├── README.md
├── lib
│   └── esp32-scd4x
│       ├── CMakeLists.txt
│       ├── LICENSE
│       ├── README.md
│       ├── images
│       │   └── SCD4x.png
│       ├── main.c
│       ├── scd4x.c
│       └── scd4x.h
├── main
│   ├── CMakeLists.txt
│   ├── ddns.c
│   ├── ddns.h
│   ├── dreamdesk.c
│   ├── dreamdesk.h
│   ├── homekit.c
│   ├── homekit.h
│   ├── ikea.c
│   ├── ikea.h
│   ├── lin.c
│   ├── lin.h
│   ├── logicdata.c
│   ├── logicdata.h
│   ├── main.c
│   ├── ota.c
│   ├── ota.h
│   ├── sensors.c
│   ├── sensors.h
│   ├── wifi.c
│   └── wifi.h
├── partitions.csv
├── sdkconfig
├── sdkconfig.defaults
└── wifi.csv

TODO

  • IKEA desk testing
  • PCB prototype
  • PCB assembly
  • OTA updates
  • DDNS updates
  • NVS encryption
  • HomeKit memory integration
  • HomeKit sensors integration
  • Sensors (humidity + air + temperature)
  • Google Home support
  • Amazon Alexa support
  • Dump Logicdata firwmare

Feedback & Issues

Issues and feature requests should be raised on GitHub using

dreamdesk's People

Contributors

ma-lwa-re avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dreamdesk's Issues

Feature: min/max position

This is a feature I miss from the yaasa desk, and I believe could be solved with the custom controller: custom min/max position for the table. This is useful when the desk is in a crammy space with objects below and above, and you don't want to rely on the collision detection mechanism (which would easily let the table crush my chair before backing up).
There should be 2 configuration values, min_position and max_position, and the controller should break the movement of the table when either is reached.

PCB Board

Very nice work!
Could you also share the PCB Design for OSHPark?
BR, Matt

UART wiring?

This project looks very promising and clean. I couldn't find any documentation on how to do the UART wiring since the desks themselves don't have a UART ports AFAIK? Where are the pins configured?

I'm particularly interested in what you are doing with Logicdata (https://github.com/ma-lwa-re/dreamdesk/blob/master/main/logicdata.c), since the protocol seems well established when looking at the code and the other decoded versions of the protocol I could find (e.g. https://github.com/phord/RoboDesk) aren't as complete.

Do you have any hardware / wiring specs / photos on how to set this up per supported desk model?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.