mm radar in Home Assistant

Hi-Link manufactures a number of different sensor modules with millimeter wavelength radars which are great to detect humans with.

Some time ago I read about these and they were did not cost much. I bought these from AliExpress. So I ordered some different ones. Recently I found some time to experiment with one of them, the LD2450 (The AliExpress item I bought). On the product page there is a link to a Google drive with documents and software for this module.

I had previously tried one of the others briefly but unsuccessfully. So this time I took a bit different path.

I read that several (maybe all?) of these has built in Bluetooth so I downloaded the HLKRadarTool (iOS or Android) to my phone and powered up the module and connected the phone to it. It worked directly and it was easy to evaluate how the device performed.

Once I know it worked well it was time to connect it to an ESP32. The manual made it easy to understand what pins to use on the radar module. I had some ESP32-C3 modules at home so I decided to use it. The model I had was Tenstar Robot Super Mini and the pinout made it easy to figure out how to connect RX and TX on the sensor to TX and RX on the ESP32.

I then used ESPHome device builder in Home Assistant and the information on the ESPHome LD2450 page to create and install a configuration for the sensor. And soon it appeared in Home Assistant.

After that I looked for a case and found a nice simple case that could easily be pointed in different directions but was not too bulky.

ESP32-CAM in HomeAssistant

I have an ESP32-CAM unit I wanted to try to connect to Home Assistant. This is how I managed to add it.

First I Googled and found the esp32_camera component for ESPHome so it was a natural start since I already have several other ESPHome devices.

After a while I found that the esp32_camera component came with a number of configuration examples. After a little investigation among checking the https://github.com/raphaelbs/esp32-cam-ai-thinker project I realized that I should be able to use the Ai-Thinker Camera-example.

I also wanted to be able to control the LEDs on the board, both the status LED and the Flash and added those as well.

This was my final yaml configuration which I added to the rest of the ESP yaml in the ESP Builder

esp32_camera:
  name: ESP32 camera
  external_clock:
    pin: GPIO0
    frequency: 20MHz
  i2c_pins:
    sda: GPIO26
    scl: GPIO27
  data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
  vsync_pin: GPIO25
  href_pin: GPIO23
  pixel_clock_pin: GPIO22
  power_down_pin: GPIO32
  resolution: 1600x1200 # Native resolutions CIF 400x296, SVGA 800x600, UXGA 1600x1200
  jpeg_quality: 10
  vertical_flip: false
  horizontal_mirror: false

output:
  - platform: gpio
    id: camera_flash_led
    pin: GPIO04

light:
  - platform: status_led
    name: "Camera status LED"
    pin: 
      number: GPIO33
      inverted: true

  - platform: binary
    name: "Camera Flash LED"
    output: camera_flash_led

Running temporary Home-Assistant on my laptop

Wanted to experiment a bit with Home-Assistant while travelling. And wanted to be able to run as much as possibly locally on the laptop instead of connecting to my home setup since network connectivity is not always reliable.

So here is a short summary how I set it up.

Docker Desktop

I already had Docker Desktop setup with a free Docker Personal account. If you do not have it setup already, download and install it.

HomeAssistant and MQTT

I found these two articles; Installing Docker, Home Assistant and Portainer on Ubuntu Linux and Configuring the Mosquitto MQTT Docker container for use with Home Assistant but they are dedicated to run Docker on Linux and since my laptop is a Mac I had to do some modifications.

Home Assistant

Create a folder on your laptop. I called mine home-assistant and then a number of subfolders in it:

mkdir home-assistant
cd home-assistant
mkdir homeassistant
mkdir homeassistant/config

Then run code docker-compose.yml and add

version: '3.0'
services:
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - ./homeassistant/config:/config
      - /etc/localtime:/etc/localtime:ro
      - /run/dbus:/run/dbus:ro
    restart: unless-stopped
    privileged: true
    ports:
      - 8123:8123

Mosquitto

Optionally if you want to run Mosquitto for MQTT

mkdir mosquitto
mkdir mosquitto/data  
mkdir mosquitto/logmkdir mosquitto/config

Then run code mosquitto/config/mosquitto.conf and add

persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
listener 1883

## Authentication ##
allow_anonymous true

And add to docker-compose.yml

  mosquitto:
    image: eclipse-mosquitto
    container_name: mosquitto
    volumes:
      - ./mosquitto:/mosquitto
      - ./mosquitto/data:/mosquitto/data
      - ./mosquitto/log:/mosquitto/log
    ports:
      - 1883:1883
      - 9001:9001    

Start container/s

Then start the the container or containers with docker compose like

docker-compose up -d

Configure login to mosquitto

You now have both Home Assistant and Mosquitto running but before connecting the two you want to setup authentication in Mosquitto. This is just a simple setup with only one account.

In Docker Desktop, view your containers by clicking Containers in the left menu. Find the mosquitto one and click on its name. Then select the Exec tab and execute the following command

mosquitto_passwd -c /mosquitto/config/password_file hass

Enter the password you want twice.

Then edit the /mosquitto/config/mosquitto.config in VSCode and change the following section

## Authentication ##
allow_anonymous true

to

## Authentication ##
allow_anonymous false
password_file /mosquitto/config/password_file

Then restart the mosquitto docker to reload this config.

Connect Home Assistant to Mosquitto

Then visit localhost:8123 to create account and start using Home-Assistant.

Click Setting in the left menu once you have logged in. Then click Devices & services.

Click “Add Integration” and type MQTT. Select MQTT and then click MQTT(the top alternative). You should see something like

Fill in all fields like in this example

And click Submit. Now you have added your Mosquitto instance to Home Assistant!

Wiring MakerX – remote receiver

Some documentation of my wiring to the MakerX VESC since I am about to connect a BRemote instead of the Maytech one.

VESCFirst cableSecondThirdFourthMaytech RxBRemote Rx V1.3
PPM
SigYellowOrangeYellowOrangePWMSRV
5VRedNC
GNDBlackNC
COMM 
AUXBrownNC
MISO_ADC_EXT2OrangeNC
TX_SDA_NSSWhitePurplePinkPurpleRXDTX2
RX_SCL_MOSIBlueGreyGreyGreyTXDRX2
SCK_ADC_EXT1GreenNC
GNDBlackBlackBlueBlackGNDGND
3.3VYellowNC
5VRedRedRedRed5V5V
Other
Battery +GreenGreenBrownGreyBATBMS+
Motor phaseBlueBlueWhiteWhiteMOT

Extruder calibration on the Snapmaker A250

This article on the Snapmaker forum outlines how to do it. https://forum.snapmaker.com/t/extruder-calibration-a-must/7724/33

I use the calibration card to measure and cut the filament at 10 on the card, i.e 100mm plus the dead space before the 0. But since I measure the extruded distance also with this space it can be ignored.

Make sure the hot end has reached the correct temperature for the filament you are calibrating with. And issue the command to start feeding the 100mm of filament. Once that finished measure the amount of filament left.

I had 23mm left this time. Then it is time to do the calculation. I find it easiest to start the developer tools in the browser. In the console there I just enter the expressions in the article.

Then use the Luban console to enter the newly calculated value and permanently store it. If you want to understand the M-commands like M92 this page was good, https://snapmaker.github.io/Documentation/gcode/M092

Finally make a test run with the same command that feeds 100mm of filament. Mine fed a few mm of extra filament.

This time I ignored the difference but if you want you can re-calibrate. Use your calculated S value as the new E in the calculation and enter how much filament that has been fed. Repeat until you are satisfied.

Alternatives to get Nexa support in Home Assistent

I found the OpenMQTTGateway project and got really interested since it can open up for a lot of interesting integrations to Home Assistant. I bought a LilyGo to start experimenting and could get it to read 433Mhz devices like Nexa. All this is possible due to the RTL_433_ESP library.

I wanted also to be able to write to the devices since I have several power plugs that use Nexa. That is not possible with just the LilyGo and the radio module on it. With the STX882 it should be possible to transmit. So I bought both a STX882 and a SRX882. This page describes how to connect these to a ESP32 or NodeMCU.

Have not yet tried to make the full setup and connect everything. Will update this post once I have tried that.

Maytech remote and MakerX VESC

Building the tow boogie I am using the Maytech MTSKR1905WF Remote and the MakerX Hi200/75V VESC together with the Flipsky 65161 motor. Here are som some quick notes about the settings I have used to get things to work as I want.

There is a circuits diagram on the Maytech page which makes it easy to connect the remote receiver and the VESC together using the pinout picture on the MakerX page.


VESC App settings:

  • if you are using firmware version 5.03 (VESC TOOL 3.1) or above – turn off the phase filter, see here for more details
  • Set App to Use to UART – gives much quicker response than the Maytech recommended UART and PPM.
  • Use the Maytech recommended Control Type: Current No Reverse under VESC Remote
  • For quicker response on the remote, change the Input Deadband to something like 3% under VESC Remote

VESC Motor Settings:

  • Set Motor Current Max to 140A
  • Do not set Motor Current Max Brake to 0A but some negativa number like -1A
  • Set Absolute Maximum Current to 180A

Here are some screen dumps to better explain the settings

App to Use: UART
VESC Remote settings
Motor Settings


Support RPM filtering?

Started flying FPV in October 2020 but have since then blown a couple of ESC. And each time I’m going to setup the new ones I ran into problems so this time I write down some notes to not have that happen again…

The most common problem I run into is that I turn on Bi-directional DShot in BetaFlight but then I get RPM_FILTER Disarm disabled flag turned on!! And cannot figure out why??

The answer and solution is quite simple. The default ESC firmware does not support bidirectional DShot! And this article describes how to get it. The ESCs I have one need to use BLHeli_S firmware. On my Nazgul 5 2 HD the ESC has the G H 30 configuration and currently I’m using version 16.73. So I download the G_H_30_REV16_73.HEX firmware and use BLHeli Configuration to flash it. Other versions can be downloaded from https://github.com/JazzMaverick/BLHeli/tree/JazzMaverick-patch-1/BLHeli_S%20SiLabs