Double relais AC-DC ne fonctionne pas !

Forum dédie aux capteurs et gateway mysensors.org
tonnerre33
Messages : 8
Inscription : 15 nov. 2016, 21:46

Re: Double relais AC-DC ne fonctionne pas !

Message par tonnerre33 »

Salut les logs du node me font penser à un module nrf sous alimente. Comment alimentes tu ton node ? Si c'est avec un programmateur vérifié que tu est bien en 5v et non 3.3. Si tout est bon côté alimentation essayés de changer de nrf.
ganq
Messages : 385
Inscription : 01 avr. 2015, 14:20

Re: Double relais AC-DC ne fonctionne pas !

Message par ganq »

Oui, le noeud n'a pas de numéro... Je ne suis pas sur que cela soit normal.
Concernant le manque d'alimentation, je peux te raconter mon expérience. J'ai cherché plusieurs jours pourquoi ma gateway ne répondait plus. J'ai tout changé, mais ce qui a fonctionné, c'est une alimentation externe du NRF. Donc, j'utilise deux ports USB pour ma gateway : un vers arduino, un vers l'alim du NRF. Depuis ca fonctionne bien... Je ne comprends pas pourquoi l'arduino n'arrive pas à alimenter le nrf.. Tu as peut-être le même pb...
domoticien amateur option bidouille
laster13
Messages : 23
Inscription : 01 nov. 2016, 19:01

Re: Double relais AC-DC ne fonctionne pas !

Message par laster13 »

@tonnerre33
Oui j'utilise le FTDI USB en 5v pour l'alimentation du node et j'ai change le NRF de la passerelle, toujours pareil. Dois je envisager aussi de changer le NRF du node ? Si oui cela risque d'être coton vu qu' il est soudé .. je vois mal comment le dessouder et le retirer. Faut dire que mon expérience en soudure frize le zéro pointé vu que c'est ma première expérience en la matière :oops:

Quoiqu'il en soit j'ai soudé 2 PCB et j'obtiens les mêmes erreurs, peu être mon lot de NRF commandé sur aliexpress est il défectueux.

L'arduino de la passerelle (Raspberry B+) est un uno et j'ai mis un condo sur le NRF.

@ganq
D'après ce que tu me dis cela pourrait être un problème de réception au niveau Gateway (alimentation du NRF)
ganq a écrit :Donc, j'utilise deux ports USB pour ma gateway : un vers arduino, un vers l'alim du NRF
le 1er port vers l'arduino ok par contre le 2eme port usb du raspi vers l'alim du NRF .. je vois pas :oops:

En clair le problème viendrait il de la Gateway ou bien de la node? Si j'arrivais à localiser la source du problème ca m'aiderait à orienter mes recherches

merci à vous
ganq
Messages : 385
Inscription : 01 avr. 2015, 14:20

Re: Double relais AC-DC ne fonctionne pas !

Message par ganq »

Oui, le 2e de l'usb du pi (et en coupant le bout du fil), je récupère le + et le - (noir et rouge) que je branche sur l'alim du NRF.

As-tu la possibilité de créer un autre node ?
As-tu la possibilité de créer une autre gateway ?
domoticien amateur option bidouille
tonnerre33
Messages : 8
Inscription : 15 nov. 2016, 21:46

Re: Double relais AC-DC ne fonctionne pas !

Message par tonnerre33 »

En fait ta passerelle et ton node n'arrive pas à communiquer, cela peut venir d'un problème d'alim ou d'un problème de configuration.

Est-ce que tu peux nous poster le programme de ta passerelle et celle de ton node pour que l'on contrôle ta config.

Il faut aussi que tu nous donne la config exacte de ta passerelle et celle du node :

Type d'arduino : (pro mini, uno, etc...)
Tension de la carte arduino (5V ou 3.3)
Comment tu as réalisé l'alimentation de la carte arduino
Le type de transducteur sans fil utilisé (référence la plus précise possible)
Sur quelle broche de l'arduino tu as connecté l'alimentation du transducteur sans fil

Exemple de ce que j'ai fait :

Passerelle :

:arrow: Type arduino : Arduino UNO
:arrow: Tension : 5V
:arrow: Réalisation alim arduino: Alimentation par USB du rasberry pi 2
:arrow: Ref transducteur : NRF24L01 + PA + LNA avec L'antenne (lien de commande ici)
:arrow: Réalisation alim transducteur :
5V arduino -> VCC Socket Adaptateur(voir type ici)
GND arduino -> GND Socket Adaptateur
:arrow: Code de la passerelle :

Code : Tout sélectionner

  /**
 * 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.
 *
 *******************************
 *
 * DESCRIPTION
 * The ArduinoGateway prints data received from sensors on the serial link. 
 * The gateway accepts input on seral which will be sent out on radio network.
 *
 * The GW code is designed for Arduino Nano 328p / 16MHz
 *
 * Wire connections (OPTIONAL):
 * - Inclusion button should be connected between digital pin 3 and GND  
 * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
 *
 * LEDs (OPTIONAL):
 * - To use the feature, uncomment MY_LEDS_BLINKING_FEATURE in MyConfig.h
 * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
 * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
 * - ERR (red) - fast blink on error during transmission error or recieve crc error 
 * 
 */

// Enable debug prints to serial monitor
//#define MY_DEBUG 


// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69

/*JBY_ADD_S*/
//#define MY_DEBUG_VERBOSE_SIGNING
#define MY_SIGNING_SOFT
// SETTINGS FOR MY_SIGNING_SOFT
#define MY_SIGNING_SOFT_RANDOMSEED_PIN 7 
// Enable this if you want destination node to sign all messages sent to this node.
#define MY_SIGNING_REQUEST_SIGNATURES
//#define MY_SIGNING_NODE_WHITELISTING {{.nodeId = 4,.serial = {0xA6,0x6C,0x4D,0x7A,0xA1,0xBB,0x5B,0xE6,0xF8}}}

/*JBY_ADD_E*/

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

void setup() { 
  // Setup locally attached sensors
}

void presentation() {
 // Present locally attached sensors 
}

void loop() { 
  // Send locally attached sensor data here 
}




Node:

:arrow: Type arduino : Arduino pro mini
:arrow: Tension : 5VCC
:arrow: Réalisation alim arduino: 230V / 5VCC par alim HLK-PM01
:arrow: Ref transducteur : NRF24l01 + (lien de commande ici)
:arrow: Réalisation alim transducteur : Câblage interne par PCB
:arrow: Code du node :

Code : Tout sélectionner

/**
 * 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.
 *
 *******************************
 *
 * DESCRIPTION
 *
 * Script for double SSR relay board by Aproxx
 * https://www.openhardware.io/view/77/AC-DC-double-solid-state-relay-module
 * https://forum.mysensors.org/topic/3671/ac-dc-double-solid-state-relay-module
 * Control 2 circuits either from controller or from physical buttons connected on pins 4 & 7
 * Optional DS18b20 is connected on pin 8
 * 
 *  HISTORY :
 * xx/xx/2016 original version by Aproxx
 * 08/02/2016 upgraded to MySensors 2.0 by mr_const
 * 08/30/2016 changes by Nca78 :
 *        - fixed initialization of physical buttons/debouncer status
 *        - centralized pin status change for relays in setRelayState method
 *        - centralized debug information for state changes in one method + added debug info when changed by physical switches
 *        - added #ifdef MY_DEBUG before each Serial.print (saves prog memory when not in debug mode) and F() macros for debug strings (saves RAM when in debug mode)
 *        - added #define USE_TEMP_SENSOR to make temperature sensor optional (not used if line is commented)
 *        - put back #define for repeater feature
 *        - add #define TEMPERATURE_ROUNDING for custom temperature rounding
**/

//#define MY_NODE_ID 100

// MySensor Debug
#define MY_DEBUG

// Enables repeater functionality (relays messages from other nodes)
//#define MY_REPEATER_FEATURE

// Comment line below if you don't want to use the temperature sensor
#define USE_TEMP_SENSOR

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

#define RELAY_PIN    3  // Arduino Digital I/O pin number for relay 
#define RELAY_PIN_2  5
#define BUTTON_PIN   4  // Arduino Digital I/O pin number for button 
#define BUTTON_PIN_2 7

#define CHILD_ID 11 // Id of the sensor child for 1st relay
#define CHILD_ID_2 12 // Id of the sensor child for 2nd relay

// Relay status
#define RELAY_ON 1
#define RELAY_OFF 0

// Source of state change (used when printing debug information)
#define CHANGE_STATE_SOURCE_RADIO 0
#define CHANGE_STATE_SOURCE_SWITCH 1


// Temperature sensor definitions
#ifdef USE_TEMP_SENSOR
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 8
#define CHILD_DSB_ID 13 // Id of the sensor child for temperature sensor
#define TEMPERATURE_ROUNDING 10.f   // Change value to change rounding of temperature value: 10.f for 0.1°C change, 5.f for 0.2°C change, 2.f for 0.5°C change
#endif



Bounce debouncer = Bounce();
int oldValue;
bool state;
Bounce debouncer2 = Bounce();
int oldValue2;
bool state2;

MyMessage msg(CHILD_ID, V_LIGHT);
MyMessage msg2(CHILD_ID_2, V_LIGHT);

#ifdef USE_TEMP_SENSOR
MyMessage msgTemp(CHILD_DSB_ID, V_TEMP);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature.
#endif

void presentation() {
  // Send the sketch version information to the gateway and Controller
  sendSketchInfo("Double Relay & Button", "0.2");
  // Register all sensors to gw (they will be created as child devices)
  present(CHILD_ID, S_LIGHT);
  present(CHILD_ID_2, S_LIGHT);
#ifdef USE_TEMP_SENSOR
  present(CHILD_DSB_ID, S_TEMP);
#endif
}

void setup()
{
#ifdef USE_TEMP_SENSOR
  sensors.begin();
  sensors.setWaitForConversion(false);
#endif

  // Setup the button
  pinMode(BUTTON_PIN, INPUT);
  // Activate internal pull-up
  digitalWrite(BUTTON_PIN, HIGH);

  // Setup the button
  pinMode(BUTTON_PIN_2, INPUT);
  // Activate internal pull-up
  digitalWrite(BUTTON_PIN_2, HIGH);

  // After setting up the button, setup debouncer
  debouncer.attach(BUTTON_PIN);
  debouncer.interval(5);

  debouncer2.attach(BUTTON_PIN_2);
  debouncer2.interval(5);

  // Set the initial values of oldValue/oldValue2 variables from status of physical switches
  //  if this is not done the loop() will detect status change and switch the relays on or off
  debouncer.update();
  debouncer2.update();
  oldValue = debouncer.read();
  oldValue2 = debouncer2.read();


  // Make sure relays are off when starting up
  setRelayState(RELAY_PIN, RELAY_OFF);
  // Then set relay pins in output mode
  pinMode(RELAY_PIN, OUTPUT);

  digitalWrite(RELAY_PIN_2, RELAY_OFF);
  // Then set relay pins in output mode
  pinMode(RELAY_PIN_2, OUTPUT);

  // Set relay to last known state (using eeprom storage)
  state = loadState(CHILD_ID);
  setRelayState(RELAY_PIN, state);

  state2 = loadState(CHILD_ID_2);
  setRelayState(RELAY_PIN_2, state2);
}


/*
   Example on how to asynchronously check for new messages from gw
*/
void loop()
{
#ifdef USE_TEMP_SENSOR
  static float prevTemp = 0;
#endif

  debouncer.update();
  debouncer2.update();
  // Get the update value
  int value = debouncer.read();
  int value2 = debouncer2.read();

  if (value != oldValue) {
    send(msg.set(state ? false : true), true); // Send new state and request ack back
    // Write some debug info
    printStateChangedDebug(CHANGE_STATE_SOURCE_SWITCH, CHILD_ID, value);
  }
  oldValue = value;

  if (value2 != oldValue2) {
    send(msg2.set(state2 ? false : true), true); // Send new state and request ack back
    // Write some debug info
    printStateChangedDebug(CHANGE_STATE_SOURCE_SWITCH, CHILD_ID_2, value2);
  }
  oldValue2 = value2;

  // Fetch temperatures from Dallas sensors
#ifdef USE_TEMP_SENSOR
  sensors.requestTemperatures();
  // Fetch and round temperature to one decimal
  float temperature = static_cast<float>(static_cast<int>(sensors.getTempCByIndex(0) * TEMPERATURE_ROUNDING)) / TEMPERATURE_ROUNDING;

  if (temperature != -127.00f && temperature != 85.00f && prevTemp != temperature) {
    // Send in the new temperature
    send(msgTemp.set(temperature, 1));
#ifdef MY_DEBUG
    Serial.print("Sent temperature: ");
    Serial.println(temperature);
#endif
    prevTemp = temperature;
  }
#endif
}

void receive(const MyMessage &message) {
  // We only expect one type of message from controller. But we better check anyway.
  if (message.isAck()) {
#ifdef MY_DEBUG
    Serial.println(F("This is an ack from gateway"));
#endif
  }
  else if (message.type == V_LIGHT && message.sensor == CHILD_ID) {
    // Change relay state
    state = message.getBool();
    setRelayState(RELAY_PIN, state);
    // Store state in eeprom
    saveState(CHILD_ID, state);
    // Write some debug info
    printStateChangedDebug(CHANGE_STATE_SOURCE_RADIO, CHILD_ID, state);
  }
  else if (message.type == V_LIGHT && message.sensor == CHILD_ID_2) {
    state2 = message.getBool();
    setRelayState(RELAY_PIN_2, state2);
    // Store state in eeprom
    saveState(CHILD_ID_2, state2);
    // Write some debug info
    printStateChangedDebug(CHANGE_STATE_SOURCE_RADIO, CHILD_ID_2, state2);
  }
}

// Set status of a relay pin
void setRelayState(byte relayPin, bool value) {
  digitalWrite(relayPin, value ? RELAY_ON : RELAY_OFF);
}

// Print debug info, centralized in one place to minimize memory usage and have only one #ifdef MY_DEBUG for all state change messages
void printStateChangedDebug(int source, int sensorID, bool value) {
#ifdef MY_DEBUG
  Serial.print(F("Sensor value changed, source="));
  Serial.print(source == CHANGE_STATE_SOURCE_RADIO ? F("Radio") : F("Physical switch"));
  Serial.print(F(", Sensor="));
  Serial.print(sensorID);
  Serial.print(F(", New status: "));
  Serial.println(value);
#endif
}
laster13
Messages : 23
Inscription : 01 nov. 2016, 19:01

Re: Double relais AC-DC ne fonctionne pas !

Message par laster13 »

le progrramme de la passerelle

Code : Tout sélectionner

  /**
 * 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.
 *
 *******************************
 *
 * DESCRIPTION
 * The ArduinoGateway prints data received from sensors on the serial link. 
 * The gateway accepts input on seral which will be sent out on radio network.
 *
 * The GW code is designed for Arduino Nano 328p / 16MHz
 *
 * Wire connections (OPTIONAL):
 * - Inclusion button should be connected between digital pin 3 and GND  
 * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
 *
 * LEDs (OPTIONAL):
 * - To use the feature, uncomment MY_LEDS_BLINKING_FEATURE in MyConfig.h
 * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
 * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
 * - ERR (red) - fast blink on error during transmission error or recieve crc error 
 * 
 */

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

void setup() { 
  // Setup locally attached sensors
}

void presentation() {
 // Present locally attached sensors 
}

void loop() { 
  // Send locally attached sensor data here 
}





Programme node

Code : Tout sélectionner

/**
 * 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.
 *
 *******************************
 *
 * DESCRIPTION
 *
 * Script for double SSR relay board by Aproxx
 * https://www.openhardware.io/view/77/AC-DC-double-solid-state-relay-module
 * https://forum.mysensors.org/topic/3671/ac-dc-double-solid-state-relay-module
 * Control 2 circuits either from controller or from physical buttons connected on pins 4 & 7
 * Optional DS18b20 is connected on pin 8
 * 
 *  HISTORY :
 * xx/xx/2016 original version by Aproxx
 * 08/02/2016 upgraded to MySensors 2.0 by mr_const
 * 08/30/2016 changes by Nca78 :
 *        - fixed initialization of physical buttons/debouncer status
 *        - centralized pin status change for relays in setRelayState method
 *        - centralized debug information for state changes in one method + added debug info when changed by physical switches
 *        - added #ifdef MY_DEBUG before each Serial.print (saves prog memory when not in debug mode) and F() macros for debug strings (saves RAM when in debug mode)
 *        - added #define USE_TEMP_SENSOR to make temperature sensor optional (not used if line is commented)
 *        - put back #define for repeater feature
 *        - add #define TEMPERATURE_ROUNDING for custom temperature rounding
**/

// MySensor Debug
#define MY_DEBUG

// Enables repeater functionality (relays messages from other nodes)
//#define MY_REPEATER_FEATURE

// Comment line below if you don't want to use the temperature sensor
#define USE_TEMP_SENSOR

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

#define RELAY_PIN    3  // Arduino Digital I/O pin number for relay 
#define RELAY_PIN_2  5
#define BUTTON_PIN   4  // Arduino Digital I/O pin number for button 
#define BUTTON_PIN_2 7

#define CHILD_ID 11 // Id of the sensor child for 1st relay
#define CHILD_ID_2 12 // Id of the sensor child for 2nd relay

// Relay status
#define RELAY_ON 1
#define RELAY_OFF 0

// Source of state change (used when printing debug information)
#define CHANGE_STATE_SOURCE_RADIO 0
#define CHANGE_STATE_SOURCE_SWITCH 1


// Temperature sensor definitions
#ifdef USE_TEMP_SENSOR
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 8
#define CHILD_DSB_ID 13 // Id of the sensor child for temperature sensor
#define TEMPERATURE_ROUNDING 10.f   // Change value to change rounding of temperature value: 10.f for 0.1°C change, 5.f for 0.2°C change, 2.f for 0.5°C change
#endif



Bounce debouncer = Bounce();
int oldValue;
bool state;
Bounce debouncer2 = Bounce();
int oldValue2;
bool state2;

MyMessage msg(CHILD_ID, V_LIGHT);
MyMessage msg2(CHILD_ID_2, V_LIGHT);

#ifdef USE_TEMP_SENSOR
MyMessage msgTemp(CHILD_DSB_ID, V_TEMP);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature.
#endif

void presentation() {
  // Send the sketch version information to the gateway and Controller
  sendSketchInfo("Double Relay & Button", "0.2");
  // Register all sensors to gw (they will be created as child devices)
  present(CHILD_ID, S_LIGHT);
  present(CHILD_ID_2, S_LIGHT);
#ifdef USE_TEMP_SENSOR
  present(CHILD_DSB_ID, S_TEMP);
#endif
}

void setup()
{
#ifdef USE_TEMP_SENSOR
  sensors.begin();
  sensors.setWaitForConversion(false);
#endif

  // Setup the button
  pinMode(BUTTON_PIN, INPUT);
  // Activate internal pull-up
  digitalWrite(BUTTON_PIN, HIGH);

  // Setup the button
  pinMode(BUTTON_PIN_2, INPUT);
  // Activate internal pull-up
  digitalWrite(BUTTON_PIN_2, HIGH);

  // After setting up the button, setup debouncer
  debouncer.attach(BUTTON_PIN);
  debouncer.interval(5);

  debouncer2.attach(BUTTON_PIN_2);
  debouncer2.interval(5);

  // Set the initial values of oldValue/oldValue2 variables from status of physical switches
  //  if this is not done the loop() will detect status change and switch the relays on or off
  debouncer.update();
  debouncer2.update();
  oldValue = debouncer.read();
  oldValue2 = debouncer2.read();


  // Make sure relays are off when starting up
  setRelayState(RELAY_PIN, RELAY_OFF);
  // Then set relay pins in output mode
  pinMode(RELAY_PIN, OUTPUT);

  digitalWrite(RELAY_PIN_2, RELAY_OFF);
  // Then set relay pins in output mode
  pinMode(RELAY_PIN_2, OUTPUT);

  // Set relay to last known state (using eeprom storage)
  state = loadState(CHILD_ID);
  setRelayState(RELAY_PIN, state);

  state2 = loadState(CHILD_ID_2);
  setRelayState(RELAY_PIN_2, state2);
}


/*
   Example on how to asynchronously check for new messages from gw
*/
void loop()
{
#ifdef USE_TEMP_SENSOR
  static float prevTemp = 0;
#endif

  debouncer.update();
  debouncer2.update();
  // Get the update value
  int value = debouncer.read();
  int value2 = debouncer2.read();

  if (value != oldValue) {
    send(msg.set(state ? false : true), true); // Send new state and request ack back
    // Write some debug info
    printStateChangedDebug(CHANGE_STATE_SOURCE_SWITCH, CHILD_ID, value);
  }
  oldValue = value;

  if (value2 != oldValue2) {
    send(msg2.set(state2 ? false : true), true); // Send new state and request ack back
    // Write some debug info
    printStateChangedDebug(CHANGE_STATE_SOURCE_SWITCH, CHILD_ID_2, value2);
  }
  oldValue2 = value2;

  // Fetch temperatures from Dallas sensors
#ifdef USE_TEMP_SENSOR
  sensors.requestTemperatures();
  // Fetch and round temperature to one decimal
  float temperature = static_cast<float>(static_cast<int>(sensors.getTempCByIndex(0) * TEMPERATURE_ROUNDING)) / TEMPERATURE_ROUNDING;

  if (temperature != -127.00f && temperature != 85.00f && prevTemp != temperature) {
    // Send in the new temperature
    send(msgTemp.set(temperature, 1));
#ifdef MY_DEBUG
    Serial.print("Sent temperature: ");
    Serial.println(temperature);
#endif
    prevTemp = temperature;
  }
#endif
}

void receive(const MyMessage &message) {
  // We only expect one type of message from controller. But we better check anyway.
  if (message.isAck()) {
#ifdef MY_DEBUG
    Serial.println(F("This is an ack from gateway"));
#endif
  }
  else if (message.type == V_LIGHT && message.sensor == CHILD_ID) {
    // Change relay state
    state = message.getBool();
    setRelayState(RELAY_PIN, state);
    // Store state in eeprom
    saveState(CHILD_ID, state);
    // Write some debug info
    printStateChangedDebug(CHANGE_STATE_SOURCE_RADIO, CHILD_ID, state);
  }
  else if (message.type == V_LIGHT && message.sensor == CHILD_ID_2) {
    state2 = message.getBool();
    setRelayState(RELAY_PIN_2, state2);
    // Store state in eeprom
    saveState(CHILD_ID_2, state2);
    // Write some debug info
    printStateChangedDebug(CHANGE_STATE_SOURCE_RADIO, CHILD_ID_2, state2);
  }
}

// Set status of a relay pin
void setRelayState(byte relayPin, bool value) {
  digitalWrite(relayPin, value ? RELAY_ON : RELAY_OFF);
}

// Print debug info, centralized in one place to minimize memory usage and have only one #ifdef MY_DEBUG for all state change messages
void printStateChangedDebug(int source, int sensorID, bool value) {
#ifdef MY_DEBUG
  Serial.print(F("Sensor value changed, source="));
  Serial.print(source == CHANGE_STATE_SOURCE_RADIO ? F("Radio") : F("Physical switch"));
  Serial.print(F(", Sensor="));
  Serial.print(sensorID);
  Serial.print(F(", New status: "));
  Serial.println(value);
#endif
}
J'ai suivi le conseil de ganq et j'ai créé une node avec un autre arduino pro mini avec le programme ci dessus et cela fonctionne. le log du moniteur serie est bon.

Passerelle
j'ai realisé le montage avec un arduino uno ( 5V)conformément à ce qui est proposé par le site MySensors (3.3 v pour le module NRF)
https://www.mysensors.org/build/connect_radio
L'arduino uno est branché sur le port USB du raspberry B+
Pour les NRF, ce sont ceux ci
https://fr.aliexpress.com/item/Free-shi ... yId=400103

Pour la node c'est exactement pareil que toi

Node:
Type arduino : Arduino pro mini
Tension : 5VCC
Réalisation alim arduino: 230V / 5VCC par alim HLK-PM01
Ref transducteur : NRF24l01 + les même que le lien au dessus
Réalisation alim transducteur : Câblage interne par PCB
Code du node :

J'espere n'avoir rien oublié ;)
laster13
Messages : 23
Inscription : 01 nov. 2016, 19:01

Re: Double relais AC-DC ne fonctionne pas !

Message par laster13 »

A force de débrancher et rebrancher l'adaptateur usb de l'arduino pro j'ai fini par avoir un log sympa avec les nodes de declarer dans domoticz ... mais le coup d'apres cela ner fonctionne plus

Code : Tout sélectionner

Starting sensor (RNNNA-, 2.0.0)
TSM:INIT
TSM:RADIO:OK
TSP:ASSIGNID:OK (ID=1)
TSM:FPAR
TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSM:FPAR
TSP:MSG:SEND 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSP:MSG:READ 0-0-1 s=255,c=3,t=8,pt=1,l=1,sg=0:0
TSP:MSG:FPAR RES (ID=0, dist=0)
TSP:MSG:PAR OK (ID=0, dist=1)
TSM:FPAR:OK
TSM:ID
TSM:CHKID:OK (ID=1)
TSM:UPL
TSP:PING:SEND (dest=0)
TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
TSP:MSG:READ 0-0-1 s=255,c=3,t=25,pt=1,l=1,sg=0:1
TSP:MSG:PONG RECV (hops=1)
TSP:CHKUPL:OK
TSM:UPL:OK
TSM:READY
TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
TSP:MSG:SEND 1-1-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=ok:2.0.0
TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=ok:0
TSP:MSG:READ 0-0-1 s=255,c=3,t=15,pt=6,l=2,sg=0:0100
TSP:MSG:READ 0-0-1 s=255,c=3,t=6,pt=0,l=1,sg=0:M
TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=11,pt=0,l=21,sg=0,ft=0,st=ok:Double Relay & Button
TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=ok:0.2
TSP:MSG:SEND 1-1-0-0 s=11,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
TSP:MSG:SEND 1-1-0-0 s=12,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=ok:
TSP:MSG:SEND 1-1-0-0 s=13,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=ok:
Request registration...
TSP:MSG:SEND 1-1-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2
TSP:MSG:READ 0-0-1 s=255,c=3,t=27,pt=1,l=1,sg=0:1
Node registration=1
Init complete, id=1, parent=0, distance=1, registration=1
TSP:MSG:SEND 1-1-0-0 s=13,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:28.5
Sent temperature: 28.50
TSP:MSG:SEND 1-1-0-0 s=13,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:28.6
Sent temperature: 28.60
TSP:MSG:SEND 1-1-0-0 s=13,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:28.7
Sent temperature: 28.70
TSP:MSG:SEND 1-1-0-0 s=13,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:28.8
Sent temperature: 28.80
TSP:MSG:SEND 1-1-0-0 s=13,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:28.9
Sent temperature: 28.90
TSP:MSG:SEND 1-1-0-0 s=13,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=ok:29.0
Sent temperature: 29.00
Vous ne pensez pas à des soudures défaillantes?

Déroutant tout ca :cry:
tonnerre33
Messages : 8
Inscription : 15 nov. 2016, 21:46

Re: Double relais AC-DC ne fonctionne pas !

Message par tonnerre33 »

Tu n'aurais pas des mauvaises connexions avec le NRF de ta passerelle ?

Le node est à quelle distance de la passerelle quand tu fais tes essais ?
laster13
Messages : 23
Inscription : 01 nov. 2016, 19:01

Re: Double relais AC-DC ne fonctionne pas !

Message par laster13 »

J'ai longuement testé un pro mini ( comme node ) avec le même programme et cela marche systématiquement, la passerelle réagit parfaitement et le log est nickel.

Du coup je suis quasi sur que cela vient du PCB que j'ai du mal soudé. Pour rappel c'est la première fois que je me lance dans ce type d'exercice, si tu as des conseils a me donner.

J'arrive tant bien que mal a souder le fusible thermique rapidement mais j'en ai grillé quelques un. Concernant le NRF, est il également sensible à la température du fer à souder? faut il le souder rapidement lui aussi ? J'ai aussi du mal avec lui car les pins sont rapprochés et je suis gêné par les pin 7, gnd, 4.

Bon je prends tous les conseils ;) *

Merci
tonnerre33
Messages : 8
Inscription : 15 nov. 2016, 21:46

Re: Double relais AC-DC ne fonctionne pas !

Message par tonnerre33 »

Salut, pour moi le NRF n'est pas aussi sensible que le fusible thermique.

Par contre si tu n'es pas embête par l'encombrement je te conseil de faire comme j'ai fait en ajoutant des connecteurs au lieu de souder l'arduino et le NRF.
J'en ai perdu quelques un au début alors j'ai vite arrêté de les souder dans la mesure du possible ;)
Après si tu dois mettre ton node derrière un équipement tel que prise encastré ou interrupteur je comprends que tu n'en mette pas.

Bref maintenant que c'est soudé, il y a plusieurs techniques pour dessouder :
:arrow: Tu utilises un pistolet à air chaud de manière à chauffer en même temps toutes les pins
:arrow: Tu utilises de la tresse à dessouder
Répondre