gkasprow / Sensor-Box

Multichannel standarized enviorement for home automation and other MQTT applications
18 stars 11 forks source link

CAN support #9

Open gkasprow opened 6 years ago

gkasprow commented 6 years ago

I have build a house and started looking for a home automation system that has several features:

So the idea is to use:

I designed simple circuit based on ATMEGA328PB which is ~1$ CPU and supports HAPCAN. I added CAN chipset (MCP2551 & MCP2515) - another 1.5$ and bistable relay - another 2$. There is also AC power detector (LM358 diff amplifier) and DC/DC converter (AP65111A) The PCB fits easily under the light switch obraz The schematic is here PCB was quickly auto-routed to confirm the components placement. I will route it manually later on.

I also ordered switch, relay and programmer from the company who develops HAPCAN. They already shipped so I will play with it soon.

gkasprow commented 6 years ago

To add support to Linux module, I initially implemented MCP2515 CAN controller. But it is not well supported in Linux due to lack of buffering. One can write bit-bang Linux driver that is not very elegant solution Another solution is to use existing implementation of UART/USB to CAN based on small MCU. I found a few, the most interesting is one based on low cost STM32 Cortex M0 CPU (~2$ chip). I ordered 2 pcs on Tindie and will test them once they arrive. I also replaced MCP2515 with STM32 solution to get rid of future problems with decoding of CAN frames.