# Building custom velbus devices

**URL:** <https://forum.velbus.eu/t/building-custom-velbus-devices/4125>\
**Category:** English\
**Created:** [October 15, 2010, 8:05am UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125 "2010-10-15T08:05:58Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![matthijsfh](https://forum.velbus.eu/user_avatar/forum.velbus.eu/matthijsfh/32/4397_2.png) [@matthijsfh](https://forum.velbus.eu/u/matthijsfh)\
**Post date:** [January 20, 2021, 11:20am UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/41 "2021-01-20T11:20:08Z")

</div>

Made great progress over the last days. Now have a “STM32” based VMB8PB module working.

![VMB8PB_velbus](https://forum.velbus.eu/uploads/default/original/2X/d/d5c8247c0e88d52ab46ff14ac4af6b00c3689002.png)

The STM32 responds to the “scan” request with the module type.  
Also the status request messages are answered.

Also all comands to read / write the memory have been implemented (although it now writes the RAM of the STM, so everthing is lost on power down). Have to check how to write the EEPROM of the STM32.

When I press the button, the corresponding channel message is send.  
Memory map of the VMB8PB is extremely simple, so that helped a lot.

Cleaning up code and then see if I can made a motion sensor input. Much more complicated as there are a lot more settings to handle.

See you,  
Matthijs

---

<div class="post-metadata">

**Author:** ![matthijsfh](https://forum.velbus.eu/user_avatar/forum.velbus.eu/matthijsfh/32/4397_2.png) [@matthijsfh](https://forum.velbus.eu/u/matthijsfh)\
**Post date:** [January 22, 2021, 1:16pm UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/42 "2021-01-22T13:16:32Z")

</div>

Dont know if any one is interested, but made another huge step.

Made a VMBPIRM module and now can write & read flash of the STM with the data from VelBusLink.  
So VelBusLink can write & read back the settings. I treat the parameter list as a blob (512 bytes) of data for now.

Of a few parameters I already know what they mean.

![Untitled](https://forum.velbus.eu/uploads/default/original/2X/b/b15e2dface1b17cbbb2b821ab4600c4373626714.png)

![Untitled2](https://forum.velbus.eu/uploads/default/original/2X/c/c37d35901c08291dc1adc0460857f159bffe4556.png)

**Next step** :

- Adding a physical motion sensor + LDR
- Write the logic (using some of) the parameters set in flash.
- Port to F1 device as that PCB is much smaller.

Grtz Matthijs

---

<div class="post-metadata">

**Author:** ![matthijsfh](https://forum.velbus.eu/user_avatar/forum.velbus.eu/matthijsfh/32/4397_2.png) [@matthijsfh](https://forum.velbus.eu/u/matthijsfh)\
**Post date:** [January 26, 2021, 8:47am UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/43 "2021-01-26T08:47:01Z")

</div>

Update:

Proto hardware is up and running. Blue pill with a modified CAN driver board. The regulator will be replaced by a DC-DC upcomming days. This one runs hot.

Will add the motion sensor tonight. Everything still fits in power socket in the wall.

 ![WhatsApp Image 2021-01-26 at 09.36.06](https://forum.velbus.eu/uploads/default/original/2X/0/0f631e14eb0c2781cad05b358889ffcb3d7222d0.jpeg)

 ![WhatsApp Image 2021-01-26 at 09.36.06 (1)](https://forum.velbus.eu/uploads/default/original/2X/1/190da34c44c46f03d6b4a413b1b22df09174bd0b.jpeg)

Most likely will make a custom PCB later on. Think I need about 5 of them around the house for motion detection. But this board can simulate any VelBus module if needed (and invested enough time to make it work).

Greetings Matthijs

---

<div class="post-metadata">

**Author:** ![matthijsfh](https://forum.velbus.eu/user_avatar/forum.velbus.eu/matthijsfh/32/4397_2.png) [@matthijsfh](https://forum.velbus.eu/u/matthijsfh)\
**Post date:** [January 31, 2021, 10:03am UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/44 "2021-01-31T10:03:12Z")

</div>

1st module installed & working.

![WhatsApp Image 2021-01-31 at 10.34.05](https://forum.velbus.eu/uploads/default/original/2X/d/d3f0eaa9888bc42b1df39b4724f6277da98d35ba.jpeg)

 ![WhatsApp Image 2021-01-31 at 11.00.34](https://forum.velbus.eu/uploads/default/original/2X/9/9ecfe2a4feb4b3d1c9d7c5059346faf2246f6197.jpeg)

 ![WhatsApp Image 2021-01-31 at 11.00.49](https://forum.velbus.eu/uploads/default/original/2X/4/4090e91976bce119f28c13a803602d6e2b1afdef.jpeg)

So things are looking pretty good. Used the same switch covers as used in the rest of the hallway.  
Might be looking for some more fancy “glass” likes on aliexpress.

Also designed a PCB to reduce the wire mess on te back of the module. This makes it also easier to multiply the design.

 ![WhatsApp Image 2021-01-31 at 11.05.32](https://forum.velbus.eu/uploads/default/original/2X/e/e75e9a46eef456cee3b3f78e165b6ef228588358.jpeg)

The STM32 board goes underneath this board. Kind of piggy bag board. Power supply from 15 VDC to 5 VDC (CAN & motion) and down to 3.3 V for the STM32. 2 red blocks are screw terminals for the 4 bus wires.

Grtz Matthijs

---

<div class="post-metadata">

**Author:** ![matthijsfh](https://forum.velbus.eu/user_avatar/forum.velbus.eu/matthijsfh/32/4397_2.png) [@matthijsfh](https://forum.velbus.eu/u/matthijsfh)\
**Post date:** [February 8, 2021, 4:37pm UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/45 "2021-02-08T16:37:36Z")

</div>

😃

PCB’s from China. Now waiting for the components to arrive.

Looking gooooood!

 ![WhatsApp Image 2021-02-08 at 17.35.24](https://forum.velbus.eu/uploads/default/original/2X/1/1869326c5b3fcdaa4a29460434794b8addd888d4.jpeg)

---

<div class="post-metadata">

**Author:** ![matthijsfh](https://forum.velbus.eu/user_avatar/forum.velbus.eu/matthijsfh/32/4397_2.png) [@matthijsfh](https://forum.velbus.eu/u/matthijsfh)\
**Post date:** [February 18, 2021, 8:56pm UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/46 "2021-02-18T20:56:11Z")

</div>

Another update. Things are working!

The PCB I made with 5V and 3.3 V regulators and MCP2551 driver.

 ![WhatsApp Image 2021-02-18 at 21.47.45](https://forum.velbus.eu/uploads/default/original/2X/f/f0befa43a537cc8f4e2191459ab19b15e67f108b.jpeg)

STM32F103 on the back side.

 ![WhatsApp Image 2021-02-18 at 21.47.45 (1)](https://forum.velbus.eu/uploads/default/original/2X/a/a6d220e0e770b91e01eb61bbf1c6c49ba2b24290.jpeg)

So the hardware is working and fits inside a junction box in the wall.

Bought a motion sensor with glass look on aliexpress. Removed the electronics and place the new module in there.

![WhatsApp Image 2021-02-18 at 21.51.47](https://forum.velbus.eu/uploads/default/original/2X/5/5f8c73f9a039bec072d38935abdacf935508c06a.jpeg)

Now playing around with the software. Still some bugs to fix. Also I implemented only a limited set of features.

Want to use the same board (and software) to mimic an VMB8PB module too, so have to make some more changes to the software. That project will follow soon.

Grtz Matthijs

---

<div class="post-metadata">

**Author:** ![matthijsfh](https://forum.velbus.eu/user_avatar/forum.velbus.eu/matthijsfh/32/4397_2.png) [@matthijsfh](https://forum.velbus.eu/u/matthijsfh)\
**Post date:** [March 26, 2021, 12:21pm UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/47 "2021-03-26T12:21:34Z")

</div>

Progress!

Currently have 4 DIY Velbus like modules operating in the house.

- 2x VMBPIRM (motion sensors)
- 1x VMB8PB (only single button to control the blinds)
- 1x VMB8PB **analog** version. _A special version which can measure 2 analog inputs and compare those input values to 4 reference values to determine “above”, “in between”, “below”._

The UBS interface which I created is 99% compatible (must be some hidden features which I overlooked, so no 100%). But both VelBusLink and Velserv are happy with the interface and work perfectly with it.

 ![WhatsApp Image 2021-03-25 at 21.42.43](https://forum.velbus.eu/uploads/default/original/2X/f/f7c2644d264a472703d8245eb89acbc270054927.jpeg)

The VMB8PB emulator sends its status every few seconds. This is done to enable development of the other modules and have some triggers to respond to.

Plan is to start developing an “VMB4RYLD” output module. But as output modules contain the “rules” / “actions”, this module will be much more complex to emulate compared to the VMB8PB module.

But has been great fun so far and @Ggaljoen joined the team.

Ofcourse we will not be able to “clone” the original VelBus hardware 100%. But that is also not the purpose. Adding a few DIY modules to the existing genuine VelBus is enough. Meanwhile we are having great fun and learning a lot about STM32 too.

Grtz Matthijs

---

<div class="post-metadata">

**Author:** ![matthijsfh](https://forum.velbus.eu/user_avatar/forum.velbus.eu/matthijsfh/32/4397_2.png) [@matthijsfh](https://forum.velbus.eu/u/matthijsfh)\
**Post date:** [April 16, 2021, 10:35am UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/48 "2021-04-16T10:35:54Z")

</div>

**Another update…**

 ![fa97b073-142b-499b-81af-77ac3012f13e](https://forum.velbus.eu/uploads/default/original/2X/9/95f7218c0b0d8c5bb57a5813af8f321b7b458567.jpeg)

@Ggaljoen helped the project and made a logger which displays the CAN data on the bus onto an LCD screen. The screen is a “standard” arduino project which uses an STM32 too, and he added extensive logging to the velbus modules. Basically this logging is the same as the one found in VelBusLink, but then in hardware.

Logging is working so good, that Gert is going to make a dedicated logging VelBus module. Very handy when debugging the commands. And can be installed in the VelBus installation permanently.

This will definitely increase the “nerd” level of the VelBus system and impress my non-technical friends and make their heads explode. Just like the screens in the matrix movies. 😆

Will post more on that later.

Greetings Matthijs

---

<div class="post-metadata">

**Author:** ![Robbe](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/r/df788c/32.png) [@Robbe](https://forum.velbus.eu/u/Robbe)\
**Post date:** [January 27, 2023, 1:05pm UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/49 "2023-01-27T13:05:58Z")

</div>

Really nice and interesting work Matthijs! 🙂

Would it be possible to create a microwave sensor that can be hidden in the ceiling for motion detection that can attach to the bus?

---

<div class="post-metadata">

**Author:** ![PrzemoF](https://forum.velbus.eu/user_avatar/forum.velbus.eu/przemof/32/4758_2.png) [@PrzemoF](https://forum.velbus.eu/u/PrzemoF)\
**Post date:** [April 5, 2023, 1:43pm UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/50 "2023-04-05T13:43:24Z")

</div>

@matthijsfh Fantastic work! Please post if you have any updates or anything you can share: code, PCB plans, documentation, etc. It would be a shame if it got lost! 🙂 I’m gathering info if it’s possible to make a swimming pool chlorination and pump controller (\*) (a few digital and analog signals) and looks like what you’ve done is perfect starting point 🙂

(\*) controller might not be the best word - interface for monitoring and commanding the actual controller provided by the vendor of the system.

---

<div class="post-metadata">

**Author:** ![matthijsfh](https://forum.velbus.eu/user_avatar/forum.velbus.eu/matthijsfh/32/4397_2.png) [@matthijsfh](https://forum.velbus.eu/u/matthijsfh)\
**Post date:** [June 16, 2023, 9:45am UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/51 "2023-06-16T09:45:32Z")

</div>

Hai,

Not much progress. Most of my “modules with the same velbus interfaces” are working good enough to keep the wife happy 🙂

I did make a 5 channel output module. It has the basic behaviour of the VMB4RYLD, but only with the basic relay commands (no timers, no special stuff. On/Off/Follow and forced on/ off.)

Works well and saves me quite some money. The original modules are \> 200 EUR each. So have a few official modules and now some DIY to get more IO on the bus.

Also finding the limits of the way I implemented the code. As I did not know how to start, my code is not optimal now things are getting very complicated. So the moment to call it a day is coming.

 ![Screenshot_20221110-104103_WhatsApp](https://forum.velbus.eu/uploads/default/original/2X/8/8b6a57815b8c878e88b33b871d887cb7eb071b50.jpeg)

1 Thing on the list is to use the STM32F103 spare capacity better and have multiple Velbus modules running on a single STM32F103. “Only” 5 outputs is a waste of uP real estate.

Greetings Matthijs

---

<div class="post-metadata">

**Author:** ![Ggaljoen](https://forum.velbus.eu/user_avatar/forum.velbus.eu/ggaljoen/32/4097_2.png) [@Ggaljoen](https://forum.velbus.eu/u/Ggaljoen)\
**Post date:** [June 23, 2023, 10:17am UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/52 "2023-06-23T10:17:07Z")

</div>

With the new ESP32 types (before you got stuck with the lower limit of 50kbps) , you can communicate with other Velbus components.

 ![20230619_063830](https://forum.velbus.eu/uploads/default/original/2X/8/8a0da47536ce1b2f606579c0a5ea9914a8e0fef7.jpeg)  
That is all required hardware (around € 15), “only” software and imagination are your limitation.

---

<div class="post-metadata">

**Author:** ![matthijsfh](https://forum.velbus.eu/user_avatar/forum.velbus.eu/matthijsfh/32/4397_2.png) [@matthijsfh](https://forum.velbus.eu/u/matthijsfh)\
**Post date:** [June 23, 2023, 6:11pm UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/53 "2023-06-23T18:11:13Z")

</div>

My 2 cents:

WiFi bridge between 2 parts of a Velbus network. So connect a local network (in my garage) over WiFi with the main network in the house.

Any other ideas! **Please let us know!**  
Interested in helping? **Please let us know!**

Greetings Matthijs & Gert.

---

<div class="post-metadata">

**Author:** ![MDAR](https://forum.velbus.eu/user_avatar/forum.velbus.eu/mdar/32/4215_2.png) [@MDAR](https://forum.velbus.eu/u/MDAR)\
**Post date:** [September 17, 2023, 5:35pm UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/55 "2023-09-17T17:35:31Z")

</div>

> [@matthijsfh](#):
>
> WiFi bridge between 2 parts of a Velbus network. So connect a local network (in my garage) over WiFi with the main network in the house.

I’ve only just seen this.

Jeroen’s VelServ can do this already.

If the second unit is set to slave mode.

---

<div class="post-metadata">

**Author:** ![EvAndy](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/e/dc4da7/32.png) [@EvAndy](https://forum.velbus.eu/u/EvAndy)\
**Post date:** [September 18, 2023, 4:25pm UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/56 "2023-09-18T16:25:10Z")

</div>

Has anyone here actually managed to get ESP32 (V2 or 3) talking to velbus at 16.6 kBd?

I just ended up in some sort of Windows installer/IDE hell. VScode IDF components complaining that they didn’t have permissions to update or Arduino IDE libs not working at these low baud rates and cross compilation and python tools installed in very strange places so they don’t work from normal command lines and I cannot see how to set environment to use them directly.

I can see how to get the extra divide by 2 and modify an existing arduino lib but I can’t see how that is sufficient to get down as low as 12.5 kBd like the Espressif docs seem to suggest their SDK can manage. What has happened to arduino since ESP32 and MBED came along and they started wrapping everything? It used to be simple.

If anyone has an ESP32 _simple_ example before I go crazy that would be great.

Alternatively I did manage to get Raspberry Pi Pico talking to Velbus fairly easily using Kevin OConnor’s can2040 driver (a software implementation of CAN2.0 good for up to 1MBd). That is fine but since the Pico Wifi has a ESP32 on board for the WiFi part that seems a bit unnecessary.

---

<div class="post-metadata">

**Author:** ![Ggaljoen](https://forum.velbus.eu/user_avatar/forum.velbus.eu/ggaljoen/32/4097_2.png) [@Ggaljoen](https://forum.velbus.eu/u/Ggaljoen)\
**Post date:** [September 18, 2023, 5:14pm UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/57 "2023-09-18T17:14:06Z")

</div>

It is possible in the Arduino IDE to get it down to VelBus speed with the TWAI library, but a 1 digit change is required.  
The file twai\_types.h has a config for 16KBITS, the parameter “tseg\_1” should not read 16 but 15.

What do you have in mind for the ESP32 (S2/S3/C3), a special use case in the make?

---

<div class="post-metadata">

**Author:** ![EvAndy](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/e/dc4da7/32.png) [@EvAndy](https://forum.velbus.eu/u/EvAndy)\
**Post date:** [September 18, 2023, 5:48pm UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/58 "2023-09-18T17:48:18Z")

</div>

I see… so they push the bit-read right out to the end? With the extra /2 and BRP=62 and TSEG2 still 1, I make that maybe 16.7 KBd … which is probably close enough?

Which arduino CAN/TWAI library are you looking at?  
The “arduino-CAN” library I found on github does not use twai\_types.h; it just has a switch on the speed that sets the BTR1 and BTR0 register values but the settings for \< 40kBd don’t work of course because the BRP ends up being more than 6 bits. It does not seem to to use the IDF driver support… just talks to the SJA1000 regs directly.

I have a few Wemos D1 Mini (ESP-WROOM-32 v3) on the shelf here and some older ESP-PICO-KIT development boards. I do not have anything in particular in mind yet… I just thought I would try a few different approaches (rPi-Pico, ESP32, STM32) for entertainment… to see which was simplest and most useful.

After messing around with painful Espressif and ST dev tools and VS-code all on Windows I think what I would most like to do is write a simple 8-bit AVR software driver instead :-/

Having ESP32 WiFi would be cool though… bound to be useful.

---

<div class="post-metadata">

**Author:** ![Ggaljoen](https://forum.velbus.eu/user_avatar/forum.velbus.eu/ggaljoen/32/4097_2.png) [@Ggaljoen](https://forum.velbus.eu/u/Ggaljoen)\
**Post date:** [September 18, 2023, 6:14pm UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/59 "2023-09-18T18:14:41Z")

</div>

> [@EvAndy](#):
>
> Which arduino CAN/TWAI library are you looking at?

The espressif Arduino-ESP32 support from; [Installing - - — Arduino ESP32 latest documentation](https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html)

> [@EvAndy](#):
>
> to see which was simplest and most useful.

So far for the simple part?

> [@EvAndy](#):
>
> Having ESP32 WiFi would be cool though

There is a serious potential with the newer versions, my test did work on a ESP32S3 (have my doubts about your ESP32 v3 even being compatible).

---

<div class="post-metadata">

**Author:** ![EvAndy](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/e/dc4da7/32.png) [@EvAndy](https://forum.velbus.eu/u/EvAndy)\
**Post date:** [September 18, 2023, 8:53pm UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/60 "2023-09-18T20:53:40Z")

</div>

Oh… I was expecting Arduino libs… but you’re using the ESP-IDF headers in Arduino and then using the ESP-IDF driver?

I think the extra BRP divider started from ESP32 v2 hardware. I came across it in this old ESP32 forum post (in a 2021 post further down)

> **[CAN controller clock and slow CAN bitrates - ESP32 Forum](https://esp32.com/viewtopic.php?f=12&t=2142&sid=a67ce85dc1e8597d64117183a4014870)**
>
> Espressif ESP32 Official Forum

I have not looked at doing it with ESP-IDF directly. I thought there would be an Arduino lib that would be simpler… maybe even a lib that compatible with Arduino CAN support for Uno v4 and STM32.

I haven’t tried using ESP-IDF in Arduino. Thanks, I’ll go find an ESP-IDF TWAI example and take a look at what’s needed. I’ll pick up an ESP32S3 too, just in case 🙂

---

<div class="post-metadata">

**Author:** ![EvAndy](https://forum.velbus.eu/letter_avatar_proxy/v4/letter/e/dc4da7/32.png) [@EvAndy](https://forum.velbus.eu/u/EvAndy)\
**Post date:** [September 21, 2023, 5:03pm UTC](https://forum.velbus.eu/t/building-custom-velbus-devices/4125/61 "2023-09-21T17:03:47Z")

</div>

I found a S2 in my parts box (a small Adafruit QtPy ESP32-S2uFL) and that seems to work nicely.

Rather than modify the header you can just add the extra line to the source file where you do call twai\_driver\_install()…

#define TWAI\_TIMING\_CONFIG\_16K6BITS() {.brp = 200, .tseg\_1 = 15, .tseg\_2 = 8, .sjw = 3, .triple\_sampling = false}

So thanks v.much for the hints.

I can get the WROOM32 parts to work too as long as they are v2 or greater (my D1 Mini are v3.1). Its only the original 2016 WROOMs that have the old 1.0 chip version.

So I now have code running on Pi Pico, WROOM-32, ESP32-S2 and ESP32-S3, and STM32F103.

And have you seen [Canable.io](http://Canable.io)? All open source. It uses a newer STM part… STM32F042/F072, that is capable of running both USB and CAN at the same time (unlike the F103). There is a pretty cheap official ST Nucleo-F042K2 dev board but there are also adapters like this one…

> **[DSD TECH USB to CAN Bus Adapter Based on Open Hardware Canable: Amazon.co.uk:...](https://www.amazon.co.uk/DSD-TECH-Adapter-Hardware-Canable/dp/B0BQ5G3KLR)**
>
> The SH-C30A is derived from the open source hardware project Canable, which differs from other commercial USB CAN products in that all the information (schematics, BOM list, Gerb files) is publicly available on the DSD TECH website. Also, if you are...

It has no 16600 bd support out of the box but that is easily fixed.  
I have a few very small CAN-AVR boards I might try out too.  
Only thing I am missing now is the usual cheap MCP2515 boards on a.n.other MCU.

So lots of options to play with.  
Still no idea what I will do with any of this yet but it’s interesting to play with.

[Previous page](https://forum.velbus.eu/t/building-custom-velbus-devices/4125.md?page=2)

[Next page](https://forum.velbus.eu/t/building-custom-velbus-devices/4125.md?page=4)
