CAN bus, well.
But what protocol between CAN bus devices?
CanOpen is wery huge for simply controllers, like Arduino etc.
And CAN message has only 8 bytes of data.
Of course, we can use some EXT ID bits too.
I try to integrate CAN bus to MYsensors project, but problem is, that domoticz sends data to Mysensors like strings, and 8 bytes are not enough in most cases.
I Try rewrite some libraries of MySensors, but now I think, the better way for me is code my own CAN bus ethernet gateway.
I love like ESPesay communicate with Domoticz, when I am able send JSON commands to domoticz and events from domoticz to ESPeasy.
I am planing translate this commands to my CAN protocol and vice versa.
About my CAN protocol.
I am using extended 29bit ID, first 6 bits are receivers ID, so I can set mask and filter registers so, that I receive only messages for my node or broadcast.
Others bits in ID and in payload I use for senders ID, sensor ID,message type , data type, data and etc.
( like Mysensors protocol )
I am using MCP2515 module.
I am able code to one CAN message:
6 bits - destination
6 bis - sender
(gateway, broadcast, 62 nodes - it is enough for me for one bus. I plane three buses and gateway can " translate " or "expand" nodes ID from and to controller )
1 bit - RACK
1 bit - IS ACK
3 bits - command
6 bits - type ( MY sensors has 56 types max. now )
6 bits - sensor id ( only 64 sensors per node ... )
3 bits - payload type ( int, uint, long .... )
The sum of these is not 29, but 32 so I am using a little "hacking" data length field in CAN frame to obtain additional 3 bits.
For data I have got 8 bytes.
It is enough for conventional data types from char to floating point.
Only text messages are limited to 8 bytes. But for us, old boys, who remember old DOS file names, it is enough.
Now I am able send data between nodes and between nodes and gateway.
I try a "stress test" like here:
https://forum.mysensors.org/topic/5051/ ... tress-test
I send 10 000 messages from two nodes to "gateway" at some time ( 22kbps ).
Result - zero messages lost.
But it is expectable with CAN.
Now I must connect this to Domoticz

(