Navigation

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

    stephenmhall

    @stephenmhall

    34
    Reputation
    71
    Posts
    1521
    Profile views
    2
    Followers
    1
    Following
    Joined Last Online

    stephenmhall Follow

    Best posts made by stephenmhall

    • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.

      Hi Guys. A rather specific project that may not be much use to many others but maybe of interest if you are looking for individual radiator heater control.

      I tried the Stella-Z radiator controllers with Vera and in all honesty they were crap, they talk to the system only rarely and they only hold one setpoint at a time, all in all no good.

      So I ended up getting a full set of the eq-3 MAX! kit with 7 radiator controllers, 3 wall thermostats an eco button and the central Cube controller. Apart from the supplied software being a little annoying with it sometimes messing with the heating times it is great. I solved the software problem in the app store with MAX! Remote unofficial replacement software, very good. The only problem I was left with was my Boiler.

      British Gas Boiler fitted with a single wireless wall thermostat in the living room. I had already upgraded the simple thermostat to a Drayton +3RF giving me daily timings but it still just took the one temperature. The problem being if the temp was up in the living room at night the heat would go off and the bedrooms would not heat up for going to bed.

      So to my solution. I already have a Vera automation controller and Mysensors nodes, so I now have a Raspberry Pi that polls the Cube to get all the valve open percentages if it decides the boiler needs to be on it sends a message to the Vera which transmits out on a Mysensors 433Mhz transmitter node to turn the boiler on. The Rpi has a web interface accessible in the house so I can see current temps and boiler state and also a graph of past temps for each room. I hope to implement the Cube controls in the web interface eventually so I don't need 2 pieces of software.

      Web UI
      2015-11-29.png

      Graph
      2015-11-29 (1).png

      Rpi2 very stock and I code in Python
      Heating Pi2.jpg

      And Finally the Mysensor Board, Just done today, has been running on a breadboard until now.
      heating_Mysensor.jpg

      It still needs a box printing.

      I could wire the RPi into the boiler switch direct but I want to have the old Thermostat as backup just in case.

      So if you have a Vera and MAX! radiator valves and an Rpi and a Drayton controlled Boiler, this is for you 🙂

      If anyone is interested I will post the code. It is very much my code as in an actual Python developer would go "What the!!" but it works. So far.

      posted in My Project
      stephenmhall
      stephenmhall
    • RE: Request: New Sensor Type ? Thermostatically controlled switch

      I went with your suggestion, its definitely a work in progress, but there is progress.
      I have a nano with DHT22 sensor and a relay for heating on/off.
      I played with the I_Arduino.xml and L_Arduino.lua files and added

      HVAC = {26, "urn:schemas-upnp-org:device:HVAC_ZoneThermostat:1", "D_HVAC_ZoneThermostat1.xml", "HVAC "}
      
      HVAC = {40, "urn:upnp-org:serviceId:TemperatureSetpoint1", "CurrentSetpoint", "" }
      
      function SetTheNewHvacTemp(device, NewCurrentSetpoint)
      	sendCommand(luup.devices[device].id,"HVAC",NewCurrentSetpoint)
      end
      

      to L_Arduino.lua

      and

      <action>
        <serviceId>urn:upnp-org:serviceId:TemperatureSetpoint1</serviceId>
          <name>SetCurrentSetpoint</name>
            <job>
              if (p ~= nil) then p.SetTheNewHvacTemp(lul_device, lul_settings.NewCurrentSetpoint)  end
        			return 4,0
            </job>
      </action>
      

      to I_Arduino.xml

      Also added V_HVAC and S_HVAC to MyMessage.h for Arduino.

      And I get this on Vera Edge UI7

      vera_arduino_hvac.png

      As of now I can change the setpoint, although it comes back from the node as 27.6 which throws off the vera temp display, makes it 2 line but shows it, I can also send the states "CoolOn", "HeatOn" and so on.

      I haven't worked out how to get the temp on the card instead of separate, or the battery level yet.

      Here is serial from node
      vera_arduino_hvac_serial.png

      Here is my node sketch

      #include <SPI.h>
      #include <MySensor.h>  
      #include <DHT.h>
      #include <Bounce2.h>
      
      #define NODE_ID AUTO
      #define SKETCH_NAME "MySensor_Heater"
      #define SKETCH_VERSION "1.1"
      #define NODE_REPEAT true
      
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      #define CHILD_ID_HVAC 2
      #define CHILD_ID_BATT 3
      #define CHILD_ID_HEATER_SW 4
      
      #define HUMIDITY_SENSOR_DIGITAL_PIN 3
      #define RELAY_PIN  4  // Arduino Digital I/O pin number for relay 
      #define BUTTON_PIN  5  // Arduino Digital I/O pin number for button 
      #define RELAY_ON 0
      #define RELAY_OFF 1
      unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
      
      Bounce debouncer = Bounce(); 
      int oldValue=0;
      bool state;
      MySensor gw;
      DHT dht;
      float lastTemp;
      float lastHum;
      boolean metric = true;
      unsigned long CHECK_TIME = millis();
      String heaterMode = "Off";
      int setPoint = 20;
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgHeaterSW(CHILD_ID_HEATER_SW,V_HEATER_SW);
      //MyMessage msgHeaterState(CHILD_ID_HEATER_STATE,V_HEATER);
      MyMessage msgHvac(CHILD_ID_HVAC, V_HVAC);
      MyMessage msgBattery(CHILD_ID_BATT, I_BATTERY_LEVEL);
      
      void setup()  
      { 
        gw.begin(incomingMessage,NODE_ID,NODE_REPEAT);
        dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
      
        // Send the Sketch Version Information to the Gateway
        gw.sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
        
        // Setup the button
        pinMode(BUTTON_PIN,INPUT);
        // Activate internal pull-up
        digitalWrite(BUTTON_PIN,HIGH);
        
        // After setting up the button, setup debouncer
        debouncer.attach(BUTTON_PIN);
        debouncer.interval(5);
      
        // Register all sensors to gw (they will be created as child devices)
        gw.present(CHILD_ID_HUM, S_HUM);
        gw.present(CHILD_ID_TEMP, S_TEMP);
        //gw.present(CHILD_ID_HEATER_SW, S_HEATER);
        //gw.present(CHILD_ID_HEATER_STATE, S_HEATER);
        gw.present(CHILD_ID_HVAC, S_HVAC);
        
        metric = gw.getConfig().isMetric;
        
        // Make sure relays are off when starting up
        digitalWrite(RELAY_PIN, RELAY_OFF);
        // Then set relay pins in output mode
        pinMode(RELAY_PIN, OUTPUT);   
            
        // Set relay to last known state (using eeprom storage) 
        //state = gw.loadState(CHILD_ID);
        //digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
      }
      
      void loop()      
      {
        gw.process();
        debouncer.update();
        // Get the update value
        int value = debouncer.read();
        if (value != oldValue && value==0) {
            gw.send(msgHvac.set(state?false:true), true); // Send new state and request ack back
        }
        oldValue = value;
        
        // Check Temp and Humidity sensor every set ammount of time
        unsigned long NOW_TIME = millis();
        if(NOW_TIME - CHECK_TIME >= SLEEP_TIME) {
          getTemps();
          CHECK_TIME = NOW_TIME;
        }
        
        
      }
      
      void getTemps(){
        delay(dht.getMinimumSamplingPeriod());
      
        float temperature = dht.getTemperature();
        if (isnan(temperature)) {
            Serial.println("Failed reading temperature from DHT");
        } else if (temperature != lastTemp) {
          lastTemp = temperature;
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          gw.send(msgTemp.set(temperature, 1));
          //gw.send(msgHvac.set(temperature, 1));
          gw.send(msgBattery.set(65, 1));
          Serial.print("T: ");
          Serial.println(temperature);
        }
        
        float humidity = dht.getHumidity();
        if (isnan(humidity)) {
            Serial.println("Failed reading humidity from DHT");
        } else if (humidity != lastHum) {
            lastHum = humidity;
            gw.send(msgHum.set(humidity, 1));
            Serial.print("H: ");
            Serial.println(humidity);
        }
      
        //gw.sleep(SLEEP_TIME); //sleep a bit
        
      }
      
      void incomingMessage(const MyMessage &message) {
        Serial.println(message.type);
        //Serial.println(message.value);
        // We only expect one type of message from controller. But we better check anyway.
        if (message.isAck()) {
           Serial.println("This is an ack from gateway");
        }
      
        if (message.type == V_HVAC) {
           // Change relay state
           Serial.println("Message received");
           setPoint = String(message.data).toInt();
           Serial.println("New Set Temp is : " + String(setPoint));
           gw.send(msgHvac.set(setPoint, 1));
           // Store state in eeprom
           //gw.saveState(CHILD_ID, state);
          
           // Write some debug info
           Serial.print("Incoming change for sensor:");
           Serial.print(message.sensor);
           Serial.print(", New status: ");
           Serial.println(message.data);
         }
        if (message.type == V_HEATER_SW) {
          Serial.println("Switch Message received");
          Serial.println(String(message.data));
          if(String(message.data) == "HeatOn"){
            Serial.println("Heating ON");
            digitalWrite(RELAY_PIN, RELAY_ON);
            //gw.send(msgHeaterSW.set("HeatOn", 1));
          }
          if(String(message.data) == "CoolOn"){
            Serial.println("Heating OFF");
            digitalWrite(RELAY_PIN, RELAY_OFF);
            //gw.send(msgHeaterSW.set("CoolOn", 1));
          }
        }
      }
      

      L_Arduino.lua
      I_Arduino1.xml
      MyMessage.h

      I have a couple of StellaZ Zwave radiator thermostats that use the hvac files, and they have many variables for temps and batteries and setpoints, but it is beyond me how to enable these for the mysensors nodes.

      We also need to be able to add a scene that goes

      If currentTemp is > currentSetpoint
        Turn on heat
      

      and looking at scenes to switch on heating, it seems you have to add a temp to create a scene involving temperature. I don't know LUUA code at all at the moment so I do not know if you can create a function that ignores the temp you had to add to create it and looks at current temp and setpoint. babbling now.

      Over to you 🙂

      posted in Feature Requests
      stephenmhall
      stephenmhall
    • 5000mah solar battery pack

      Hi Guys

      I saw these on ebay and thought I would give them a go for a shed based node.

      ebay

      batterypack.JPG

      the picture is actually bigger than lifesize its just 142mm tall.

      only £4.95 delivered free. 5000mah with solar charging. states 200mA under full sunlight so a little daylight should keep a node going for ever.

      Unfortunately they are no use straight out of the box as they must have a current drain circuit and a node is not enough to keep it outputting juice.

      However I cracked it open and the battery is a 4v pack so I fitted a 5V step up module to the battery leads and disconnected one of the USB socket feeds and connected it to the 5V output.

      I am feeding the nano based node straight into the usb connector and the pack is held against a window in the shed which lights the green led to tell you it's charging. Only been in a few days but so far the battery has swung up and down between 93% and 97% probably depending on the amount of light. which considering the window does not face the sun and its in Scotland with all of 7 hours of sunlight at the moment if were lucky, it's not doing too bad. The current case hack is very rough but if it seems to work OK I will probably print up a new box for everything.

      Dual USB Solar Power Bank 5000mAh Waterproof Battery Charger for iPhone Samsung

      $7.18
      Sold out
      posted in Hardware
      stephenmhall
      stephenmhall
    • Serial Gateway Board

      Just some pics of my Serial gateway board. Making it tidy to live in the airing cupboard.

      IMG_20150616_201622.jpg

      decided to add the led's but forgot the switch, will add it later

      IMG_20150616_201628.jpg

      And with nano and rf board

      IMG_20150616_201643.jpg

      Just need to print a nice box now.

      Oh and are the led's meant to be on all the time and flash off? cos they do. And damn, those blue led's are bright. (didn't have a yellow), doubles as a light for the cupboard.

      posted in My Project
      stephenmhall
      stephenmhall
    • Wemos D1 mini gateway

      Just for info these work fine as a wifi gateway. Only £2.78 each on Aliexpress

      0_1453397837225_wemos_gateway.jpg

      and the stripboard. pretty small and the connections line up nicely.

      0_1453397825529_wemos_gateway_board.jpg

      That is all..

      posted in Hardware
      stephenmhall
      stephenmhall
    • RE: Serial Gateway Board

      Mk 2 box in white ABS, the lights don't look like the picture they are more distinct.

      IMG_20150619_215949.jpg

      posted in My Project
      stephenmhall
      stephenmhall
    • RE: Serial Gateway Board

      And this is what I thought for a box, tunnels for the led's to shine through the lid.

      serial_gateway_box.png

      posted in My Project
      stephenmhall
      stephenmhall
    • RE: Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.

      Thanks for all that @p_battino , Any recent updates have been in the Neopixel branch rather than the master, I have added direct relay support in that branch for those with no Vera. The main changes have been to change the local display from individual led's to a neopixel ring controlled by a WeMos D1 mini ESP2866 board. I only use the serial and I2C connections on the GPIO to talk to the ESP and an I2C real time clock board (which is not necessary if the RPi can see the interwebs ) All the buttons and outputs are done by the ESP. The neopixel Libraries are much better for the Arduino based boards.

      I will post some pictures when I remember how to do that 😞

      ah got it 🙂
      The connector by the WeMos is for the Relay.
      0_1460565562795_IMG_20160413_170002.jpg

      0_1460565773407_IMG_20160413_170015.jpg

      link to small video of it running

      posted in My Project
      stephenmhall
      stephenmhall
    • RE: Decoding / converting IR-codes

      is it maybe a 48bit binary code 500 0 1350 1

      110001001101001101100100100000000000000000000100

      see if the on and off vary slightly.

      I had to work out something like this for a 433Mhz 5 way switch, if you know the pulse width you can us Rcswitch to transmit. Here is some of the code

      #include <RCSwitch.h>
      #define TRANSMIT_PIN  8  // Arduino Digital I/O pin number for relay
      RCSwitch mySwitch = RCSwitch(); // initiate RC Switch
      
      void setup() {
      // Setup 433 Transmitter
        mySwitch.enableTransmit(TRANSMIT_PIN);
        mySwitch.setPulseLength(200);   // Optional set pulse length.
      }
      
      void loop() {
        mySwitch.send("0100000101010101001100110"); //1 on
      }
      
      posted in Troubleshooting
      stephenmhall
      stephenmhall
    • RE: Serial Gateway Board

      Finished and installed. Little bit of fickering to get it in, I forgot to take into account the big solder blobs on the bottom of the antenna connector.

      IMG_20150617_212700.jpg

      IMG_20150617_212728.jpg

      IMG_20150617_214417.jpg

      The lights are more distinct than the photo shows, my phone obviously really likes red.

      IMG_20150617_214442.jpg

      Now back to nodes 🙂

      posted in My Project
      stephenmhall
      stephenmhall

    Latest posts made by stephenmhall

    • RE: Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.

      Hi Anthony.

      Funnily enough I went from the MAX system to a Honeywell Evo system and Domoticz as I have elderly parents and could not risk the times the max just forgot about all its radiators and either left the heating off or on all day.

      Had the Evo for maybe a year now with no problems. The only thing I miss with the evo is notification as to when the heating is actually on. And being able to work on my code as I did enjoy writing it.

      If you need any help with the code just ask, although it has been a while since I looked at it 🙂

      Stephen

      posted in My Project
      stephenmhall
      stephenmhall
    • RE: ESP8266 MQTT gateway + sonoff_MQTT code + vera + HA_Bridge + Alexa, oh my

      Switches working well but I can't get Temperature to update on a device.

      When switching on a sonoff locally it sends

      mygateway1-in/20/10/1/1/2/1
      

      to the MQTT broker, which immediately causes the switch on the device in Vera to show on, this is passed back out and is sent back to the sonoff.

      However I cannot get a temperature device to update. I send

      mygateway1-in/50/1/1/0/0/20.70
      

      to the Broker but get no change. I can send an html command to update the temp fine.

      here is the Vera device parameters.
      alt text

      I have tried sending to the in and the out topic just to be sure.

      Does anyone have a log from an actual temp node showing the message passed to the gateway just in case someting is not right with my message?

      Also is there a way to monitor the serial messages passed into the Vera from the gateway to check the messages are passing?

      posted in Development
      stephenmhall
      stephenmhall
    • RE: ESP8266 MQTT gateway + sonoff_MQTT code + vera + HA_Bridge + Alexa, oh my

      Would it not need to be added to the Vera as another gateway? I only have a serial gateway on the vera at the moment, I seem to remember I had problems the last time I tried to upgrade to an esp8266 ethernet Gateway and had to go back to the old serial one.

      Mysensor plugin is reporting version 1.5 lib 2.0.0

      posted in Development
      stephenmhall
      stephenmhall
    • RE: ESP8266 MQTT gateway + sonoff_MQTT code + vera + HA_Bridge + Alexa, oh my

      @Efflon I don't think it would, I'm assuming your Home Assistant controller is telling the sonoff to switch using MQTT with your config code

      mysensors:
        gateways:
          - device: mqtt
            persistence_file: '/home/homeassistant/.homeassistant/sonoff.json'
            topic_in_prefix: 'sonoff-out'
            topic_out_prefix: 'sonoff-in'
        debug: false
        optimistic: false
        persistence: true
        retain: true
        version: 2.0
      

      The problem is the Vera controller does not speak MQTT at all, there is a plugin to send device statuses out to a Broker but it's not two way. So all you could do is send the fact that the switch is on or off, but not change it.

      This gets round that by sending out a MySensors message which is then converted into MQTT to switch the Sonoff. so the Vera does not need to know about MQTT and the Sonoff units do not need to know about MySensors.

      posted in Development
      stephenmhall
      stephenmhall
    • RE: ESP8266 MQTT gateway + sonoff_MQTT code + vera + HA_Bridge + Alexa, oh my

      Broker is running on my Synology Diskstation, keeps it all in house as it were. The HA bridge is just there to allow Alexa to control Vera devices.

      posted in Development
      stephenmhall
      stephenmhall
    • ESP8266 MQTT gateway + sonoff_MQTT code + vera + HA_Bridge + Alexa, oh my

      Hi guys, I have been playing with a sonoff using MQTT and a Mosquitto server on my Synology diskstation.

      But could not see a way to get control of the sonoff on my vera (with Mysensors) as it does not support MQTT.

      I started to play with the ESP8266 MQTT gateway, the gateway has an NRF radio but is Not connected to the vera as an actual gateway.

      (I just opened a second page on Mysensors to check something and saw Efflon posted a MQTT Sonoff post but his uses home assistant which supports MQTT so I think mine is different enough to keep going)

      Ok so, here is the working chain:

      • "Alexa switch on mains plug 1"

      • Alexa talks to HA Bridge (also running on my Synology) where mains plug 1 is the friendly name of Vera virtual switch device no 181 id 20;10 parent 3

      • HA Bridge talks to Vera in html to switch on the Virtual switch with id 20;10 (I have a 433Txnode with id 20 and 6 switches) with parent id 3(Mysensors plugin)

      • Message then goes out the Mysensors serial gateway and is broadcast over NRF (20/10/1/1/2 1)

      • The ESP8266_MQTT_gateway picks up the message on NRF and sends it on to the MQTT broker (mygateway1-out/20/10/1/1/2 with message 1)

      • The SONOFF unit is subscribed to the broker and picks up the message and switches on.

      if you press the button on the sonoff it works in reverse as far as Vera, sending a message to mygateway1-in/20/10/1/1/2 0 or 1 switching the state of the virtual switch.

      The ESP8266 MQTT gateway code was unchanged.

      Sonoff MQTT code from esp8266.com

      The only change was to the topic name

      /*
      
       It connects to an MQTT server then:
        - on 0 switches off relay
        - on 1 switches on relay
        - on 2 switches the state of the relay
      
        - sends 0 on off relay
        - sends 1 on on relay
      
       It will reconnect to the server if the connection is lost using a blocking
       reconnect function. See the 'mqtt_reconnect_nonblocking' example for how to
       achieve the same result without blocking the main loop.
      
       The current state is stored in EEPROM and restored on bootup
      
      */
      
      #include <ESP8266WiFi.h>
      #include <PubSubClient.h>
      #include <Bounce2.h>
      #include <EEPROM.h>
      
      
      const char* ssid = "ssid";
      const char* password = "password";
      const char* mqtt_server = "broker IP address";
      
      WiFiClient espClient;
      PubSubClient client(espClient);
      long lastMsg = 0;
      char msg[50];
      int value = 0;
      
      //const char* outTopic = "Sonoff1out";
      const char* outTopic = "mygateway1-in/20/10/1/1/2";
      //const char* inTopic = "Sonoff1in";
      const char* inTopic = "mygateway1-out/20/10/1/1/2";
      
      int relay_pin = 12;
      int button_pin = 0;
      bool relayState = LOW;
      
      // Instantiate a Bounce object :
      Bounce debouncer = Bounce(); 
      
      
      void setup_wifi() {
      
        delay(10);
        // We start by connecting to a WiFi network
        Serial.println();
        Serial.print("Connecting to ");
        Serial.println(ssid);
      
        WiFi.begin(ssid, password);
      
        while (WiFi.status() != WL_CONNECTED) {
          extButton();
          for(int i = 0; i<500; i++){
            extButton();
            delay(1);
          }
          Serial.print(".");
        }
        digitalWrite(13, LOW);
        delay(500);
        digitalWrite(13, HIGH);
        delay(500);
        digitalWrite(13, LOW);
        delay(500);
        digitalWrite(13, HIGH);
        Serial.println("");
        Serial.println("WiFi connected");
        Serial.println("IP address: ");
        Serial.println(WiFi.localIP());
      }
      
      void callback(char* topic, byte* payload, unsigned int length) {
        Serial.print("Message arrived [");
        Serial.print(topic);
        Serial.print("] ");
        for (int i = 0; i < length; i++) {
          Serial.print((char)payload[i]);
        }
        Serial.println();
      
        // Switch on the LED if an 1 was received as first character
        if ((char)payload[0] == '0') {
          digitalWrite(relay_pin, LOW);   // Turn the LED on (Note that LOW is the voltage level
          Serial.println("relay_pin -> LOW");
          relayState = LOW;
          EEPROM.write(0, relayState);    // Write state to EEPROM
          EEPROM.commit();
        } else if ((char)payload[0] == '1') {
          digitalWrite(relay_pin, HIGH);  // Turn the LED off by making the voltage HIGH
          Serial.println("relay_pin -> HIGH");
          relayState = HIGH;
          EEPROM.write(0, relayState);    // Write state to EEPROM
          EEPROM.commit();
        } else if ((char)payload[0] == '2') {
          relayState = !relayState;
          digitalWrite(relay_pin, relayState);  // Turn the LED off by making the voltage HIGH
          Serial.print("relay_pin -> switched to ");
          Serial.println(relayState); 
          EEPROM.write(0, relayState);    // Write state to EEPROM
          EEPROM.commit();
        }
      }
      
      void reconnect() {
        // Loop until we're reconnected
        while (!client.connected()) {
          Serial.print("Attempting MQTT connection...");
          // Attempt to connect
          if (client.connect("ESP8266Client")) {
            Serial.println("connected");
            // Once connected, publish an announcement...
            client.publish(outTopic, "Sonoff1 booted");
            // ... and resubscribe
            client.subscribe(inTopic);
          } else {
            Serial.print("failed, rc=");
            Serial.print(client.state());
            Serial.println(" try again in 5 seconds");
            // Wait 5 seconds before retrying
            for(int i = 0; i<5000; i++){
              extButton();
              delay(1);
            }
          }
        }
      }
      
      void extButton() {
        debouncer.update();
         
         // Call code if Bounce fell (transition from HIGH to LOW) :
         if ( debouncer.fell() ) {
           Serial.println("Debouncer fell");
           // Toggle relay state :
           relayState = !relayState;
           digitalWrite(relay_pin,relayState);
           EEPROM.write(0, relayState);    // Write state to EEPROM
           if (relayState == 1){
            client.publish(outTopic, "1");
           }
           else if (relayState == 0){
            client.publish(outTopic, "0");
           }
         }
      }
      
      void setup() {
        EEPROM.begin(512);              // Begin eeprom to store on/off state
        pinMode(relay_pin, OUTPUT);     // Initialize the relay pin as an output
        pinMode(button_pin, INPUT);     // Initialize the relay pin as an output
        pinMode(13, OUTPUT);
        relayState = EEPROM.read(0);
        digitalWrite(relay_pin,relayState);
        
        debouncer.attach(button_pin);   // Use the bounce2 library to debounce the built in button
        debouncer.interval(50);         // Input must be low for 50 ms
        
        digitalWrite(13, LOW);          // Blink to indicate setup
        delay(500);
        digitalWrite(13, HIGH);
        delay(500);
        
        Serial.begin(115200);
        setup_wifi();                   // Connect to wifi 
        client.setServer(mqtt_server, 1883);
        client.setCallback(callback);
      }
      
      void loop() {
      
        if (!client.connected()) {
          reconnect();
        }
        client.loop();
        extButton();
      }
      
      //- See more at: http://www.esp8266.com/viewtopic.php?f=29&t=8746#sthash.vhv33y8Q.dpuf
      

      You don't need to add any extra gateways to Vera, you just add Virtual Switches and program each sonoff (or any other ESP8266) with the different Broker topics needed.

      posted in Development
      stephenmhall
      stephenmhall
    • RE: Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.

      if you need any help with my software let me know, I have swapped to a Honywell system myself so no longer use it but if I can help I will.

      posted in My Project
      stephenmhall
      stephenmhall
    • RE: 💬 Building a MQTT Gateway

      Not sure if you want to leave the GPS on there unless that isn't your house with the double hot tub in tha back garden 🙂

      posted in Announcements
      stephenmhall
      stephenmhall
    • RE: Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.

      Damn, just weeks after I changed to a Honeywell system. Talk about bad timing.

      posted in My Project
      stephenmhall
      stephenmhall
    • RE: Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.

      As far as Cube to valves and valves to cube comms, I think it must be bi-directional as if you change anything on the cube app it happens pretty much instantly. How the cube and valves communicate could be magic for all I know 🙂 they are on the 868Mhz band but what the protocol is I don't know.

      I recently read about a company in Germany called busware.de that makes a Raspberry interface card that has firmware that speaks MAX protocol, I have sent them an email looking to confirm this but not heard anything back yet. If I could cut the Cube out of my system I would be very happy as it is the least reliable part, it seems to factory reset itself every couple of months.

      posted in My Project
      stephenmhall
      stephenmhall