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
A

alco

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

Posts

Recent Best Controversial

  • Domoticz/Mysensors
    A alco

    #define MY_DEBUG
    #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 == 8000000L
    #define MY_BAUD_RATE 38400
    #endif

    // 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

    #include <SPI.h>
    #include <MySensors.h>
    #include <Bounce2.h>

    // Enable repeater functionality for this node
    #define MY_REPEATER_FEATURE

    #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 noLightSwitch 10 //2-11
    int relayPin[] = {2,3,4,5,6,7,8,9,10,11}; // switch around pins to your desire
    int buttonPin[] = {A0,A1,A2,A3,A4,A5,A6,A7,A8,A9}; // switch around pins to your desire
    Bounce debouncer[10];
    MyMessage msg[10];

    void before() {
    //sendHeartbeat();
    wait(100);
    // Initialize Relays with corresponding buttons
    for (int i = 0; i < noLightSwitch; i++){
    // Setup the button.
    pinMode(buttonPin[i], INPUT_PULLUP);
    wait(100);
    // Then set relay pins in output mode
    pinMode(relayPin[i], OUTPUT);
    wait(100);
    digitalWrite(relayPin[i], RELAY_OFF);
    msg[i].sensor = i; // initialize messages
    msg[i].type = V_LIGHT;
    //send(msg[i].set(loadState(i))); // make controller aware of last status
    //wait(100);
    // setup debouncer.
    debouncer[i] = Bounce(); // initialize debouncer
    debouncer[i].attach(buttonPin[i]);
    debouncer[i].interval(20);
    }
    }

    void setup() {
    // Setup locally attached sensors
    delay(100);
    presentation();
    }

    boolean inputState;
    void presentation() {
    // Send the sketch version information to the gateway and Controller
    sendSketchInfo("Relay", "1.0");
    // Register all sensors to gw (they will be created as child devices)
    for (int i = 0; i < noLightSwitch; i++){
    present(buttonPin[i], S_LIGHT);
    inputState =! digitalRead(buttonPin[i]);
    send(msg[i].set(inputState));
    }
    wait(100);
    }

    void loop() {
    // Send locally attached sensor data here
    for (int i = 0; i < noLightSwitch; i++){
    if (debouncer[i].update()) {
    inputState =! digitalRead(buttonPin[i]);
    send(msg[i].set(inputState));
    }
    wait(100);
    }
    }

    void receive(const MyMessage &message) {
    // We only expect one type of message from controller. But we better check anyway.
    if (message.type==V_LIGHT) {
    for (int i = 0; i < noLightSwitch; i++) {
    if (i == message.sensor){
    digitalWrite(relayPin[i], RELAY_ON);
    wait(100);
    digitalWrite(relayPin[i], RELAY_OFF);
    wait(100);
    inputState =! digitalRead(buttonPin[i]);
    send(msg[i].set(inputState));
    }
    }
    }
    }

    Domoticz

  • Domoticz/Mysensors
    A alco

    Hi
    Thanks. The good thing is that the light circuit is independent from Arduino and Raspberry. That was the main reason behind it. I was supposed to add a description but something went wrong and I only published the schematic. Anyway, I have got a problem with a script for this solution.
    Anybody can help with the programming?

    Domoticz

  • Domoticz/Mysensors
    A alco

    IMG_1446.JPG

    Domoticz
  • Login

  • Don't have an account? Register

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