Hmm, I've changed it to S_DOOR now. But I still can turn it on and off in Domoticz.
I guess this is a Domoticz thing and has nothing to do with MySensors... Weird...
Posts made by PDP8
-
RE: Multiple switch inputs
-
RE: Multiple switch inputs
Thanks for the comment, I will look at it.
Another question, the inputs look exactly like an output in domoticz.
I can even switch on the lamp with the mouse. Of course there is nothing happening
because it is an input. But it is a bit confusing. Is this a Domoticz setting? Or can I change
something in the MySensors code for this? Thanks! -
RE: Multiple switch inputs
Well to make three inputs I've come to this using the code you mentioned...
I've removed the invert function because I could get Domotics invert the
monitoring. And I've added an initial read at startup. Because at powering-up
the switches were not read. Any comments? Regards!// Enable debug prints to serial monitor #define MY_DEBUG // Enable serial gateway #define MY_GATEWAY_SERIAL #include <SPI.h> #include <MySensors.h> #include <Bounce2.h> // Define Sensor ID's #define KNOB_A_ID 1 // Id of the sensor child #define KNOB_B_ID 2 // Id of the sensor child #define KNOB_C_ID 3 // Id of the sensor child // Define buttons const int buttonPinA = 10; const int buttonPinB = 11; const int buttonPinC = 12; // Define Variables int oldValueA = 0; int oldValueB = 0; int oldValueC = 0; bool stateA = false; bool stateB = false; bool stateC = false; int trigger = 0; Bounce debouncerA = Bounce(); Bounce debouncerB = Bounce(); Bounce debouncerC = Bounce(); MyMessage msgA(KNOB_A_ID, V_STATUS); MyMessage msgB(KNOB_B_ID, V_STATUS); MyMessage msgC(KNOB_C_ID, V_STATUS); void setup() { pinMode(buttonPinA, INPUT_PULLUP); // Setup the button Activate internal pull-up pinMode(buttonPinB, INPUT_PULLUP); // Setup the button Activate internal pull-up pinMode(buttonPinC, INPUT_PULLUP); // Setup the button Activate internal pull-up // After setting up the buttons, setup debouncer debouncerA.attach(buttonPinA); debouncerA.interval(5); debouncerB.attach(buttonPinB); debouncerB.interval(5); debouncerC.attach(buttonPinC); debouncerC.interval(5); /*--------------------- Added these lines for toggle switch-------------------------*/ oldValueA = digitalRead(buttonPinA); // set oldValueA to the current status of the toggle switch oldValueB = digitalRead(buttonPinB); // set oldValueB to the current status of the toggle switch oldValueC = digitalRead(buttonPinC); // set oldValueC to the current status of the toggle switch } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("2x bistable button", "1.1"); // Register all sensors to gw (they will be created as child devices) present(KNOB_A_ID, S_LIGHT); present(KNOB_B_ID, S_LIGHT); present(KNOB_C_ID, S_LIGHT); } void loop() { if (trigger == 0) { debouncerA.update(); // Get the startup valueA int valueA = debouncerA.read(); send(msgA.set(valueA==HIGH ? 0 : 1)); debouncerB.update(); // Get the startup valueB int valueB = debouncerB.read(); send(msgB.set(valueB==HIGH ? 0 : 1)); debouncerC.update(); // Get the startup valueC int valueC = debouncerC.read(); send(msgC.set(valueC==HIGH ? 0 : 1)); trigger = 1; } debouncerA.update(); // Get the update valueA int valueA = debouncerA.read(); if (valueA != oldValueA) { // Send in the new valueA send(msgA.set(valueA==HIGH ? 0 : 1)); oldValueA = valueA; } debouncerB.update(); // Get the update valueB int valueB = debouncerB.read(); if (valueB != oldValueB) { // Send in the new valueB send(msgB.set(valueB==HIGH ? 0 : 1)); oldValueB = valueB; } debouncerC.update(); // Get the update valueC int valueC = debouncerC.read(); if (valueC != oldValueC) { // Send in the new valueC send(msgC.set(valueC==HIGH ? 0 : 1)); oldValueC = valueC; } }
-
RE: Multiple switch inputs
@rejoe2 said in Multiple switch inputs:
Thanks, I will dive into the code then
-
RE: Multiple switch inputs
Thanks, it seems the switches also turn on the relays directly?
I have to figure out the code. I just want to have independent switch inputs.If there is some code which has only switches it would help a lot
Regards
-
Multiple switch inputs
Hello all,
I'm new here and also new to MySensors. I got here trough Domoticz.
At the moment I have an Arduino Nano running and configured as a serial gateway trough USB.
I've combined the relay and temperature sketch and now I can use a ds18b20 and 8 relays simultaneous on that board.But I want to add some switches too. I've seen a button sketch but that is for just one button.
I've read about expanding this sketch would give problems with the debounce code.Does anyone have an example for multiple switches on one Arduino?
Thanks in advance!