Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. سیدعظیم عباس
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    سیدعظیم عباس

    @سیدعظیم عباس

    0
    Reputation
    10
    Posts
    451
    Profile views
    0
    Followers
    1
    Following
    Joined Last Online

    سیدعظیم عباس Follow

    Best posts made by سیدعظیم عباس

    This user hasn't posted anything yet.

    Latest posts made by سیدعظیم عباس

    • RE: Sending Message from SerialGateway Node to RelayActuator

      Thanks that really worked for me.

      posted in Development
      سیدعظیم عباس
      سیدعظیم عباس
    • RE: Sending Message from SerialGateway Node to RelayActuator

      what does this function does
      msg.setDestination(105);

      posted in Development
      سیدعظیم عباس
      سیدعظیم عباس
    • RE: Sending Message from SerialGateway Node to RelayActuator
      void incomingMessage(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
           // Change relay state
           digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
           // Store state in eeprom
           gw.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());
         } 
      

      The incomingMessage function in RelayActuator is checking message type as V_LIGHT
      how can we send this message from serial monitor of SerialGateway

      posted in Development
      سیدعظیم عباس
      سیدعظیم عباس
    • RE: Sending Message from SerialGateway Node to RelayActuator

      And if we want to send message through Serial Monitor

      posted in Development
      سیدعظیم عباس
      سیدعظیم عباس
    • Sending Message from SerialGateway Node to RelayActuator

      This is the sample code of SerialGateway I am using

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * DESCRIPTION
       * The ArduinoGateway prints data received from sensors on the serial link. 
       * The gateway accepts input on seral which will be sent out on radio network.
       *
       * The GW code is designed for Arduino Nano 328p / 16MHz
       *
       * Wire connections (OPTIONAL):
       * - Inclusion button should be connected between digital pin 3 and GND  
       * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
       *
       * LEDs (OPTIONAL):
       * - To use the feature, uncomment WITH_LEDS_BLINKING in MyConfig.h
       * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
       * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
       * - ERR (red) - fast blink on error during transmission error or recieve crc error 
       * 
       */
      
      #define NO_PORTB_PINCHANGES  
      
      #include <MySigningNone.h>
      #include <MyTransportRFM69.h>
      #include <MyTransportNRF24.h>
      #include <MyHwATMega328.h>
      #include <MySigningAtsha204Soft.h>
      #include <MySigningAtsha204.h>
      
      #include <SPI.h>  
      #include <MyParserSerial.h>  
      #include <MySensor.h>  
      #include <stdarg.h>
      #include <PinChangeInt.h>
      #include "GatewayUtil.h"
      
      #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
      #define INCLUSION_MODE_PIN  3 // Digital pin used for inclusion mode button
      #define RADIO_ERROR_LED_PIN 4  // Error led pin
      #define RADIO_RX_LED_PIN    6  // Receive led pin
      #define RADIO_TX_LED_PIN    5  // the PCB, on board LED
      
      // NRFRF24L01 radio driver (set low transmit power by default) 
      MyTransportNRF24 transport(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
      //MyTransportRFM69 transport;
      
      // Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
      //MySigningNone signer;
      //MySigningAtsha204Soft signer;
      //MySigningAtsha204 signer;
      
      // Hardware profile 
      MyHwATMega328 hw;
      
      // Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
      // To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h
      #ifdef WITH_LEDS_BLINKING
      MySensor gw(transport, hw /*, signer*/, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
      #else
      MySensor gw(transport, hw /*, signer*/);
      #endif
      
      char inputString[MAX_RECEIVE_LENGTH] = "";    // A string to hold incoming commands from serial/ethernet interface
      int inputPos = 0;
      boolean commandComplete = false;  // whether the string is complete
      
      void parseAndSend(char *commandBuffer);
      
      void output(const char *fmt, ... ) {
         va_list args;
         va_start (args, fmt );
         vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args);
         va_end (args);
         Serial.print(serialBuffer);
      }
      
        
      void setup()  
      { 
        gw.begin(incomingMessage, 0, true, 0);
      
        setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
      
        // Add interrupt for inclusion button to pin
        PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING);
      
      
        // Send startup log message on serial
        serial(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"),  C_INTERNAL, I_GATEWAY_READY);
      }
      
      void loop()  
      { 
        gw.process();
      
        checkButtonTriggeredInclusion();
        checkInclusionFinished();
        
        if (commandComplete) {
          // A command wass issued from serial interface
          // We will now try to send it to the actuator
          parseAndSend(gw, inputString);
          commandComplete = false;  
          inputPos = 0;
        }
      }
      
      
      /*
        SerialEvent occurs whenever a new data comes in the
       hardware serial RX.  This routine is run between each
       time loop() runs, so using delay inside loop can delay
       response.  Multiple bytes of data may be available.
       */
      void serialEvent() {
        while (Serial.available()) {
          // get the new byte:
          char inChar = (char)Serial.read(); 
          // if the incoming character is a newline, set a flag
          // so the main loop can do something about it:
          if (inputPos<MAX_RECEIVE_LENGTH-1 && !commandComplete) { 
            if (inChar == '\n') {
              inputString[inputPos] = 0;
              commandComplete = true;
            } else {
              // add it to the inputString:
              inputString[inputPos] = inChar;
              inputPos++;
            }
          } else {
             // Incoming message too long. Throw away 
              inputPos = 0;
          }
        }
      }
      
      
      
      

      and this is the RelayActuator sample code

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0 - Henrik Ekblad
       * 
       * DESCRIPTION
       * Example sketch showing how to control physical relays. 
       * This example will remember relay state after power failure.
       * http://www.mysensors.org/build/relay
       */ 
      
      #include <MySigningNone.h>
      #include <MyTransportNRF24.h>
      #include <MyTransportRFM69.h>
      #include <MyHwATMega328.h>
      #include <MySensor.h>
      #include <SPI.h>
      
      #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 1 // Total number of attached relays
      #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
      
      // NRFRF24L01 radio driver (set low transmit power by default) 
      MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);  
      //MyTransportRFM69 radio;
      // Message signing driver (none default)
      //MySigningNone signer;
      // Select AtMega328 hardware profile
      MyHwATMega328 hw;
      // Construct MySensors library
      MySensor gw(radio, hw);
      
      void setup()  
      {   
        // Initialize library and add callback for incoming messages
        gw.begin(incomingMessage, AUTO, true);
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Relay", "1.0");
      
        // Fetch relay status
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          gw.present(sensor, S_LIGHT);
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      }
      
      
      void loop() 
      {
        // Alway process incoming messages whenever possible
        gw.process();
      }
      
      void incomingMessage(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
           // Change relay state
           digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
           // Store state in eeprom
           gw.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());
         } 
      }
      

      This is output of SerialMonitor

      fisend: 105-105-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
      send: 105-105-0-0 s=255,c=0,t=18,pt=0,l=5,sg=0,st=ok:1.5.4
      send: 105-105-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
      repeater started, id=105, parent=0, distance=1
      send: 105-105-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
      send: 105-105-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
      send: 105-105-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:

      Now I want to send Message from gateway to switch the relay pin 3 of RelayActuator , please guide me I am new to mysensor. How can i send a message from gateway to RelayActuator node.

      posted in Development
      سیدعظیم عباس
      سیدعظیم عباس
    • RE: Arduino and NRF24 Mesh Code
      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0 - Henrik Ekblad
       * 
       * DESCRIPTION
       * Example sketch showing how to control physical relays. 
       * This example will remember relay state after power failure.
       * http://www.mysensors.org/build/relay
       */ 
      
      #include <MySigningNone.h>
      #include <MyTransportNRF24.h>
      #include <MyTransportRFM69.h>
      #include <MyHwATMega328.h>
      #include <MySensor.h>
      #include <SPI.h>
      
      #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 1 // Total number of attached relays
      #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
      
      // NRFRF24L01 radio driver (set low transmit power by default) 
      MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);  
      //MyTransportRFM69 radio;
      // Message signing driver (none default)
      //MySigningNone signer;
      // Select AtMega328 hardware profile
      MyHwATMega328 hw;
      // Construct MySensors library
      MySensor gw(radio, hw);
      
      void setup()  
      {   
        // Initialize library and add callback for incoming messages
        gw.begin(incomingMessage, AUTO, true);
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Relay", "1.0");
      
        // Fetch relay status
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          gw.present(sensor, S_LIGHT);
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      }
      
      
      void loop() 
      {
        // Alway process incoming messages whenever possible
        gw.process();
      }
      
      void incomingMessage(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
           // Change relay state
           digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
           // Store state in eeprom
           gw.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());
         } 
      }
      

      above i have shared a sample code of RelayActuator can i treat it as one sensor node controlling one relay switch from pin 3.Please guide me i am new to mysensor library.

      posted in Development
      سیدعظیم عباس
      سیدعظیم عباس
    • RE: Arduino and NRF24 Mesh Code

      For example , I am controlling switches of 4 rooms(each room can be consider as a node) , having 6 buttons each when I call MyMessage msg(CHILD_ID,V_LIGHT); and than gw.send how i can assure which button of that node or room i wont to turn.
      Also if i am assign child_id as 0,1,2..... in neighbor their can also be nodes having CHILD_ID same.

      posted in Development
      سیدعظیم عباس
      سیدعظیم عباس
    • RE: Arduino and NRF24 Mesh Code
      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      
      #define RELAY_PIN  4  // Arduino Digital I/O pin number for relay 
      #define BUTTON_PIN  3  // Arduino Digital I/O pin number for button 
      #define CHILD_ID 1   // Id of the sensor child
      #define RELAY_ON 1
      #define RELAY_OFF 0
      
      Bounce debouncer = Bounce(); 
      int oldValue=0;
      bool state;
      MySensor gw;
      MyMessage msg(CHILD_ID,V_LIGHT);
      
      void setup()  
      {  
        gw.begin(incomingMessage, AUTO, true);
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Relay & Button", "1.0");
      
       // 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, S_LIGHT);
      
        // 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);
      }
      
      
      /*
      *  Example on how to asynchronously check for new messages from gw
      */
      void loop() 
      {
        gw.process();
        debouncer.update();
        // Get the update value
        int value = debouncer.read();
        if (value != oldValue && value==0) {
            gw.send(msg.set(state?false:true), true); // Send new state and request ack back
        }
        oldValue = value;
      } 
       
      void incomingMessage(const MyMessage &message) {
        // 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_LIGHT) {
           // Change relay state
           state = message.getBool();
           digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
           // 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.getBool());
         } 
      }
      

      Thanks for your reply , I have shared the sample code of MySensor Library above according to this code you mean that all the gateway nodes will have child_id 0 and sensor node will have child_id 1.

      posted in Development
      سیدعظیم عباس
      سیدعظیم عباس
    • RE: Arduino and NRF24 Mesh Code

      I have 4 arduino uno's with nrf24 and i want to make 3 uno's as a sensor nodes and one as a gateway node.I want to make networking mesh of these 3 sensor nodes and 1 gateway node.

      posted in Development
      سیدعظیم عباس
      سیدعظیم عباس
    • Arduino and NRF24 Mesh Code

      0_1459882900227_gw.png

      I have seen this NRF24 mesh tutorial of MySensor Library on the link link text but could not find any sample code of it's implementation. Is there any sample code that implements sensor and gateway code.Please help , thanks in advance.

      posted in Development
      سیدعظیم عباس
      سیدعظیم عباس