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. MyController.org
  4. MyController (Ubuntu) + Ethernet Gateway + Relay Board

MyController (Ubuntu) + Ethernet Gateway + Relay Board

Scheduled Pinned Locked Moved MyController.org
2 Posts 2 Posters 1.0k Views 2 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.
  • Z Offline
    Z Offline
    ZachFlem
    wrote on last edited by
    #1

    Hi folks,

    I'm trying to get MyController to see my Ethernet Gateway and the 4xRelay board that's connected to it.

    I can use the relay board with a simple webserver sketch, seperate to mycontroller, so I can only assume that the wiring is correct.

    I can ping the MySensors(2.1.1) Gateway from my laptop and from the ubuntu server.

    I can add the Gatewat to MyController and it shows status as "Connected Successfully" and a nice green tick.

    And this is where I get stuck.

    Either I am not doing something correctly, or for some reason, my relay board isn't showing up/available.

    I am currently using sketches with as little modification as possible, gleaned directly from tutorials etc.

    Any advice greatly appreciated.

    TIA

    Zach

    Sketch Here:

    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    // Enable gateway ethernet module type 
    #define MY_GATEWAY_W5100 
    
    // IP Connection
    #define MY_IP_ADDRESS 10,0,0,201                              // If this is disabled, DHCP is used to retrieve address
    #define MY_PORT 5003                                          // The port to keep open on node server mode / or port to contact in client mode
    #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED     // MAC Address, can be anything, but must be unique on the network
    
    // Include the various Libraries
    #include <SPI.h>
    #include <Ethernet.h>
    #include <MySensors.h>
    
    // Define relays
    #define RELAY_1  6            // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 4    // Total number of attached relays
    #define RELAY_ON 1            // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0           // GPIO value to write to turn off attached relay
    
    
    void before() { 
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
        // Then set relay pins in output mode
        pinMode(pin, OUTPUT);   
        // Set relay to last known state (using eeprom storage) 
        digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
      }
    }
    void setup()
    {
    }
    
    void presentation()  
    {   
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Audry - Gateway w/Relays", "0.1");
    
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_LIGHT);
      }
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_LIGHT) {
         // Change relay state
         digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
         // Store state in eeprom
         saveState(message.sensor, message.getBool());
         // Write some debug info
         Serial.print("Incoming change for sensor:");
         Serial.print(message.sensor);
         Serial.print(", New status: ");
         Serial.println(message.getBool());
       } 
    }
    
    void loop() {
    }
    
    J 1 Reply Last reply
    0
    • Z ZachFlem

      Hi folks,

      I'm trying to get MyController to see my Ethernet Gateway and the 4xRelay board that's connected to it.

      I can use the relay board with a simple webserver sketch, seperate to mycontroller, so I can only assume that the wiring is correct.

      I can ping the MySensors(2.1.1) Gateway from my laptop and from the ubuntu server.

      I can add the Gatewat to MyController and it shows status as "Connected Successfully" and a nice green tick.

      And this is where I get stuck.

      Either I am not doing something correctly, or for some reason, my relay board isn't showing up/available.

      I am currently using sketches with as little modification as possible, gleaned directly from tutorials etc.

      Any advice greatly appreciated.

      TIA

      Zach

      Sketch Here:

      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      // Enable gateway ethernet module type 
      #define MY_GATEWAY_W5100 
      
      // IP Connection
      #define MY_IP_ADDRESS 10,0,0,201                              // If this is disabled, DHCP is used to retrieve address
      #define MY_PORT 5003                                          // The port to keep open on node server mode / or port to contact in client mode
      #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED     // MAC Address, can be anything, but must be unique on the network
      
      // Include the various Libraries
      #include <SPI.h>
      #include <Ethernet.h>
      #include <MySensors.h>
      
      // Define relays
      #define RELAY_1  6            // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 4    // Total number of attached relays
      #define RELAY_ON 1            // GPIO value to write to turn on attached relay
      #define RELAY_OFF 0           // GPIO value to write to turn off attached relay
      
      
      void before() { 
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      }
      void setup()
      {
      }
      
      void presentation()  
      {   
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Audry - Gateway w/Relays", "0.1");
      
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          present(sensor, S_LIGHT);
        }
      }
      
      void receive(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
           // Change relay state
           digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
           // Store state in eeprom
           saveState(message.sensor, message.getBool());
           // Write some debug info
           Serial.print("Incoming change for sensor:");
           Serial.print(message.sensor);
           Serial.print(", New status: ");
           Serial.println(message.getBool());
         } 
      }
      
      void loop() {
      }
      
      J Offline
      J Offline
      jkandasa
      Plugin Developer
      wrote on last edited by
      #2

      @zachflem Can you see a node 0? Select your gateway and run Discover

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


      28

      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