Domoticz(Raspberry) with Mysensor USB gateway without Radio
-
Hello,
I try to create USB gateway without radio, but my domoticz under raspberry don't see this gateway.
Could you check my code?
Thanks// 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 // 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 // Set blinking period #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Inverses the behavior of leds //#define MY_WITH_LEDS_BLINKING_INVERSE // Flash leds on rx/tx/err // 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 <MySensors.h> #include <SPI.h> #define CHILD_ID 1 // Id of the sensor child #define IN_Sejour_Presence1 2 // Arduino Digital I/O pin number for Presence #define IN_Sejour_Presence2 3 // Arduino Digital I/O pin number for Presence #define IN_Sejour_Presence3 4 // Arduino Digital I/O pin number for Presence #define IN_ChParents_Presence 5 // Arduino Digital I/O pin number for Presence #define NUMBER_OF_INPUT 4 // Total number of attached input port #define RELAY_Sejour_Volet1_Bas 22 // Arduino Digital I/O pin number for relay #define RELAY_Sejour_Volet1_Stop 23 // Arduino Digital I/O pin number for relay #define RELAY_Sejour_Volet1_Haut 24 // Arduino Digital I/O pin number for relay #define RELAY_Sejour_Volet2_Bas 25 // Arduino Digital I/O pin number for relay #define RELAY_Sejour_Volet2_Stop 26 // Arduino Digital I/O pin number for relay #define RELAY_Sejour_Volet2_Haut 27 // Arduino Digital I/O pin number for relay #define RELAY_Sejour_Volet3_Bas 28 // Arduino Digital I/O pin number for relay #define RELAY_Sejour_Volet3_Stop 29 // Arduino Digital I/O pin number for relay #define RELAY_Sejour_Volet3_Haut 30 // Arduino Digital I/O pin number for relay #define RELAY_Sejour_Lumiere1 31 // Arduino Digital I/O pin number for relay #define RELAY_Sejour_Lumiere2 32 // Arduino Digital I/O pin number for relay #define RELAY_Sejour_Lumiere3 33 // Arduino Digital I/O pin number for relay #define RELAY_Sejour_Chauffage1 34 // Arduino Digital I/O pin number for relay #define RELAY_Sejour_Chauffage2 35 // Arduino Digital I/O pin number for relay #define RELAY_SdJ_Volet1_Bas 37 // Arduino Digital I/O pin number for relay #define RELAY_SdJ_Volet1_Stop 38 // Arduino Digital I/O pin number for relay #define RELAY_SdJ_Volet1_Haut 39 // Arduino Digital I/O pin number for relay #define RELAY_ChParents_Volet_Bas 41 // Arduino Digital I/O pin number for relay #define RELAY_ChParents_Volet_Stop 42 // Arduino Digital I/O pin number for relay #define RELAY_ChParents_Volet_Haut 43 // Arduino Digital I/O pin number for relay #define RELAY_ChParents_Lumiere 44 // Arduino Digital I/O pin number for relay #define RELAY_ChParents_Chauffage 45 // Arduino Digital I/O pin number for relay #define NUMBER_OF_RELAYS 32 // Total number of attached relays port 22 to 53 #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 unsigned long Duree_Sejour_Lum1 = 60000; unsigned long Duree_Sejour_Lum2 = 60000; unsigned long Duree_Sejour_Lum3 = 60000; unsigned long Duree_ChParents_Lum = 60000; unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds) bool IN_Sejour_Presence1_Etat = LOW; bool IN_Sejour_Presence1_Etat_Avant = LOW; bool IN_Sejour_Presence2_Etat = LOW; bool IN_Sejour_Presence2_Etat_Avant = LOW; bool IN_Sejour_Presence3_Etat = LOW; bool IN_Sejour_Presence3_Etat_Avant = LOW; bool IN_ChParents_Presence_Etat = LOW; bool IN_ChParents_Presence_Etat_Avant = LOW; // Initialize motion message MyMessage msg(CHILD_ID, V_TRIPPED); void before() { // Send the sketch version information to the gateway and Controller // sendSketchInfo("MySensorBas", "1.0"); for (int sensor=RELAY_Sejour_Volet1_Bas, pin=RELAY_Sejour_Volet1_Bas; 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); } pinMode(IN_Sejour_Presence1, INPUT); pinMode(IN_Sejour_Presence2, INPUT); pinMode(IN_Sejour_Presence3, INPUT); pinMode(IN_ChParents_Presence, INPUT); } void setup() { } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Salon_Parents_SdJ", "1.0"); for (int sensor=RELAY_Sejour_Volet1_Bas, pin=RELAY_Sejour_Volet1_Bas; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_BINARY); } for (int sensor=IN_Sejour_Presence1, pin=IN_Sejour_Presence1; sensor<=NUMBER_OF_INPUT; sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_MOTION); } } void loop() { // Read digital motion value IN_Sejour_Presence1_Etat = digitalRead(IN_Sejour_Presence1); if (IN_Sejour_Presence1_Etat != IN_Sejour_Presence1_Etat_Avant){ if (IN_Sejour_Presence1_Etat == HIGH){ // Serial.println(IN_Sejour_Presence1_Etat); send(msg.set(IN_Sejour_Presence1_Etat?"1":"0")); // Send tripped value to gw } IN_Sejour_Presence1_Etat_Avant = IN_Sejour_Presence1_Etat; } // Read digital motion value IN_Sejour_Presence2_Etat = digitalRead(IN_Sejour_Presence2); if (IN_Sejour_Presence2_Etat != IN_Sejour_Presence2_Etat_Avant){ if (IN_Sejour_Presence2_Etat == HIGH){ // Serial.println(IN_Sejour_Presence2_Etat); send(msg.set(IN_Sejour_Presence2_Etat?"1":"0")); // Send tripped value to gw } IN_Sejour_Presence2_Etat_Avant = IN_Sejour_Presence2_Etat; } // Read digital motion value IN_Sejour_Presence3_Etat = digitalRead(IN_Sejour_Presence3); if (IN_Sejour_Presence3_Etat != IN_Sejour_Presence3_Etat_Avant){ if (IN_Sejour_Presence3_Etat == HIGH){ // Serial.println(IN_Sejour_Presence3_Etat); send(msg.set(IN_Sejour_Presence3_Etat?"1":"0")); // Send tripped value to gw } IN_Sejour_Presence3_Etat_Avant = IN_Sejour_Presence3_Etat; } // Read digital motion value IN_ChParents_Presence_Etat = digitalRead(IN_ChParents_Presence); if (IN_ChParents_Presence_Etat != IN_ChParents_Presence_Etat_Avant){ if (IN_ChParents_Presence_Etat == HIGH){ // Serial.println(IN_ChParents_Presence_Etat); send(msg.set(IN_ChParents_Presence_Etat?"1":"0")); // Send tripped value to gw } IN_ChParents_Presence_Etat_Avant = IN_ChParents_Presence_Etat; } } 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_Sejour_Volet1_Bas, 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()); } } -
Yes, I Have:
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1
0;255;3;0;9;MCO:BGN:BFR
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSF:WUR:MS=0
0;255;3;0;9;!TSM:INIT:TSP FAIL
0;255;3;0;9;TSM:FAIL:CNT=1
0;255;3;0;9;TSM:FAIL:PDT.But I don't know why I have on first error :Transport device initialization failed
-
When I put serial gateway code availiable on MySensor Site, I have the same error.
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSF:WUR:MS=0
0;255;3;0;9;!TSM:INIT:TSP FAIL
0;255;3;0;9;TSM:FAIL:CNT=1
0;255;3;0;9;TSM:FAIL:PDTI try to do MySensor USB gateway without radio for physical IO on Arduino(to have relay)
-
Ok, I find.
Sketchinfo was in Presntation, and should be in setup.
void setup() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Salon_Parents_SdJ", "1.0"); for (int sensor=RELAY_Sejour_Volet1_Bas, pin=RELAY_Sejour_Volet1_Bas; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_BINARY); } for (int sensor=IN_Sejour_Presence1, pin=IN_Sejour_Presence1; sensor<=NUMBER_OF_INPUT; sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_MOTION); } }```
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login