Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. Home Assistant
  4. Adding Multiple Relay to Home Assistant

Adding Multiple Relay to Home Assistant

Scheduled Pinned Locked Moved Home Assistant
1 Posts 1 Posters 695 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Artur Csepregi
    wrote on last edited by
    #1

    Hello

    In struggling with adding more relays to Home assistant, till now only this sketch was working.
    but wit it I can add only 1 Relay, pleas help me to add more relays

    /*

    • Documentation: http://www.mysensors.org
    • Support Forum: http://forum.mysensors.org
    • http://www.mysensors.org/build/relay
      */

    #include <MySensor.h>
    #include <SPI.h>

    #define SN "Relay"
    #define SV "1.0"
    #define CHILD_ID 1
    #define RELAY_PIN 3

    MySensor gw;
    MyMessage msgRelay(CHILD_ID, V_STATUS);

    void setup()
    {
    gw.begin(incomingMessage);
    gw.sendSketchInfo(SN, SV);
    // Initialize the digital pin as an output.
    pinMode(RELAY_PIN, OUTPUT);
    gw.present(CHILD_ID, S_BINARY);
    gw.send(msgRelay.set(0));
    }

    void loop()
    {
    gw.process();
    }

    void incomingMessage(const MyMessage &message)
    {
    if (message.type == V_STATUS) {
    // Change relay state.
    digitalWrite(RELAY_PIN, message.getBool() ? 1 : 0);
    gw.send(msgRelay.set(message.getBool() ? 1 : 0));
    }
    }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    12

    Online

    11.7k

    Users

    11.2k

    Topics

    113.1k

    Posts


    Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • MySensors
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular