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
S

skassa

@skassa
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

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

    thank you very much! ;)

    General Discussion

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

    General Discussion
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular