No forward link or gateway feature activated, but I did.
-
-
@hek Tried both, doesn't make a difference. I'll include my sketch below.
#include <MySensors.h> #include <MyConfig.h> // Modalità debug //#define MY_DEBUG // Baud rate seriale mod. debug #define MY_BAUD_RATE 9600 //#define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_GATEWAY_ESP8266 #define MY_ESP8266_SSID "SSID" #define MY_ESP8266_PASSWORD "Password" //#define MY_USE_UDP #define MY_ESP8266_HOSTNAME "Sonoff1" //#define MY_IP_ADDRESS 192,168,178,87 // If using static ip you need to define Gateway and Subnet address as well //#define MY_IP_GATEWAY_ADDRESS 192,168,178,1 //#define MY_IP_SUBNET_ADDRESS 255,255,255,0 //Porta in ascolto #define MY_PORT 5003 // Numero massimo di client #define MY_GATEWAY_MAX_CLIENTS 2 // Enable inclusion mode #define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway // #define MY_INCLUSION_BUTTON_FEATURE // Set inclusion mode duration (in seconds) #define MY_INCLUSION_MODE_DURATION 60 // Digital pin used for inclusion mode button #define MY_INCLUSION_MODE_BUTTON_PIN 3 #define MY_REPEATER_FEATURE #define RELAY_1 12 // Pin del relè #define NUMBER_OF_RELAYS 1 // Numero di relè #define RELAY_ON 1 // Stato del pin per relè attivo #define RELAY_OFF 0 // Stato del pin per relè inattivo #if defined(MY_USE_UDP) #include <WiFiUdp.h> #endif #include <ESP8266WiFi.h> void before() { for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Imposta il quale pin è quello del relè pinMode(pin, OUTPUT); // Imposta il relè allo stato precedente (in caso salti la luce) digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF); } } void setup() { } void presentation() { // Invia informazioni versione al gateway sendSketchInfo("Relay", "1.0"); for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Presenta i sensori locali al gateway present(sensor, S_BINARY); } } void receive(const MyMessage &message) { // Controllo il messaggio inviato if (message.type==V_STATUS) { // Cambia stato relè digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF); // Memorizza stato relè saveState(message.sensor, message.getBool()); // Informazioni debug Serial.print("Cambiamento relè:"); Serial.print(message.sensor); Serial.print(", Nuovo Stato:"); Serial.println(message.getBool()); } } void loop() { } -
-
Always put the include after the defines. The sketch posted above is wrong and will fail at compile time. And remove the MyConfig.h include.
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