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. General Discussion
  3. [Solved] Getting Arduino IDE error with Relay Actuator sketch

[Solved] Getting Arduino IDE error with Relay Actuator sketch

Scheduled Pinned Locked Moved General Discussion
6 Posts 3 Posters 71 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.
  • M Offline
    M Offline
    mrhutchinsonmn
    wrote on last edited by tekka
    #1

    https://www.mysensors.org/build/relay

    I am attempting to use the following sketch for a relay setup but getting the error below:

    /*
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2019 Sensnology AB
     * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik Ekblad
     *
     * DESCRIPTION
     * Example sketch showing how to control physical relays.
     * This example will remember relay state after power failure.
     * http://www.mysensors.org/build/relay
     */
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_RF24
    //#define MY_RADIO_NRF5_ESB
    //#define MY_RADIO_RFM69
    //#define MY_RADIO_RFM95
    
    // Enable repeater functionality for this node
    #define MY_REPEATER_FEATURE
    
    #include <MySensors.h>
    
    #define RELAY_PIN 4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 1 // 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_PIN; 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("Relay", "1.0");
    
      for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_BINARY);
      }
    }
    
    
    void loop()
    {
    
    }
    
    void receive(const MyMessage &message)
    {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.getType()==V_STATUS) {
        // Change relay state
        digitalWrite(message.getSensor()-1+RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
        // Store state in eeprom
        saveState(message.getSensor(), message.getBool());
        // Write some debug info
        Serial.print("Incoming change for sensor:");
        Serial.print(message.getSensor());
        Serial.print(", New status: ");
        Serial.println(message.getBool());
      }
    }
    
    
    wifi-enabled-relay:89:23: error: 'const class MyMessage' has no member named 'getSensor'; did you mean 'setSensor'?
         saveState(message.getSensor(), message.getBool());
                           ^~~~~~~~~
                           setSensor
    
    tekkaT 1 Reply Last reply
    0
    • nagelcN Offline
      nagelcN Offline
      nagelc
      wrote on last edited by
      #2

      That is weird. I can't see what is wrong. Especially since it compiled the one in digitalWrite.
      I just tried pasting your code into a sketch I was working on and it verified (different board and radio, but it doesn't seem like that should matter).
      Using Arduino 1.8.9

      1 Reply Last reply
      0
      • M mrhutchinsonmn

        https://www.mysensors.org/build/relay

        I am attempting to use the following sketch for a relay setup but getting the error below:

        /*
         * The MySensors Arduino library handles the wireless radio link and protocol
         * between your home built sensors/actuators and HA controller of choice.
         * The sensors forms a self healing radio network with optional repeaters. Each
         * repeater and gateway builds a routing tables in EEPROM which keeps track of the
         * network topology allowing messages to be routed to nodes.
         *
         * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
         * Copyright (C) 2013-2019 Sensnology AB
         * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
         *
         * Documentation: http://www.mysensors.org
         * Support Forum: http://forum.mysensors.org
         *
         * This program is free software; you can redistribute it and/or
         * modify it under the terms of the GNU General Public License
         * version 2 as published by the Free Software Foundation.
         *
         *******************************
         *
         * REVISION HISTORY
         * Version 1.0 - Henrik Ekblad
         *
         * DESCRIPTION
         * Example sketch showing how to control physical relays.
         * This example will remember relay state after power failure.
         * http://www.mysensors.org/build/relay
         */
        
        // Enable debug prints to serial monitor
        #define MY_DEBUG
        
        // Enable and select radio type attached
        #define MY_RADIO_RF24
        //#define MY_RADIO_NRF5_ESB
        //#define MY_RADIO_RFM69
        //#define MY_RADIO_RFM95
        
        // Enable repeater functionality for this node
        #define MY_REPEATER_FEATURE
        
        #include <MySensors.h>
        
        #define RELAY_PIN 4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
        #define NUMBER_OF_RELAYS 1 // 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_PIN; 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("Relay", "1.0");
        
          for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
            // Register all sensors to gw (they will be created as child devices)
            present(sensor, S_BINARY);
          }
        }
        
        
        void loop()
        {
        
        }
        
        void receive(const MyMessage &message)
        {
          // We only expect one type of message from controller. But we better check anyway.
          if (message.getType()==V_STATUS) {
            // Change relay state
            digitalWrite(message.getSensor()-1+RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
            // Store state in eeprom
            saveState(message.getSensor(), message.getBool());
            // Write some debug info
            Serial.print("Incoming change for sensor:");
            Serial.print(message.getSensor());
            Serial.print(", New status: ");
            Serial.println(message.getBool());
          }
        }
        
        
        wifi-enabled-relay:89:23: error: 'const class MyMessage' has no member named 'getSensor'; did you mean 'setSensor'?
             saveState(message.getSensor(), message.getBool());
                               ^~~~~~~~~
                               setSensor
        
        tekkaT Offline
        tekkaT Offline
        tekka
        Admin
        wrote on last edited by
        #3

        @mrhutchinsonmn Looks like your MySensors library is outdated, please update to 2.3.2

        M 1 Reply Last reply
        0
        • tekkaT tekka

          @mrhutchinsonmn Looks like your MySensors library is outdated, please update to 2.3.2

          M Offline
          M Offline
          mrhutchinsonmn
          wrote on last edited by
          #4

          @tekka Looks up to date to me.

          Screenshot from 2020-03-09 07-44-29.png

          tekkaT 1 Reply Last reply
          0
          • M mrhutchinsonmn

            @tekka Looks up to date to me.

            Screenshot from 2020-03-09 07-44-29.png

            tekkaT Offline
            tekkaT Offline
            tekka
            Admin
            wrote on last edited by
            #5

            @mrhutchinsonmn It compiles here, can you post the entire compilation log?

            M 1 Reply Last reply
            1
            • tekkaT tekka

              @mrhutchinsonmn It compiles here, can you post the entire compilation log?

              M Offline
              M Offline
              mrhutchinsonmn
              wrote on last edited by
              #6

              @tekka I moved the library and reinstalled. The sketch works now. Thank you for pointing me in the right direction!

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


              16

              Online

              11.7k

              Users

              11.2k

              Topics

              113.0k

              Posts


              Copyright 2019 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