[SOLVED ... partially] Ethernet gateway without radio don't present local sensors to domoticz
-
@tonin I'm following this with much curiosity. My first guess was that it can't work. Because the gateway shouldn't startup, in my mind at will stop the bootup sequence because there's it can't initialize the radio. At least that's what I expected.
-
Mystery solved ....
I was using client mode gateway because in server mode my arduino mega reset every time that send an ethernet packet. In client mode as I say, domoticz connect to the arduino but there is no traffic from arduino to RPI domoticz presenting my relays. I read that client mode is buggy at this time, so I try to get server mode without the resets.
To avoid resets in my chinese arduino mega 2560 & chinese w5100 I need to downgrade de AVR library from 1.6.13 to 1.6.11. So all works Ok with my to gateways (usb & ethernet() connected to my RPI domoticz controller.
-
Hi. I have the same problem with my serialgateway. its usb conected to VERA 3
(ui7).
There are no inclusion on vera. Normally i use the software arduino gateway start button on vera to include ,and reset the sensor be detected. Now my buzzer(relay based sketch) it's on gateway.
What i do now for vera include my buzzer???? :disappointed:i even dont know if the scketch work but i need inclusion first...
**(...)** // 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> #define CHILD_ID 5 void setup() { } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("BUZZER", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID,S_DOOR); } void loop() { } void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_TRIPPED) { tone(2, 2500, 1000) ; } } -
Not worked. I think maybe i need an include button or some function that preset that sensor after gateway was already running and waiting for messages..I don't now. This new feature on gateway was one of my requests but still a mistery for me how it work :P
-
This code
// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached //Comento la siguiente linea para que no necesite radio //#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> //Para el sensor de temperatura #ifdef TEMP #include <DallasTemperature.h> #include <OneWire.h> #define ONE_WIRE_BUS 2 OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); MyMessage msg(0,V_TEMP); #endif //Structura de reles typedef struct { int pin; char desc[20]; bool ON; bool OFF; } sRELE; sRELE Rele [] = { {13 , "LED", HIGH, LOW}, {31 , "RELE ASPERSOR PORCHE", LOW, HIGH}, {33 , "RELE TURBINAS", LOW, HIGH}, {35 , "RELE GOTEROS BAJOS", LOW, HIGH} }; #define NUMBER_OF_RELAYS 4 // Total number of attached relays void setup() { // Setup locally attached sensors #ifdef TEMP //Para el sensor de temperatura sensors.begin(); #endif //Para los reles Serial.println("start call Setup"); for (int sensor=0 ; sensor<NUMBER_OF_RELAYS;sensor++) { // Poner el rele en output mode pinMode(Rele[sensor].pin, OUTPUT); // Poner el rele en el ultimo estado conocido (usando eeprom storage) digitalWrite(Rele[sensor].pin, loadState(sensor)?Rele[sensor].ON:Rele[sensor].OFF); } Serial.println("End call Setup"); presentation(); } void presentation() { // Presentar los sensores y actuadores locales Serial.println("start call presentation"); // Mandar la info del sketch sendSketchInfo("Arduino USB", "1.0"); //Presentar los reles for (int rele=0; rele<NUMBER_OF_RELAYS;rele++) { // Registrar todos los reles al gw present(rele, S_LIGHT,Rele[rele].desc); } Serial.println("End call presentation"); #ifdef TEMP //Presento el sensor de temperatura present(9,S_TEMP,"SENSOR_TEMP"); #endif } bool STATUS; void loop() { // Send locally attached sensor data here #ifdef TEMP Serial.print("Solicitando temperaturas..."); sensors.requestTemperatures(); // Send the command to get temperatures float temperatura = sensors.getTempCByIndex(0); send(msg.setSensor(9).set(temperatura,1)); Serial.println("DONE"); sleep(2000); #endif } void receive(const MyMessage &message) { // Solo esperamos mensajes V_LIGTH de momento, pero lo chequeamos por si acaso. if (message.type==V_LIGHT) { // Cambiar estado del rele digitalWrite(Rele[message.sensor].pin, message.getBool()?Rele[message.sensor].ON:Rele[message.sensor].OFF); // Almacenar estado en la eeprom saveState(message.sensor, message.getBool()); // Escribir informacion de debug Serial.print("Cambio entrante para sensor:"); Serial.print(message.sensor); Serial.print(", Nuevo status: "); Serial.println(message.getBool()); } }works ok for me. As you can see I define the relays in an structure to do it configurable. The only trick for me is to call the presentation function in the setup function. In the ethernet gateway it isn't needed.
A note for the structure sRELE. yo can see the pin, description and the state of the pin that mean ON or OFF. It's so because my relay boards have an inverse logic. When the pin is in low state, the relay is on. This relay boards are opto coupled and have an isolated circuit between arduino pins and relays, this is the reason for that.
The sample code also have some lines to read temperature from a dallas sensor.
I hope that this help you.
-
hi. i just add presentation function on setup but still the same. No sign of the sensor on vera. maybe yor sketch its sending back another call in some other line ... i can't make it work.
changes:
void setup() { presentation(); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("BUZZER", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID,S_DOOR); } void loop() { } void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_TRIPPED ) { tone(2, 2500, 1000) ; // 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()); } }