Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
M

Mati_Smart

@Mati_Smart
About
Posts
3
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Reading INPUTS from arduino in domoticz
    M Mati_Smart

    @hard-shovel

    I think, my problem is in MyMessage function.
    It looks fine, but it not working with domoticz.

    In "hardware'' - "MySensorsUSBGateway" - "Setup" - "Nodes" I can see taht my child ID 20 and 21 are switching
    But in "devices" tab both are always on

    @evb
    I tried to do like this simple example: https://www.mysensors.org/build/binary
    I moved "MyMessage" from "void presentation" and put in before "void before"
    It did't help.

    Of course this sketch: https://www.mysensors.org/build/binary without my relays it works fine.

    @hard-shovel thanks for the suggestion about My Inclusion and my repeater - I'm not using this, I have to disable it.

    @evb I understand the basics (only basisc) of Arduino programming and hardware.
    I have 10 years of expirience in PLC programming and a little experience in "C" language.

    Hardware

  • Reading INPUTS from arduino in domoticz
    M Mati_Smart

    Thank you for your answer.

    I wan to use this relay outputs and this outputs works good.
    So, I can't use pins D20 and D21?
    I want to use about 20-25 digital inputs but for testing i use this two.
    I write this sketch on the faith of examples "digital inputs gateway"

    Hardware

  • Reading INPUTS from arduino in domoticz
    M Mati_Smart

    Hello,

    Can you help me with reading inputs (like door, window open)?

    I try to use mega2560 to read inputs.

    With this code, i see in domoticz input1 and input2 always on...
    Do you know what can be wrong?
    My sketch:

    
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    
    // Enable and select radio type attached
    //#define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    // Set LOW transmit power level as default, if you have an amplified NRF-module and
    // power your radio separately with a good regulator you can turn up PA level. 
    //#define MY_RF24_PA_LEVEL RF24_PA_LOW
    
    // Enable serial gateway
    #define MY_GATEWAY_SERIAL
    
    // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
    #if F_CPU == 12000000L
    #define MY_BAUD_RATE 115200
    #endif
    
    // Flash leds on rx/tx/err
    // #define MY_LEDS_BLINKING_FEATURE
    // Set blinking period
    // #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Inverses the behavior of leds
    // #define MY_WITH_LEDS_BLINKING_INVERSE
    
    // Enable inclusion mode
    #define MY_INCLUSION_MODE_FEATURE
    // Enable Inclusion mode button on gateway
    #define MY_INCLUSION_BUTTON_FEATURE
    
    // Inverses behavior of inclusion button (if using external pullup)
    //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
    
    // 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 
    
    // Uncomment to override default HW configurations
    //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
    //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
    //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <Bounce2.h>
    
    // Enable repeater functionality for this node
    #define MY_REPEATER_FEATURE
    
    
    #define RELAY_1  4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define RELAY_2  5
    #define RELAY_3  6
    #define RELAY_4  7
    #define RELAY_5  8
    #define RELAY_6  9
    #define RELAY_7  10
    #define RELAY_8  11
    #define RELAY_9  12
    #define RELAY_10  13
    #define RELAY_11  14
    #define RELAY_12  15
    #define NUMBER_OF_RELAYS  12 // Total number of attached relays                             dodać na próbę wejścia
    #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
    
    
    #define CHILD_ID_1 20
    #define CHILD_ID_2 21
    
    #define INPUT_1  20
    #define INPUT_2  21
    
    
    Bounce debouncer1 = Bounce(); 
    Bounce debouncer2 = Bounce(); 
    
    int oldValue1 = -1;
    int oldValue2 = -1;
    
    
    
    void before() { 
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
        // Then set relay pins in output mode
        pinMode(pin, OUTPUT);   
        // Set relay to last known state (using eeprom storage) 
        digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
      }
    }
    
    
    void setup()  {
    
    
      pinMode(INPUT_1,INPUT);
      debouncer1.attach(INPUT_1);
      debouncer1.interval(5);
      digitalWrite(INPUT_1,HIGH);
      
    
      pinMode(INPUT_2,INPUT);
      debouncer2.attach(INPUT_2);
      debouncer2.interval(5);
      digitalWrite(INPUT_2,HIGH);
    
    }
    
    
    void presentation()  
    {   
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Relay", "1.0");
     present(CHILD_ID_1, S_DOOR);
     present(CHILD_ID_2, S_DOOR);
    
      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)
        present(sensor, S_LIGHT);
    
    
    
      }
    }
    
    
    
    MyMessage msg(1, V_LIGHT);
    MyMessage msg2(2, V_LIGHT);
    MyMessage msg3(3, V_LIGHT);
    MyMessage msg4(4, V_LIGHT);
    MyMessage msg5(5, V_LIGHT);
    MyMessage msg6(6, V_LIGHT);
    MyMessage msg7(7, V_LIGHT);
    MyMessage msg8(8, V_LIGHT);
    MyMessage msg9(9, V_LIGHT);
    MyMessage msg10(10, V_LIGHT);
    MyMessage msg11(11, V_LIGHT);
    MyMessage msg12(12, V_LIGHT);
    MyMessage msg13(CHILD_ID_1, V_TRIPPED);
    MyMessage msg14(CHILD_ID_2, V_TRIPPED);
    
    
    
    void loop() {
    
    
    
      debouncer1.update();
      int value1 = debouncer1.read();
     
      if (value1 != oldValue1) {
         send(msg13.set(value1 == HIGH ? 1 : 0));
         oldValue1 = value1;
      }
    
           debouncer2.update();
      int value2 = debouncer2.read();
     
      if (value2 != oldValue2) {
         send(msg14.set(value2 == HIGH ? 1 : 0));
         oldValue2 = value2;
      }
    }
      
    
    
    void receive(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
         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());
       } 
    }
    
    Hardware
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular