Navigation

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

    binladin

    @binladin

    1
    Reputation
    6
    Posts
    912
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    binladin Follow

    Best posts made by binladin

    • RE: nRF24LE1 full controller to control devices and sensors reading!!

      I explained at his forum as I could. Maybe it would have made a better programmer. I could to translate this into Russian.
      By the way, MaxMS developments relating NRF24LE1 are here - https://github.com/maksms/NRF24LE1_client
      It would be nice if programmers seeing and correctly put questions.

      posted in Hardware
      binladin
      binladin

    Latest posts made by binladin

    • RE: nRF24LE1 full controller to control devices and sensors reading!!

      I explained at his forum as I could. Maybe it would have made a better programmer. I could to translate this into Russian.
      By the way, MaxMS developments relating NRF24LE1 are here - https://github.com/maksms/NRF24LE1_client
      It would be nice if programmers seeing and correctly put questions.

      posted in Hardware
      binladin
      binladin
    • RE: nRF24LE1 full controller to control devices and sensors reading!!

      MaksMS the author of homes-smart.ru - http://habrahabr.ru/users/maksms/topics/
      I am leave a request for mysensors adoptation on the forum - http://homes-smart.ru/index.php/component/kunena/5-soft/106-konstruktor-besprovodnogo-klienta-na-nrf24le1?limit=6&Itemid=0&start=18#625

      posted in Hardware
      binladin
      binladin
    • RE: MQTT/OpenHab gw.request reply

      To work with actuators, suggests implementation of an RPC interface over the MQTT, such as here - mqtt-rpc for node.js. In other words - it requires special design of topic structure, as a very simple example, you could publish to MyMQTT/20/0/V_LIGHT/REQUEST and subscribe to MyMQTT/20/0/V_LIGHT/RESPONSE. Here your can read how it works in Gadgetkeeper - JSON-RPC over MQTT.

      Even better would be to have implemented the protocol WAMP - WAMP Router diagram

      But there is a trick for our situation - we can use V_VAR2 for requesting controller and V_VAR1 for getting response. For example:
      MyMQTT/20/1/V_VAR1 - (incomingMessage)
      MyMQTT/20/1/V_VAR2 - (send request).
      Below you can see sketch of Natural Gas Meter from Majordomo forum (russian - you can use translate.google.com), which used this trick. This sketch derrived from MySensors Power Meter Pulse Sensor.

      But you have to adapt the settings of OpenHub like settings in Majordomo.

      // Use this sensor to measure KWH and Watt of your house meeter
      // You need to set the correct pulsefactor of your meeter (blinks per KWH).
      // The sensor starts by fetching current KWH value from gateway.
      // Reports both KWH and Watt back to gateway.
      //
      // Unfortunately millis() won't increment when the Arduino is in 
      // sleepmode. So we cannot make this sensor sleep if we also want 
      // to calculate/report watt-number.
      
      #include <SPI.h>
      #include <MySensor.h>  
      
      #define DIGITAL_INPUT_SENSOR 3  // The digital input you attached your light sensor.  (Only 2 and 3 generates interrupt!)
      #define PULSE_FACTOR 1000       // Nummber of blinks per KWH of your meeter
      #define SLEEP_MODE true        // Watt-value can only be reported when sleep mode is false.
      #define MAX_WATT 10000          // Max watt value to report. This filetrs outliers.
      #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      
      // Id of the sensor child
      #define CHILD_ID_CNT 1
      #define CHILD_ID_DEV 254
      
       unsigned long SEND_FREQUENCY = 300000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
       MySensor gw;
       double ppwh = ((double)PULSE_FACTOR)/1000; // Pulses per watt hour
       boolean pcReceived = false;
       volatile unsigned long pulseCount = 0;   
       volatile unsigned long lastBlink = 0;
       volatile unsigned long watt = 0;
       unsigned long oldPulseCount = 0;   
       unsigned long oldWatt = 0;
       double oldKwh;
       double oldTemp = 0;
       float oldBatteryV = 0;
       unsigned long lastSend;
      
       MyMessage CntWattMsg(CHILD_ID_CNT, V_WATT);
       MyMessage CntKwhMsg(CHILD_ID_CNT,  V_KWH);
       MyMessage pcMsg(CHILD_ID_CNT,      V_VAR1);
       MyMessage pcReqMsg(CHILD_ID_CNT,   V_VAR2);
      
       MyMessage BattMsg(CHILD_ID_DEV, V_VOLTAGE);
      
      long readVcc() {
       long result;
       // Read 1.1V reference against AVcc
       ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
       delay(2); // Wait for Vref to settle
       ADCSRA |= _BV(ADSC); // Convert
       while (bit_is_set(ADCSRA,ADSC));
       result = ADCL;
       result |= ADCH<<8;
       result = 1126400L / result; // Back-calculate AVcc in mV
       return result;
      }
      
      void SendDevInfo()
      {
        //========= Battery =============  
        float batteryV  = readVcc() * 0.001;
      
        Serial.print("BatV:");
        Serial.println(batteryV);
      
        gw.send(BattMsg.set(batteryV, 2));
      }
      
      void setup()  
      {  
        wdt_disable();
      
        // Disable the ADC by setting the ADEN bit (bit 7) to zero.
        ADCSRA = ADCSRA & B01111111;
      
         // Disable the analog comparator by setting the ACD bit
        // (bit 7) to one.
        ACSR = B10000000;   
      
        gw.begin(incomingMessage);
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Natural GAS Meter", "1.0");
      
        // Register this device as power sensor
        gw.present(CHILD_ID_CNT, S_POWER);
        gw.present(CHILD_ID_DEV, V_VOLTAGE);  
      
        // Fetch last known pulse count value from gw
        //gw.request(CHILD_ID_CNT, V_VAR1);
        gw.send(pcReqMsg.set("REQ"));
      
        attachInterrupt(INTERRUPT, onPulse, RISING);
      
        wdt_enable(WDTO_8S);  
      
        lastSend=millis();
      }
      
      void loop()     
      { 
       wdt_reset();
      
       // By calling process() you route messages in the background
       gw.process();
      
       // Send feq
       // Only send values at a maximum frequency or woken up from sleep
       unsigned long now = millis();
       bool sendTime = now - lastSend > SEND_FREQUENCY;
      
       //========= Cnt =============   
       if (pcReceived && (SLEEP_MODE || sendTime)) {
         SendDevInfo();
      
      // New watt value has been calculated  
      if (!SLEEP_MODE && watt != oldWatt) {
        // Check that we dont get unresonable large watt value. 
        // could hapen when long wraps or false interrupt triggered
        if (watt<((unsigned long)MAX_WATT)) {
          gw.send(CntWattMsg.set(watt));  // Send watt value to gw 
        }  
        Serial.print("Watt:");
        Serial.println(watt);
        oldWatt = watt;
      }
      
      // Pulse cout has changed
      if (pulseCount != oldPulseCount) {
        gw.send(pcMsg.set(pulseCount));  // Send pulse count value to gw 
        double kwh = ((double)pulseCount/((double)PULSE_FACTOR));     
        oldPulseCount = pulseCount;
        if (kwh != oldKwh) {
          gw.send(CntKwhMsg.set(kwh, 4));  // Send kwh value to gw 
          oldKwh = kwh;
        }
      }       
      
      lastSend = now;    
       } else if (sendTime && !pcReceived) {
      // No count received. Try requesting it again
      //gw.request(CHILD_ID_CNT, V_VAR1);
      gw.send(pcReqMsg.set("REQ"));
      
      lastSend=now;       
      }
      
       //========= Sleep ================
       if (SLEEP_MODE && pcReceived) {
       Serial.println("sleep");
       gw.sleep(SEND_FREQUENCY);
       }
      }
      
       void incomingMessage(const MyMessage &message) {
        if (message.type==V_VAR1) {  
        pulseCount = oldPulseCount = message.getLong();
        Serial.print("Received last pulse count from gw:");
        Serial.println(pulseCount);
        pcReceived = true;
        }
       }
      
      void onPulse()     
      { 
       if (!SLEEP_MODE) {
       unsigned long newBlink = micros();  
       unsigned long interval = newBlink-lastBlink;
       if (interval<10000L) { // Sometimes we get interrupt on RISING
       return;
       }
      watt = (3600000000.0 /interval) / ppwh;
      lastBlink = newBlink;
      } 
       pulseCount++;
      }
      posted in OpenHAB
      binladin
      binladin
    • MQTT-SN

      What do you think about the possibility of using the MQTT-SN protocol for non TCP networks.
      Like this https://github.com/bittailor/BtMqttSn

      posted in General Discussion
      binladin
      binladin
    • RE: MQTT Client gateway

      Hello! Thanks for your great work.
      I have some question. After starting MajorDoMo controller and mosquitto on my PC, i made MQTTClientGateway and DHT MySensors node, and in mosquitto log i can see:

      1415812670: Received PUBLISH from MySensor (d0, q0, r0, m0, 'MyMQTT/20/1/V_TEMP'
      , ... (4 bytes))
      1415812670: Sending PUBLISH to MySensor (d0, q0, r0, m0, 'MyMQTT/20/1/V_TEMP', .
      .. (4 bytes))
      1415812670: Sending PUBLISH to MajorDoMo MQTT Client (d0, q0, r0, m0, 'MyMQTT/20
      /1/V_TEMP', ... (4 bytes))

      Can you explain why mqttclientgateway subscribing to its own data in next part of sketch:

      if (!client.connected())
      {
      client.connect("MySensor");
      client.subscribe("MyMQTT/#");

      I apologize if my question will seem ignorant, and sorry for my poor english.

      posted in Development
      binladin
      binladin
    • MajorDoMo

      MajorDoMo (Major Domestic Module) is an open-source home automation platform. This platform can be installed on almost any personal computer running Windows or Linux OS. MDM is very flexible web-based platform.
      It can simply integrated with MySensors devices via MQTT gateway. Enter IP, port of MQTT gateway and symbol # (as "Subscription path") on the page "Devices\MQTT" in control panel, and platform get access to all messages of MQTT-broker for using in MDM algorithms.
      I am successfully trying bundle MDM<->MQTT-gateway<->Mysensors DHT example.
      MDM url - http://majordomohome.com/

      posted in MajorDoMo
      binladin
      binladin