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. Vera
  4. Sonoff and Vera

Sonoff and Vera

Scheduled Pinned Locked Moved Vera
verarelaysonoff
8 Posts 3 Posters 6.5k Views 3 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.
  • nicomediaN Offline
    nicomediaN Offline
    nicomedia
    wrote on last edited by
    #1

    I'm completely new to MySensors, and I don't understand how it works 100%. I wanted to connect sonoff relays to my Vera, but I don't know how the connection works: it says on the website that the vera needs a serial or ethernet gateway, but why would I need that when the relay already has WiFi? Do I need to create multiple devices and configure them as a separate gateway for every relay? Thanks for your help.

    1 Reply Last reply
    0
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #2

      You would have to run the MySensors firmware on your Sonoff (acting as gateway) presenting and controlling the relays in the device.

      I haven't tried this myself (haven't got any sonoffs) but in theory it should work.

      1 Reply Last reply
      0
      • nicomediaN Offline
        nicomediaN Offline
        nicomedia
        wrote on last edited by
        #3

        Which one? The only firmware for the esp8266 that I can find is for gateway only, but the sonoff also has an onboard relay... Do I have to modify the code or something to make it work?

        1 Reply Last reply
        0
        • hekH Offline
          hekH Offline
          hek
          Admin
          wrote on last edited by
          #4

          You have to find out which ESP-pins that controls the relays and modify the gateway sketch using the Relay example as a hint.

          https://github.com/mysensors/MySensors/blob/development/examples/RelayActuator/RelayActuator.ino

          nicomediaN 1 Reply Last reply
          0
          • hekH hek

            You have to find out which ESP-pins that controls the relays and modify the gateway sketch using the Relay example as a hint.

            https://github.com/mysensors/MySensors/blob/development/examples/RelayActuator/RelayActuator.ino

            nicomediaN Offline
            nicomediaN Offline
            nicomedia
            wrote on last edited by
            #5

            @hek Sorry for being annoying, but I don't know anything about MySensors. I know that the relay is controlled by GPIO 12 and is active high. Do I flash the esp8266, the RelayActuator.ino or do I merge the two together? Thanks so much for your help.

            1 Reply Last reply
            0
            • hekH Offline
              hekH Offline
              hek
              Admin
              wrote on last edited by
              #6

              You will have to merge them.

              nicomediaN 1 Reply Last reply
              0
              • hekH hek

                You will have to merge them.

                nicomediaN Offline
                nicomediaN Offline
                nicomedia
                wrote on last edited by
                #7

                @hek Thank you so much! I've been able to write my code for the relay. The problem is that it doesn't compile because it finds errors in the mysensor.h library. How can I fix this? Did I do something wrong?

                Arduino: 1.8.0 (Mac OS X), Board: "Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS), ck, Disabled, None"
                
                Build options changed, rebuilding all
                In file included from /Users/Federico/Documents/Arduino/libraries/MySensors/MySensors.h:204:0,
                                 from /Users/Federico/Desktop/GatewayESP8266/GatewayESP8266.ino:44:
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:45:24: error: 'WiFiServer' does not name a type
                 #define EthernetServer WiFiServer
                                        ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:62:1: note: in expansion of macro 'EthernetServer'
                 EthernetServer _ethernetServer(_ethernetGatewayPort);
                 ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:46:24: error: 'WiFiClient' does not name a type
                 #define EthernetClient WiFiClient
                                        ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:69:8: note: in expansion of macro 'EthernetClient'
                 static EthernetClient clients[MY_GATEWAY_MAX_CLIENTS];
                        ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp: In function 'bool gatewayTransportInit()':
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:106:2: error: 'WiFi' was not declared in this scope
                  WiFi.mode (WIFI_STA);
                  ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:106:13: error: 'WIFI_STA' was not declared in this scope
                  WiFi.mode (WIFI_STA);
                             ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:114:26: error: 'WL_CONNECTED' was not declared in this scope
                  while (WiFi.status() != WL_CONNECTED) {
                                          ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:162:2: error: '_ethernetServer' was not declared in this scope
                  _ethernetServer.begin();
                  ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp: In function 'bool gatewayTransportSend(MyMessage&)':
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:212:37: error: 'clients' was not declared in this scope
                  for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) {
                                                     ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:36:32: note: in definition of macro 'ARRAY_SIZE'
                 #define ARRAY_SIZE(x)  (sizeof(x)/sizeof(x[0]))
                                                ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp: In function 'bool _readFromClient(uint8_t)':
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:228:9: error: 'clients' was not declared in this scope
                  while (clients[i].connected() && clients[i].available()) {
                         ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp: In function 'bool gatewayTransportAvailable()':
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:347:37: error: 'clients' was not declared in this scope
                  for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) {
                                                     ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:36:32: note: in definition of macro 'ARRAY_SIZE'
                 #define ARRAY_SIZE(x)  (sizeof(x)/sizeof(x[0]))
                                                ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:354:8: error: '_ethernetServer' was not declared in this scope
                    if (_ethernetServer.hasClient()) {
                        ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:367:26: error: '_ethernetServer' was not declared in this scope
                  if (allSlotsOccupied && _ethernetServer.hasClient()) {
                                          ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:46:24: error: 'WiFiClient' was not declared in this scope
                 #define EthernetClient WiFiClient
                                        ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:370:3: note: in expansion of macro 'EthernetClient'
                   EthernetClient c = _ethernetServer.available();
                   ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:370:18: error: expected ';' before 'c'
                   EthernetClient c = _ethernetServer.available();
                                  ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:371:3: error: 'c' was not declared in this scope
                   c.stop();
                   ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:374:37: error: 'clients' was not declared in this scope
                  for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) {
                                                     ^
                /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:36:32: note: in definition of macro 'ARRAY_SIZE'
                 #define ARRAY_SIZE(x)  (sizeof(x)/sizeof(x[0]))
                                                ^
                exit status 1
                Error compiling for board Generic ESP8266 Module.
                
                This report would have more information with
                "Show verbose output during compilation"
                option enabled in File -> Preferences.
                
                dbemowskD 1 Reply Last reply
                0
                • nicomediaN nicomedia

                  @hek Thank you so much! I've been able to write my code for the relay. The problem is that it doesn't compile because it finds errors in the mysensor.h library. How can I fix this? Did I do something wrong?

                  Arduino: 1.8.0 (Mac OS X), Board: "Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS), ck, Disabled, None"
                  
                  Build options changed, rebuilding all
                  In file included from /Users/Federico/Documents/Arduino/libraries/MySensors/MySensors.h:204:0,
                                   from /Users/Federico/Desktop/GatewayESP8266/GatewayESP8266.ino:44:
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:45:24: error: 'WiFiServer' does not name a type
                   #define EthernetServer WiFiServer
                                          ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:62:1: note: in expansion of macro 'EthernetServer'
                   EthernetServer _ethernetServer(_ethernetGatewayPort);
                   ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:46:24: error: 'WiFiClient' does not name a type
                   #define EthernetClient WiFiClient
                                          ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:69:8: note: in expansion of macro 'EthernetClient'
                   static EthernetClient clients[MY_GATEWAY_MAX_CLIENTS];
                          ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp: In function 'bool gatewayTransportInit()':
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:106:2: error: 'WiFi' was not declared in this scope
                    WiFi.mode (WIFI_STA);
                    ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:106:13: error: 'WIFI_STA' was not declared in this scope
                    WiFi.mode (WIFI_STA);
                               ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:114:26: error: 'WL_CONNECTED' was not declared in this scope
                    while (WiFi.status() != WL_CONNECTED) {
                                            ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:162:2: error: '_ethernetServer' was not declared in this scope
                    _ethernetServer.begin();
                    ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp: In function 'bool gatewayTransportSend(MyMessage&)':
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:212:37: error: 'clients' was not declared in this scope
                    for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) {
                                                       ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:36:32: note: in definition of macro 'ARRAY_SIZE'
                   #define ARRAY_SIZE(x)  (sizeof(x)/sizeof(x[0]))
                                                  ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp: In function 'bool _readFromClient(uint8_t)':
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:228:9: error: 'clients' was not declared in this scope
                    while (clients[i].connected() && clients[i].available()) {
                           ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp: In function 'bool gatewayTransportAvailable()':
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:347:37: error: 'clients' was not declared in this scope
                    for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) {
                                                       ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:36:32: note: in definition of macro 'ARRAY_SIZE'
                   #define ARRAY_SIZE(x)  (sizeof(x)/sizeof(x[0]))
                                                  ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:354:8: error: '_ethernetServer' was not declared in this scope
                      if (_ethernetServer.hasClient()) {
                          ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:367:26: error: '_ethernetServer' was not declared in this scope
                    if (allSlotsOccupied && _ethernetServer.hasClient()) {
                                            ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:46:24: error: 'WiFiClient' was not declared in this scope
                   #define EthernetClient WiFiClient
                                          ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:370:3: note: in expansion of macro 'EthernetClient'
                     EthernetClient c = _ethernetServer.available();
                     ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:370:18: error: expected ';' before 'c'
                     EthernetClient c = _ethernetServer.available();
                                    ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:371:3: error: 'c' was not declared in this scope
                     c.stop();
                     ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:374:37: error: 'clients' was not declared in this scope
                    for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) {
                                                       ^
                  /Users/Federico/Documents/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:36:32: note: in definition of macro 'ARRAY_SIZE'
                   #define ARRAY_SIZE(x)  (sizeof(x)/sizeof(x[0]))
                                                  ^
                  exit status 1
                  Error compiling for board Generic ESP8266 Module.
                  
                  This report would have more information with
                  "Show verbose output during compilation"
                  option enabled in File -> Preferences.
                  
                  dbemowskD Offline
                  dbemowskD Offline
                  dbemowsk
                  wrote on last edited by
                  #8

                  @nicomedia I stumbled on this doing a google search. Just wondering if you are still trying to get your Sonoff's working with your Vera controller? If so, I have written a blog post on the subject. It uses a different firmware called ESP Easy and an HTTP Switch plugin on the Vera rather than MySensors. but it works rather well for me. Here is the link to the blog post:
                  https://dan.bemowski.info/2017/07/04/using-a-sonoff-with-espeasy-and-vera/
                  I use this in conjunction with some MySensors wall switches that I built.
                  https://dan.bemowski.info/2017/06/11/my-start-into-open-source-hardware/

                  Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
                  Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

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


                  13

                  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