How connect arduino mega with Home Assistant?

Hello @benoit-cty ! Your recomandation looks promising… Please share with me an Arduino sketch that will sent the temperature of a dht11 sensors and can control a 4 channel relay board. Thx

Hello, you don’t need a sketch, that’s the power of OpenMQTTGateway.
You need to install in the Arduino, and after you just configure what you want to do in Home Assistant in configuration.yaml:

  - platform: mqtt
    unique_id: cave.relais3.4
    name: "cave relais 3 -4"
    command_topic: "home/cave_mega/commands/MQTTtoONOFF"
    payload_on: '{"gpio":17,"cmd":1}'
    payload_off: '{"gpio":17,"cmd":0}'

You could search for OpenMQTTGateway in this forum, there is many thread about it.