@TheoL My Domoticz works again, I have to give it a fix ip because the IP was change and for your info, Your solution worked very well. It is now visible in Domoticz. Thanks for the support now I have to wait for other parts, I wait for my last parts for this project, an IR receiver so I can use a remote controle. After that I can use this project as a universal project, a default design in basic.
Again thanks!
Dick
@Dick
Best posts made by Dick
-
RE: gw send, how to do in my combination of sensors
-
RE: temp sensor keep on loging status switch
that was easy, I do it right away. Thanks for the support and this stopped me for changing other parts of the event of the code of the sensor.
Have a nice day! -
RE: Cobine working DHT22 and LDR with a RelayWithButtonActuator
@alexsh1
That could I do, thanks for the tip and will do that today. Any idea is welcome -
RE: 💬 Temperature Sensor
@mfalkvidd I ony can tell "thanksfo the support ad you time" . Have a nice wekend!!!
-
RE: pir combination with working 4-relay and 4 buttons
thats logic, I hoped that I learned something in the last cople of days but trouble shooting is something else. Thank you for your advise and go on with testing and adding other devises.
-
RE: No matching function for call 'DHT::DHT()'
@mfalkvidd You are right. This was the problem. I forgot to check that. thanks for the Direction!
-
RE: Multiple DHT22 in one sensor for greenhouse (newbee question)
At least I was able to test it. The solution worked perfect. Thanks for the support and I continue to finsh my project by implementing it at home. have a nice day. Bests
Dick -
RE: pir combination with working 4-relay and 4 buttons
I finaly made it 4 buttons, 4 relay and a pir and here the script for sharing
#include <MySensor.h> #include <SPI.h> #include "Bounce2.h" #define USE_MOTION_SENSOR #define MOTION_SENSOR_PIN 3 #define RELAY_ON 0 // switch around for realy HIGH/LOW state #define RELAY_OFF 1 Bounce motionsDebouncer = Bounce(); // MySensor gw; #define RADIO_ID 11 // radio Id, whatever channel you assigned to #define noRelays 4 const int relayPin[] = {A1, A2, A3, A4}; // switch around pins to your desire const int buttonPin[] = {A5, 6, 7, 8}; // switch around pins to your desire class Relay // relay class, store all relevant data (equivalent to struct) { public: int buttonPin; // physical pin number of button int relayPin; // physical pin number of relay byte oldValue; // last Values for key (debounce) boolean relayState; // relay status (also stored in EEPROM) }; Relay Relays[noRelays]; Bounce debouncer[noRelays]; MyMessage msg[noRelays]; void setup() { gw.begin(incomingMessage, RADIO_ID, true); delay(250); gw.sendSketchInfo("Multy-Relay&Pulsanti", "0.2"); delay(250); pinMode( MOTION_SENSOR_PIN, INPUT_PULLUP ); motionsDebouncer.attach(MOTION_SENSOR_PIN); motionsDebouncer.interval(50); // Initialize Relays with corresponding buttons for (int i = 0; i < noRelays; i++) { Relays[i].buttonPin = buttonPin[i]; // assign physical pins Relays[i].relayPin = relayPin[i]; msg[i].sensor = i; // initialize messages msg[i].type = V_LIGHT; debouncer[i] = Bounce(); // initialize debouncer debouncer[i].attach(buttonPin[i]); debouncer[i].interval(5); pinMode(Relays[i].buttonPin, INPUT_PULLUP); pinMode(Relays[i].relayPin, OUTPUT); Relays[i].relayState = gw.loadState(i); // retrieve last values from EEPROM digitalWrite(Relays[i].relayPin, Relays[i].relayState ? RELAY_ON : RELAY_OFF); // and set relays accordingly gw.send(msg[i].set(Relays[i].relayState ? true : false)); // make controller aware of last status gw.present(i, S_LIGHT); // present sensor to gateway delay(250); } } void loop() { if ( motionsDebouncer.update()) { int value = motionsDebouncer.read(); Serial.println( "Motion sensor is " + (String)value ); } { gw.process(); for (byte i = 0; i < noRelays; i++) { debouncer[i].update(); byte value = debouncer[i].read(); if (value != Relays[i].oldValue && value == 0) { Relays[i].relayState = !Relays[i].relayState; digitalWrite(Relays[i].relayPin, Relays[i].relayState ? RELAY_ON : RELAY_OFF); gw.send(msg[i].set(Relays[i].relayState ? true : false)); gw.saveState( i, Relays[i].relayState ); } // save sensor state in EEPROM (location == sensor number) Relays[i].oldValue = value; } } } // process incoming message void incomingMessage(const MyMessage &message) { if (message.type == V_LIGHT) { if (message.sensor < noRelays) // check if message is valid for relays..... previous line [[[ if (message.sensor <=noRelays){ ]]] { Relays[message.sensor].relayState = message.getBool(); digitalWrite(Relays[message.sensor].relayPin, Relays[message.sensor].relayState ? RELAY_ON : RELAY_OFF); // and set relays accordingly gw.saveState( message.sensor, Relays[message.sensor].relayState ); // save sensor state in EEPROM (location == sensor number) } } delay( 50 ); // give the input pins some rest. Incomming messages are still being processed. }
-
RE: error auto restart pi
@mfalkvidd I did not noticed that, I changed it to disabled and will monitor it during the upcomming days. Thanks for the tip!
-
RE: Not all Relais visible in Domoticz
@mfalkvidd thanks for your support and no errors anymore. Unfortunately it did not work forme. probably I split my sensors in to, one with the relais switches and 1 with the binary buttons. I think that is the only way to continue right now.
Latest posts made by Dick
-
Binary button must lock after using
Can anybody help how to get a Binary button in a sleep mode and cannot be used for 15 min. After 15min the button works again.
-
RE: IR remote controle
@nca78 I start experiment this weekend and will give it a try. Thanks for the ideas to make a working solution, in this case the use of an existing IR controle.
-
RE: IR remote controle
Thanks for the reply but this is probably to big for me. I wanted to make an IR remote to operate the most common use Mysensors in my house without starting the Domoticz app,The results I wanted to connect using an Event in domoticz
-
IR remote controle
I found a nice project using an IR remote controle, it is designed for Arduino but I have no idea how to convert the code to MySensors. Who can help? ```
/*Code belongs to this video https://www.youtube.com/watch?v=wqZwQnh6ZtQ
writen by Moz for YouTube changel logmaker360.
13-04-2016code works on a car mp3 remote controller
*/#include <IRremote.h>
int RECV_PIN = 6;
int BLUE_LED = 13;
int RED_LED = 12;IRrecv irrecv(RECV_PIN);
decode_results results;void setup() {
// initialize the digital pin as an output.
pinMode(RECV_PIN, INPUT);
pinMode(BLUE_LED, OUTPUT);
pinMode(RED_LED, OUTPUT);
irrecv.enableIRIn(); // Start the receiver
Serial.begin(9600);
}
void loop() {
int i=0;
if (irrecv.decode(&results)) {translateIR();
unknownRemoter();irrecv.resume(); // Receive the next value
}
}void translateIR() // takes action based on IR code received describing Car MP3 IR codes
{switch(results.value){
case 0xFFA25D:
Serial.println(" CH- ");
break;
case 0xFF629D:
Serial.println(" CH ");
break;
case 0xFFE21D:
Serial.println(" CH+ ");
break;
case 0xFF22DD:
Serial.println(" blue LED off ");
digitalWrite(13,LOW);
break;
case 0xFF02FD:
Serial.println(" blue LED on ");
digitalWrite(13, HIGH);
break;
case 0xFFC23D:
Serial.println(" PLAY/PAUSE ");
break;
case 0xFFE01F:
Serial.println(" VOL- ");
break;
case 0xFFA857:
Serial.println(" VOL+ ");
break;
case 0xFF906F:
Serial.println(" EQ ");
break;
case 0xFF6897:
Serial.println(" 0 ");
break;
case 0xFF9867:
Serial.println(" 100+ ");
break;
case 0xFFB04F:
Serial.println(" 200+ ");
break;
case 0xFF30CF:
Serial.println(" 1 ");
break;case 0xFF18E7:
Serial.println(" 2 ");
break;case 0xFF7A85:
Serial.println(" 3 ");
break;case 0xFF10EF:
Serial.println(" 4 ");
break;case 0xFF38C7:
Serial.println(" 5 ");
break;case 0xFF5AA5:
Serial.println(" 6 ");
break;case 0xFF42BD:
Serial.println(" 7 ");
break;case 0xFF4AB5:
Serial.println(" 8 ");
break;case 0xFF52AD:
Serial.println(" 9 ");
break;default:
Serial.print(" unknown button ");
Serial.println(results.value, HEX);}
delay(500);
}
void unknownRemoter(){ //this function is from an old remoter see video.
long RED_LED_OFF = 0xFF40BF;
long RED_LED_ON = 0xFF906F;
long LAST_BUTTON = 0xFFD02F;if (results.value == RED_LED_OFF){
Serial.println ("Red led off");
digitalWrite(12,LOW);
}
else if (results.value == RED_LED_ON )
{
Serial.println ("Red led on");
digitalWrite(12,HIGH);
}
else if (results.value == LAST_BUTTON )
{
Serial.println ("CAMERA IMAGE button");
}else{
Serial.print(" still an unknown button ");
Serial.println(results.value, HEX);
}
} -
RE: Not all Relais visible in Domoticz
@mfalkvidd thanks for your support and no errors anymore. Unfortunately it did not work forme. probably I split my sensors in to, one with the relais switches and 1 with the binary buttons. I think that is the only way to continue right now.
-
RE: Not all Relais visible in Domoticz
@mfalkvidd I tested the solution and the LOOP code looks like this
but having an error during compiling ("IF" was not declared in this scope). how can I fix that?void loop() { debouncerIRBIN.update(); // Get the update value int valueIRBIN = debouncerIRBIN.read(); if (valueIRBIN != oldValue_IRBIN) { // Send in the new value send(msgIRBIN.set(valueIRBIN == HIGH ? 1 : 0)); oldValue_IRBIN = valueIRBIN; } debouncerIRBUI.update(); // Get the update value int valueIRBUI = debouncerIRBUI.read(); if (valueIRBUI != oldValue_IRBUI) { // Send in the new value send(msgIRBUI.set(valueIRBUI == HIGH ? 1 : 0)); oldValue_IRBUI = valueIRBUI; } static bool startup = true; If (startup) { Send initial value for each switch/relay startup=false; } }```
-
RE: Not all Relais visible in Domoticz
@nagelc
Thanks for the reply but I am not that experience. I must add your script to the "LOOP" but doing that I get a message "startup" was not declared in the scope. Can you show me was to declair? -
RE: Multi relay with two Binary switches
@dick said in Multi relay with two Binary switches:
I created 2 project where I need 5 relays and 2 buttons. If I put the number of relays on 5, I only see 3 in my Domoticz. The switches are visible in Domoticz without problems. How can I fix the relay issue?
// Enable debug prints to serial monitor
#define MY_DEBUG// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69// Enable repeater functionality for this node
#define MY_REPEATER_FEATURE#include <SPI.h>
#include <MySensors.h>
#include <Bounce2.h>#define RELAY_1 A0 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define NUMBER_OF_RELAYS 5 // Total number of attached relays
#define RELAY_ON 0 // GPIO value to write to turn on attached relay
#define RELAY_OFF 1 // GPIO value to write to turn off attached relay#define CHILD_ID_IRBIN 3
#define CHILD_ID_IRBUI 4
#define IRBIN_PIN 3 // Arduino Digital I/O pin for button/reed switch
#define IRBUI_PIN 4Bounce debouncerIRBIN = Bounce();
Bounce debouncerIRBUI = Bounce();int oldValue_IRBIN = -1;
int oldValue_IRBUI = -1;MyMessage msgIRBIN(CHILD_ID_IRBIN, V_TRIPPED);
MyMessage msgIRBUI(CHILD_ID_IRBUI, V_TRIPPED);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()
{
// Setup the button1
pinMode(IRBIN_PIN, INPUT);
debouncerIRBIN.attach(IRBIN_PIN);
debouncerIRBIN.interval(5);
digitalWrite(IRBIN_PIN, HIGH);
// Setup the button2
pinMode(IRBUI_PIN, INPUT);
debouncerIRBUI.attach(IRBUI_PIN);
debouncerIRBUI.interval(5);
digitalWrite(IRBUI_PIN, HIGH);}
void presentation()
{
// Register binary input sensor to gw (they will be created as child devices)
// You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
// If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
present(CHILD_ID_IRBIN, S_DOOR);
present(CHILD_ID_IRBUI, 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_BINARY);
}
}void loop()
{
debouncerIRBIN.update();
// Get the update value
int valueIRBIN = debouncerIRBIN.read();if (valueIRBIN != oldValue_IRBIN) {
// Send in the new value
send(msgIRBIN.set(valueIRBIN == HIGH ? 1 : 0));
oldValue_IRBIN = valueIRBIN;
}debouncerIRBUI.update();
// Get the update value
int valueIRBUI = debouncerIRBUI.read();if (valueIRBUI != oldValue_IRBUI) {
// Send in the new value
send(msgIRBUI.set(valueIRBUI == HIGH ? 1 : 0));
oldValue_IRBUI = valueIRBUI;
}
}void receive(const MyMessage &message)
{
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_STATUS) {
// 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());
}
}Sorry, add my questions two times
-
Not all Relais visible in Domoticz
I started a project with 5 relays and 2 binary buttons. In Domotics 3 of the 5 relays pops up including the 2 binary buttons. Why not 5 relays?
// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 // Enable repeater functionality for this node #define MY_REPEATER_FEATURE #include <SPI.h> #include <MySensors.h> #include <Bounce2.h> #define RELAY_1 A0 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define NUMBER_OF_RELAYS 5 // Total number of attached relays #define RELAY_ON 0 // GPIO value to write to turn on attached relay #define RELAY_OFF 1 // GPIO value to write to turn off attached relay #define CHILD_ID_IRBIN 3 #define CHILD_ID_IRBUI 4 #define IRBIN_PIN 3 // Arduino Digital I/O pin for button/reed switch #define IRBUI_PIN 4 Bounce debouncerIRBIN = Bounce(); Bounce debouncerIRBUI = Bounce(); int oldValue_IRBIN = -1; int oldValue_IRBUI = -1; MyMessage msgIRBIN(CHILD_ID_IRBIN, V_TRIPPED); MyMessage msgIRBUI(CHILD_ID_IRBUI, V_TRIPPED); 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() { // Setup the button1 pinMode(IRBIN_PIN, INPUT); debouncerIRBIN.attach(IRBIN_PIN); debouncerIRBIN.interval(5); digitalWrite(IRBIN_PIN, HIGH); // Setup the button2 pinMode(IRBUI_PIN, INPUT); debouncerIRBUI.attach(IRBUI_PIN); debouncerIRBUI.interval(5); digitalWrite(IRBUI_PIN, HIGH); } void presentation() { // Register binary input sensor to gw (they will be created as child devices) // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. // If S_LIGHT is used, remember to update variable type you send in. See "msg" above. present(CHILD_ID_IRBIN, S_DOOR); present(CHILD_ID_IRBUI, 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_BINARY); } } void loop() { debouncerIRBIN.update(); // Get the update value int valueIRBIN = debouncerIRBIN.read(); if (valueIRBIN != oldValue_IRBIN) { // Send in the new value send(msgIRBIN.set(valueIRBIN == HIGH ? 1 : 0)); oldValue_IRBIN = valueIRBIN; } debouncerIRBUI.update(); // Get the update value int valueIRBUI = debouncerIRBUI.read(); if (valueIRBUI != oldValue_IRBUI) { // Send in the new value send(msgIRBUI.set(valueIRBUI == HIGH ? 1 : 0)); oldValue_IRBUI = valueIRBUI; } } void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_STATUS) { // 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()); } }
-
Multi relay with two Binary switches
I created 2 project where I need 5 relays and 2 buttons. If I put the number of relays on 5, I only see 3 in my Domoticz. The switches are visible in Domoticz without problems. How can I fix the relay issue?
// Enable debug prints to serial monitor
#define MY_DEBUG// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69// Enable repeater functionality for this node
#define MY_REPEATER_FEATURE#include <SPI.h>
#include <MySensors.h>
#include <Bounce2.h>#define RELAY_1 A0 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define NUMBER_OF_RELAYS 5 // Total number of attached relays
#define RELAY_ON 0 // GPIO value to write to turn on attached relay
#define RELAY_OFF 1 // GPIO value to write to turn off attached relay#define CHILD_ID_IRBIN 3
#define CHILD_ID_IRBUI 4
#define IRBIN_PIN 3 // Arduino Digital I/O pin for button/reed switch
#define IRBUI_PIN 4Bounce debouncerIRBIN = Bounce();
Bounce debouncerIRBUI = Bounce();int oldValue_IRBIN = -1;
int oldValue_IRBUI = -1;MyMessage msgIRBIN(CHILD_ID_IRBIN, V_TRIPPED);
MyMessage msgIRBUI(CHILD_ID_IRBUI, V_TRIPPED);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()
{
// Setup the button1
pinMode(IRBIN_PIN, INPUT);
debouncerIRBIN.attach(IRBIN_PIN);
debouncerIRBIN.interval(5);
digitalWrite(IRBIN_PIN, HIGH);
// Setup the button2
pinMode(IRBUI_PIN, INPUT);
debouncerIRBUI.attach(IRBUI_PIN);
debouncerIRBUI.interval(5);
digitalWrite(IRBUI_PIN, HIGH);}
void presentation()
{
// Register binary input sensor to gw (they will be created as child devices)
// You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
// If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
present(CHILD_ID_IRBIN, S_DOOR);
present(CHILD_ID_IRBUI, 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_BINARY); }
}
void loop()
{
debouncerIRBIN.update();
// Get the update value
int valueIRBIN = debouncerIRBIN.read();if (valueIRBIN != oldValue_IRBIN) {
// Send in the new value
send(msgIRBIN.set(valueIRBIN == HIGH ? 1 : 0));
oldValue_IRBIN = valueIRBIN;
}debouncerIRBUI.update();
// Get the update value
int valueIRBUI = debouncerIRBUI.read();if (valueIRBUI != oldValue_IRBUI) {
// Send in the new value
send(msgIRBUI.set(valueIRBUI == HIGH ? 1 : 0));
oldValue_IRBUI = valueIRBUI;
}
}void receive(const MyMessage &message)
{
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_STATUS) {
// 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());
}
}