Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. Marek Běluša
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by Marek Běluša

    • RE: Relay and Light Node

      Hi!

      Thanks for help, now it works perfect 🙂

      Posting updated code:

      /**

      • 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.

      • REVISION HISTORY
      • Version 1.0 - idefix
      • DESCRIPTION
      • Arduino BH1750FVI Light sensor
      • communicate using I2C Protocol
      • this library enable 2 slave device addresses
      • Main address 0x23
      • secondary address 0x5C
      • connect the sensor as follows :
      • VCC >>> 5V
      • Gnd >>> Gnd
      • ADDR >>> NC or GND
      • SCL >>> A5
      • SDA >>> A4
      • http://www.mysensors.org/build/light
        */

      #define MY_NODE_ID 9

      // Enable debug prints to serial monitor
      #define MY_DEBUG

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

      #define MY_RF24_PA_LEVEL RF24_PA_MAX

      #include <SPI.h>
      #include <MySensors.h>
      #include <BH1750.h>
      #include <Wire.h>

      #define CHILD_ID_LIGHT 10

      unsigned long lastTime = millis();
      #define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 1 // 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

      BH1750 lightSensor;

      // transmitting LUX light level.
      MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
      // MyMessage msg(CHILD_ID_LIGHT, V_LEVEL);
      uint16_t lastlux;

      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()

      {
      lightSensor.begin();
      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 presentation() {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Relays and Light Lux Sensor node", "1.0");

      // Register all sensors to gateway (they will be created as child devices)
      present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);

      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_LIGHT);
      }
      }

      void loop()
      {
      unsigned long currentTime = millis();
      if (currentTime > lastTime + 60000) {
      lastTime = currentTime;

      uint16_t lux = lightSensor.readLightLevel();
      Serial.println(lux);
      if (lux != lastlux)
      send(msg.set(lux));
      lastlux = lux; }

      }

      void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_LIGHT) {
      // 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());

      }
      }

      posted in Development
      Marek Běluša
      Marek Běluša
    • Relay and Light Node

      Hi, i try to combine Relay and Light node sketch. It works ok but i need put interupt or delay for light sensor reading only 1 read per minute. If i put sleep time to loop then it block comunication for realy and node repeater 😞

      I found some examples only for 1.5 v nodes .........

      Thanks for help!

      My sketch:

      /**

      • 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.

      • REVISION HISTORY
      • Version 1.0 - idefix
      • DESCRIPTION
      • Arduino BH1750FVI Light sensor
      • communicate using I2C Protocol
      • this library enable 2 slave device addresses
      • Main address 0x23
      • secondary address 0x5C
      • connect the sensor as follows :
      • VCC >>> 5V
      • Gnd >>> Gnd
      • ADDR >>> NC or GND
      • SCL >>> A5
      • SDA >>> A4
      • http://www.mysensors.org/build/light
        */

      #define MY_NODE_ID 9

      // Enable debug prints to serial monitor
      #define MY_DEBUG

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

      #define MY_RF24_PA_LEVEL RF24_PA_MAX

      #include <SPI.h>
      #include <MySensors.h>
      #include <BH1750.h>
      #include <Wire.h>

      #define CHILD_ID_LIGHT 10
      unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)

      #define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 1 // 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

      BH1750 lightSensor;

      // transmitting LUX light level.
      MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
      // MyMessage msg(CHILD_ID_LIGHT, V_LEVEL);
      uint16_t lastlux;

      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()
      {
      lightSensor.begin();
      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 presentation() {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Relays and Light Lux Sensor node", "1.0");

      // Register all sensors to gateway (they will be created as child devices)
      present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);

      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_LIGHT);
      }
      }

      void loop()
      {
      uint16_t lux = lightSensor.readLightLevel();// Get Lux value
      Serial.println(lux);
      if (lux != lastlux) {
      send(msg.set(lux));
      lastlux = lux;

      }
      }
      void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_LIGHT) {
      // 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());

      }
      }

      posted in Development
      Marek Běluša
      Marek Běluša
    • RE: [Solved] LightSensor serial LOG

      ... recommend to use 1000uF on gateway 3.3V side if you powered it from arduino

      posted in Troubleshooting
      Marek Běluša
      Marek Běluša
    • RE: [Solved] LightSensor serial LOG

      Solved! After many hours spend .... 😡

      China fake moduls on sensor side!

      http://www.ebay.com/itm/191784626751?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

      .....change for this type and works OK 🙂

      http://www.ebay.com/itm/191902452981?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

      posted in Troubleshooting
      Marek Běluša
      Marek Běluša
    • [Solved] LightSensor serial LOG

      Sketch:

      https://www.mysensors.org/build/light-bh1750

      Could you please explain what does mean TSM failure in serial LOG:

      Starting sensor (RNNNA-, 2.0.0)
      TSM:INIT
      TSM:RADIO:OK
      TSM:FPAR
      TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      TSM:FPAR
      TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      TSM:FPAR
      TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      TSM:FPAR
      TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      !TSM:FPAR:FAIL
      !TSM:FAILURE
      TSM:PDT
      TSM:INIT
      TSM:RADIO:OK

      Using Domoticz with ethernet gateway, gateway log in domoticz is OK but no sonsors available 😧

      Thanks for help!

      posted in Troubleshooting
      Marek Běluša
      Marek Běluša
    • RE: Ethernet GW W5100 can not connect to Domoticz

      Thanks, solveded, IDE 1.6.7 OK !

      posted in Domoticz
      Marek Běluša
      Marek Běluša
    • Ethernet GW W5100 can not connect to Domoticz

      Hi,

      Ethernet GW W5100 buid:

      https://www.mysensors.org/build/ethernet_gateway

      ... when i try to conect to Domoticz then this is result:

      0_1477229183176_domoticz.JPG

      Ping to 192.168.1.140 is OK

      Thanks for help!

      posted in Domoticz
      Marek Běluša
      Marek Běluša
    • RE: 💬 Building an Ethernet Gateway

      Hi, i i try compile GatewayW5100.ino on this page then result is compiler error:

      Arduino: 1.6.12 (Windows 10), Board: "Arduino Nano, ATmega328"

      In file included from C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:23:0,

                   from C:\Users\M\Documents\Arduino\libraries\MySensors-master/MySensors.h:261,
      
                   from C:\Users\M\AppData\Local\Temp\arduino_modified_sketch_502474\sketch_oct22a.ino:116:
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.h:34:31: error: 'SPI_MODE0' was not declared in this scope

      #define MY_RF24_SPI_DATA_MODE SPI_MODE0

                                 ^
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.h:38:76: note: in expansion of macro 'MY_RF24_SPI_DATA_MODE'

      SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;

                                                                              ^
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.h:38:97: error: template argument 4 is invalid

      SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;

                                                                                                   ^
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.h:38:103: error: invalid type in declaration before ';' token

      SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;

                                                                                                         ^
      

      In file included from C:\Users\M\Documents\Arduino\libraries\MySensors-master/MySensors.h:261:0,

                   from C:\Users\M\AppData\Local\Temp\arduino_modified_sketch_502474\sketch_oct22a.ino:116:
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp: In function 'uint8_t RF24_spiMultiByteTransfer(uint8_t, uint8_t*, uint8_t, bool)':

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:44:24: error: request for member 'transfer' in '_SPI', which is of non-class type 'int'

      uint8_t status = _SPI.transfer( cmd );

                          ^
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:47:18: error: request for member 'transfer' in '_SPI', which is of non-class type 'int'

      status = _SPI.transfer( NOP );
      
                    ^
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:49:24: error: request for member 'transfer' in '_SPI', which is of non-class type 'int'

      } else status = _SPI.transfer(*current++);

                          ^
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp: In function 'bool RF24_initialize()':

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:261:7: error: request for member 'begin' in '_SPI', which is of non-class type 'int'

      _SPI.begin();

         ^
      

      exit status 1
      Error compiling for board Arduino Nano.

      This report would have more information with
      "Show verbose output during compilation"
      option enabled in File -> Preferences.

      Could you please help?

      Thanks.

      posted in Announcements
      Marek Běluša
      Marek Běluša
    • Ethernet gateway compile error

      Hi, could you please help me solv this error? I try compile GatewayW5100.ino from offical site and Arduino IDE show this error:
      In file included from C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:23:0,

                   from C:\Users\M\Documents\Arduino\libraries\MySensors-master/MySensors.h:261,
      
                   from C:\Users\M\Desktop\GatewayW5100\GatewayW5100.ino:116:
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.h:34:31: error: 'SPI_MODE0' was not declared in this scope

      #define MY_RF24_SPI_DATA_MODE SPI_MODE0

                                 ^
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.h:38:76: note: in expansion of macro 'MY_RF24_SPI_DATA_MODE'

      SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;

                                                                              ^
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.h:38:97: error: template argument 4 is invalid

      SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;

                                                                                                   ^
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.h:38:103: error: invalid type in declaration before ';' token

      SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;

                                                                                                         ^
      

      In file included from C:\Users\M\Documents\Arduino\libraries\MySensors-master/MySensors.h:261:0,

                   from C:\Users\M\Desktop\GatewayW5100\GatewayW5100.ino:116:
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp: In function 'uint8_t RF24_spiMultiByteTransfer(uint8_t, uint8_t*, uint8_t, bool)':

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:44:24: error: request for member 'transfer' in '_SPI', which is of non-class type 'int'

      uint8_t status = _SPI.transfer( cmd );

                          ^
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:47:18: error: request for member 'transfer' in '_SPI', which is of non-class type 'int'

      status = _SPI.transfer( NOP );
      
                    ^
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:49:24: error: request for member 'transfer' in '_SPI', which is of non-class type 'int'

      } else status = _SPI.transfer(*current++);

                          ^
      

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp: In function 'bool RF24_initialize()':

      C:\Users\M\Documents\Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:261:7: error: request for member 'begin' in '_SPI', which is of non-class type 'int'

      _SPI.begin();

         ^
      

      exit status 1
      Nastala chyba při kompilaci u desky Arduino Nano.Thanks.

      posted in Troubleshooting
      Marek Běluša
      Marek Běluša