Navigation

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

    Michal

    @Michal

    1
    Reputation
    4
    Posts
    375
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Michal Follow

    Best posts made by Michal

    • RE: RS485/RS232/Serial transport class for mysensors.org

      @radekzm
      OK, what I did:
      on one Arduino nano I have this sketch
      https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/GatewaySerialRS485/GatewaySerialRS485.ino
      on second arduino nano I have conbined two sketches:
      https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/DistanceSensor/DistanceSensor.ino
      and
      https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/MotionSensorRS485/MotionSensorRS485.ino
      and the results is:

      /**
       * 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
       * This is an example of sensors using RS485 as transport layer
       * 
       * Motion Sensor example using HC-SR501 
       * http://www.mysensors.org/build/motion
       * 
       * The transport uses AltSoftSerial to handle two serial links 
       * on one Arduino. Use the following pins for RS485 link
       * 
       *  Board          Transmit  Receive   PWM Unusable
       * -----          --------  -------   ------------
       * Teensy 3.0 & 3.1  21        20         22
       * Teensy 2.0         9        10       (none)
       * Teensy++ 2.0      25         4       26, 27
       * Arduino Uno        9         8         10
       * Arduino Leonardo   5        13       (none)
       * Arduino Mega      46        48       44, 45
       * Wiring-S           5         6          4
       * Sanguino          13        14         12 * 
       * 
       */
      
      
      // Enable RS485 transport layer
      #define MY_RS485
      
      // Define this to enables DE-pin management on defined pin 
      #define MY_RS485_DE_PIN 2
      
      // Set RS485 baud rate to use
      #define MY_RS485_BAUD_RATE 9600
      
      #include <SPI.h>
      #include <MySensor.h>
      #include <NewPing.h>
      
      #define CHILD_ID 1
      #define TRIGGER_PIN  5  // Arduino pin tied to trigger pin on the ultrasonic sensor.
      #define ECHO_PIN     6  // Arduino pin tied to echo pin on the ultrasonic sensor.
      #define MAX_DISTANCE 300 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
      unsigned long SLEEP_TIME = 5000; // Sleep time between reads (in milliseconds)
      
      NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
      MyMessage msg(CHILD_ID, V_DISTANCE);
      int lastDist;
      boolean metric = true; 
      
      void setup()  
      {  
        metric = getConfig().isMetric;
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Distance Sensor", "1.0");
      
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID, S_DISTANCE);
      }
      
      void loop()     
      {     
        int dist = metric?sonar.ping_cm():sonar.ping_in();
        Serial.print("Ping: ");
        Serial.print(dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
        Serial.println(metric?" cm":" in");
      
        if (dist != lastDist) {
            send(msg.set(dist));
            lastDist = dist;
        }
      
        sleep(SLEEP_TIME);
      }
      

      On serial port (/dev/ttyUSB0) Controller (first nano) I see:
      0;255;3;0;9;Starting gateway (RSNGA-, 2.0.0-beta)
      0;255;3;0;9;Radio init successful.
      0;255;3;0;14;Gateway startup complete.
      0;255;3;0;9;Init complete, id=0, parent=0, distance=0

      on serial port(/dev/ttyUSB1) in node is see:
      ...
      Ping: 33 cm
      Ping: 34 cm
      Ping: 34 cm
      Ping: 33 cm
      Ping: 33 cm
      Ping: 33 cm
      Ping: 5 cm
      Ping: 91 cm
      Ping: 88 cm
      Ping: 89 cm
      ......

      But I expect to see some message on controller. What can I check? Do you see and mistakes ?

      posted in Development
      Michal
      Michal

    Latest posts made by Michal

    • RE: Advanced combination script (OneWire+DHT+Relays) over serial usb to Pi runnung domoticz - HELP with timing and group ID

      @AterMentis said in Advanced combination script (OneWire+DHT+Relays) over serial usb to Pi runnung domoticz - HELP with timing and group ID:

      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_TEMP1, S_TEMP);
      present(CHILD_ID_HUM1, S_HUM);
      present(CHILD_ID_TEMP2, S_TEMP);
      present(CHILD_ID_HUM2, S_HUM);
      present(CHILD_ID_TEMP3, S_TEMP);
      present(CHILD_ID_HUM3, S_HUM);

      Did you find a solution ?
      On other topic you can find a posible solution:
      Change order of reporting/presenting devices:

      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_TEMP1, S_TEMP);
      present(CHILD_ID_TEMP2, S_TEMP);
      present(CHILD_ID_TEMP3, S_TEMP);
      present(CHILD_ID_HUM1, S_HUM);
      present(CHILD_ID_HUM2, S_HUM);
      present(CHILD_ID_HUM3, S_HUM);

      posted in Domoticz
      Michal
      Michal
    • RE: MQTT Ethernet Gateway with Wired RS485 Network

      @ATha1 What tool do you use to draw a diagram ?

      posted in Home Assistant
      Michal
      Michal
    • RE: RS485/RS232/Serial transport class for mysensors.org

      @radekzm
      OK, what I did:
      on one Arduino nano I have this sketch
      https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/GatewaySerialRS485/GatewaySerialRS485.ino
      on second arduino nano I have conbined two sketches:
      https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/DistanceSensor/DistanceSensor.ino
      and
      https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/MotionSensorRS485/MotionSensorRS485.ino
      and the results is:

      /**
       * 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
       * This is an example of sensors using RS485 as transport layer
       * 
       * Motion Sensor example using HC-SR501 
       * http://www.mysensors.org/build/motion
       * 
       * The transport uses AltSoftSerial to handle two serial links 
       * on one Arduino. Use the following pins for RS485 link
       * 
       *  Board          Transmit  Receive   PWM Unusable
       * -----          --------  -------   ------------
       * Teensy 3.0 & 3.1  21        20         22
       * Teensy 2.0         9        10       (none)
       * Teensy++ 2.0      25         4       26, 27
       * Arduino Uno        9         8         10
       * Arduino Leonardo   5        13       (none)
       * Arduino Mega      46        48       44, 45
       * Wiring-S           5         6          4
       * Sanguino          13        14         12 * 
       * 
       */
      
      
      // Enable RS485 transport layer
      #define MY_RS485
      
      // Define this to enables DE-pin management on defined pin 
      #define MY_RS485_DE_PIN 2
      
      // Set RS485 baud rate to use
      #define MY_RS485_BAUD_RATE 9600
      
      #include <SPI.h>
      #include <MySensor.h>
      #include <NewPing.h>
      
      #define CHILD_ID 1
      #define TRIGGER_PIN  5  // Arduino pin tied to trigger pin on the ultrasonic sensor.
      #define ECHO_PIN     6  // Arduino pin tied to echo pin on the ultrasonic sensor.
      #define MAX_DISTANCE 300 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
      unsigned long SLEEP_TIME = 5000; // Sleep time between reads (in milliseconds)
      
      NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
      MyMessage msg(CHILD_ID, V_DISTANCE);
      int lastDist;
      boolean metric = true; 
      
      void setup()  
      {  
        metric = getConfig().isMetric;
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Distance Sensor", "1.0");
      
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID, S_DISTANCE);
      }
      
      void loop()     
      {     
        int dist = metric?sonar.ping_cm():sonar.ping_in();
        Serial.print("Ping: ");
        Serial.print(dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
        Serial.println(metric?" cm":" in");
      
        if (dist != lastDist) {
            send(msg.set(dist));
            lastDist = dist;
        }
      
        sleep(SLEEP_TIME);
      }
      

      On serial port (/dev/ttyUSB0) Controller (first nano) I see:
      0;255;3;0;9;Starting gateway (RSNGA-, 2.0.0-beta)
      0;255;3;0;9;Radio init successful.
      0;255;3;0;14;Gateway startup complete.
      0;255;3;0;9;Init complete, id=0, parent=0, distance=0

      on serial port(/dev/ttyUSB1) in node is see:
      ...
      Ping: 33 cm
      Ping: 34 cm
      Ping: 34 cm
      Ping: 33 cm
      Ping: 33 cm
      Ping: 33 cm
      Ping: 5 cm
      Ping: 91 cm
      Ping: 88 cm
      Ping: 89 cm
      ......

      But I expect to see some message on controller. What can I check? Do you see and mistakes ?

      posted in Development
      Michal
      Michal
    • RE: RS485/RS232/Serial transport class for mysensors.org

      Hi,
      I have tired similar configuration as radekzm.
      2 x Arduino nano connected via RS485 and is looks like only rs485 is not working so my question is; How to verified that connection between to arduinos using library AltSoftSerial is ok ?

      Are this connections PIN <-> RS485 (below) OK ?

      DE and RE -> Pin 2
      RO -> Pin 8
      DI -> Pin 9

      And below example is working fine (SoftwareSerial.h library)

      https://arduino-info.wikispaces.com/SoftwareSerialRS485Example

      posted in Development
      Michal
      Michal