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. How to tell to an ESP8266 node who is its ESP8266 Wifi gateway? Or each ESP8266 is a gateway for itself?

How to tell to an ESP8266 node who is its ESP8266 Wifi gateway? Or each ESP8266 is a gateway for itself?

Scheduled Pinned Locked Moved General Discussion
3 Posts 2 Posters 946 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.
  • S Offline
    S Offline
    skassa
    wrote on last edited by
    #1

    Hello,
    I created an ESP8266 Wifi gateway and everything is working very well.
    Now I need to create a node: mi question is... what the directive to say to the node who is its gateway?
    Or every ESP8266 has to be a gateway for itself?

    I'm using Openhab2.

    This is my sketch, what I'm missing, please? My gateway as 192.168.0.95 as IP address

    // Enable debug prints to serial monitor
    #define MY_DEBUG

    // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
    #define MY_BAUD_RATE 9600

    // Enable and select radio type attached
    //#define MY_RADIO_RF24
    //#define MY_RADIO_NRF5_ESB
    //#define MY_RADIO_RFM69
    //#define MY_RADIO_RFM95
    //#define MY_GATEWAY_ESP8266

    #define MY_WIFI_SSID "xxxx"
    #define MY_WIFI_PASSWORD "xxx"

    // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
    #define MY_IP_ADDRESS 192,168,0,88

    // If using static ip you can define Gateway and Subnet address as well
    #define MY_IP_GATEWAY_ADDRESS 192,168,0,1
    #define MY_IP_SUBNET_ADDRESS 255,255,255,0

    // Flash leds on rx/tx/err
    // Led pins used if blinking feature is enabled above
    #define MY_DEFAULT_ERR_LED_PIN 16 // Error led pin
    #define MY_DEFAULT_RX_LED_PIN 16 // Receive led pin
    #define MY_DEFAULT_TX_LED_PIN 16 // the PCB, on board LED

    #define MY_NODE_ID 1

    #if defined(MY_USE_UDP)
    #include <WiFiUdp.h>
    #endif

    #include <ESP8266WiFi.h>
    #include <MySensors.h>
    #include <ArduinoOTA.h>

    #define RELAY1 12
    #define RELAY2 13

    #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()
    {
    pinMode(RELAY1,OUTPUT);
    pinMode(RELAY2,OUTPUT);
    digitalWrite(RELAY1, loadState(RELAY1)?RELAY_OFF:RELAY_ON);
    digitalWrite(RELAY2, loadState(RELAY2)?RELAY_OFF:RELAY_ON);
    }

    void setup()
    {
    }

    void presentation()
    {
    // Send the sketch version information to the gateway and Controller
    sendSketchInfo("LuciFinestrone", "1.0");

    present(RELAY1, S_BINARY, "luceFinestrone",true);
    //present(RELAY2, S_BINARY, "light2",true);
    

    }

    void loop()
    {
    }

    void receive(const MyMessage &message)
    {
    // We only expect one type of message from controller. But we better check anyway.
    if (message.type==V_STATUS) {
    // Change relay state
    digitalWrite(message.sensor, 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());
    }
    }

    mfalkviddM 1 Reply Last reply
    0
    • S skassa

      Hello,
      I created an ESP8266 Wifi gateway and everything is working very well.
      Now I need to create a node: mi question is... what the directive to say to the node who is its gateway?
      Or every ESP8266 has to be a gateway for itself?

      I'm using Openhab2.

      This is my sketch, what I'm missing, please? My gateway as 192.168.0.95 as IP address

      // Enable debug prints to serial monitor
      #define MY_DEBUG

      // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
      #define MY_BAUD_RATE 9600

      // Enable and select radio type attached
      //#define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      //#define MY_GATEWAY_ESP8266

      #define MY_WIFI_SSID "xxxx"
      #define MY_WIFI_PASSWORD "xxx"

      // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
      #define MY_IP_ADDRESS 192,168,0,88

      // If using static ip you can define Gateway and Subnet address as well
      #define MY_IP_GATEWAY_ADDRESS 192,168,0,1
      #define MY_IP_SUBNET_ADDRESS 255,255,255,0

      // Flash leds on rx/tx/err
      // Led pins used if blinking feature is enabled above
      #define MY_DEFAULT_ERR_LED_PIN 16 // Error led pin
      #define MY_DEFAULT_RX_LED_PIN 16 // Receive led pin
      #define MY_DEFAULT_TX_LED_PIN 16 // the PCB, on board LED

      #define MY_NODE_ID 1

      #if defined(MY_USE_UDP)
      #include <WiFiUdp.h>
      #endif

      #include <ESP8266WiFi.h>
      #include <MySensors.h>
      #include <ArduinoOTA.h>

      #define RELAY1 12
      #define RELAY2 13

      #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()
      {
      pinMode(RELAY1,OUTPUT);
      pinMode(RELAY2,OUTPUT);
      digitalWrite(RELAY1, loadState(RELAY1)?RELAY_OFF:RELAY_ON);
      digitalWrite(RELAY2, loadState(RELAY2)?RELAY_OFF:RELAY_ON);
      }

      void setup()
      {
      }

      void presentation()
      {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("LuciFinestrone", "1.0");

      present(RELAY1, S_BINARY, "luceFinestrone",true);
      //present(RELAY2, S_BINARY, "light2",true);
      

      }

      void loop()
      {
      }

      void receive(const MyMessage &message)
      {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_STATUS) {
      // Change relay state
      digitalWrite(message.sensor, 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());
      }
      }

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      Welcome to the forum @skassa !

      Yes, normally each esp8266 will be each own gateway. Most controllers support many gateways.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        skassa
        wrote on last edited by
        #3

        thank you very much! ;)

        1 Reply Last reply
        0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        17

        Online

        12.0k

        Users

        11.2k

        Topics

        113.4k

        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