Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. skassa
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    skassa

    @skassa

    0
    Reputation
    2
    Posts
    207
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    skassa Follow

    Best posts made by skassa

    This user hasn't posted anything yet.

    Latest posts made by skassa

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

      thank you very much! 😉

      posted in General Discussion
      skassa
      skassa
    • How to tell to an ESP8266 node who is its ESP8266 Wifi gateway? Or each ESP8266 is a gateway for itself?

      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());
      }
      }

      posted in General Discussion
      skassa
      skassa