Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. DanieleF
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by DanieleF

    • RE: Ethernet gateway and receive function

      This is the full code, in my previous message I tried simplifing it and I missed a variable declaration:

      #define MY_DEBUG
      //#define MY_DEBUG_DETAIL
      
      #define MY_GATEWAY_W5100
      
      #define MY_RF24_CS_PIN 3
      #define MY_RF24_IRQ_PIN 2
      #define MY_RX_MESSAGE_BUFFER_FEATURE 6
      
      #define MY_IP_ADDRESS 192,168,1,20
      #define MY_IP_GATEWAY_ADDRESS 192,168,1,1
      #define MY_IP_SUBNET_ADDRESS 255,255,255,0
      #define MY_PORT 5003
      #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
      
      #if defined(MY_USE_UDP)
      #include <EthernetUdp.h>
      #endif
      #include <Ethernet.h>
      
      #define CHILD_ID_LIGHT 1
      
      #include <MyRF24_P2_GW.h>
      #include <MySensors.h>
      
      MyMessage msgLIGHT(CHILD_ID_LIGHT, V_STATUS);
      
      
      #define BUTTON_UP A4
      #define BUTTON_DW A5
      
      #include <Bounce2.h>
      Bounce debounceUp = Bounce(); 
      Bounce debounceDw = Bounce();
      
      bool statoLuci = 1;
      const byte numReed = 4;
      const byte pinReed[numReed] = {A0,A1,A2,A3};
      const byte pinRelay[numReed] = {5,6,7,8};
      bool statoReed[numReed];
      
      
      
      void setup()
      {
      
      //  request(CHILD_ID_LIGHT, V_STATUS);
      
        debounceUp.attach(BUTTON_UP, INPUT_PULLUP);
        debounceUp.interval(5);
        debounceDw.attach(BUTTON_DW, INPUT_PULLUP);
        debounceDw.interval(5);
      
        for (int i=0; i<numReed; i++){
          pinMode(pinReed[i], INPUT_PULLUP);
          statoReed[i] = 0;
          pinMode(pinRelay[i], OUTPUT);
        }
      
      }
      
      void presentation()
      {
      
        present(CHILD_ID_LIGHT, S_BINARY, "P2 Luci Armadio");
      
      }
      
      void loop() {
      
        debounceUp.update();
        debounceDw.update();
        
        if ( debounceUp.fell() ) {
          Serial.println("UP");
        }
        if ( debounceDw.fell() ) {
          Serial.println("DOWN");
        }
        
      
        for (int i=0; i<numReed; i++){
          if (statoLuci){
            statoReed[i] = digitalRead(pinReed[i]);
            digitalWrite(pinRelay[i], statoReed[i]);
          }
          else
            digitalWrite(pinRelay[i], 0);
      
          #ifdef MY_DEBUG_DETAIL
          Serial.print("Reed ");
          Serial.print(i);
          Serial.print(" : ");
          Serial.println(statoReed[i]);
          #endif
        }
      
        #ifdef MY_DEBUG_DETAIL
        Serial.println("****************");
        wait(1000);
        #endif
        
      }
      
      /*
      void receive(const MyMessage &message)
      {
      
        if (message.destination == 0 && message.type == V_STATUS && message.sensor == CHILD_ID_LIGHT && !message.isAck()) {
          #ifdef MY_DEBUG
          Serial.println("*** Receiving ***");
          #endif
          statoLuci = message.getBool();
        }
      
      }
      */
      

      MyRF24_2_GW.h contains simply some common defines I use for all the nodes connected to this GW:

      #define MY_RADIO_NRF24
      #define MY_RF24_DATARATE   RF24_250KBPS
      #define MY_RF24_CHANNEL 115
      
      #ifndef MY_RF24_PA_LEVEL
      #define MY_RF24_PA_LEVEL   RF24_PA_HIGH
      #endif
      
      #ifndef MY_PARENT_NODE_ID
      #define MY_PARENT_NODE_ID 0
      #define MY_PARENT_NODE_IS_STATIC
      #endif
      
      posted in Troubleshooting
      DanieleF
      DanieleF
    • RE: Ethernet gateway and receive function

      Sorry for the late response, I've been away for a few days.
      The debug output looks very odd to me:

      4850944 MCO:BGN-Q-,REL=255,VER=2.3.1
      4850945 5,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 5,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850944 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MDO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 MCO:BGN:INIT GW,CP=RNNGA-Q-,REL=255,VER=2.3.1
      4850945 ```
      posted in Troubleshooting
      DanieleF
      DanieleF
    • RE: Ethernet gateway and receive function

      The code is really basic, taken from the ethernet gw template simply adding the receive function:

      
      #define MY_DEBUG
      
      #define MY_GATEWAY_W5100
      
      #define MY_RF24_CS_PIN 3
      #define MY_RF24_IRQ_PIN 2
      #define MY_RX_MESSAGE_BUFFER_FEATURE 6
      
      #define MY_IP_ADDRESS 192,168,1,20
      #define MY_IP_GATEWAY_ADDRESS 192,168,1,1
      #define MY_IP_SUBNET_ADDRESS 255,255,255,0
      #define MY_PORT 5003
      #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
      
      #if defined(MY_USE_UDP)
      #include <EthernetUdp.h>
      #endif
      #include <Ethernet.h>
      
      #define CHILD_ID_LIGHT 1
      
      #include <MyRF24_P2_GW.h>
      #include <MySensors.h>
      
      
      
      
      void setup()
      {
      
      }
      
      void presentation()
      {
      
        present(CHILD_ID_LIGHT, S_BINARY, "P2 Luci Armadio");
      
      }
      
      void loop() {
      
        
      }
      
      void receive(const MyMessage &message)
      {
      
        if (message.type == V_STATUS && message.sensor == CHILD_ID_LIGHT && !message.isAck()) {
          #ifdef MY_DEBUG
          Serial.println("*** Receiving ***");
          #endif
          statoLuci = message.getBool();
        }
      
      }
      
      posted in Troubleshooting
      DanieleF
      DanieleF
    • Ethernet gateway and receive function

      I have an ethernet gw based on Arduino Uno + W5100, working as expected.
      I tried to add an actuator (a simple relay), thus I added the usual "receive" function to the script, but at this point the ethernet stopped sending messages to others nodes.

      I tried filtering the destination, sensors type etc. but it still doesn't work.
      I suppose I should "forward" the messages manually in my receive function, correct?
      Does someone have a working example?

      Thanks
      Daniele

      posted in Troubleshooting
      DanieleF
      DanieleF
    • RE: NRF24 transport status not initialized

      @tekka my setup is quite simple:

      
      void setup() {
      
        wdt_disable();
      
        pinMode(RAIN_D_PIN, INPUT_PULLUP);
      //  pinMode(REED_PIN, INPUT_PULLUP);
      
        pinMode(VELUX_UP_PIN, OUTPUT);
        pinMode(VELUX_DOWN_PIN, OUTPUT);
      
        digitalWrite(VELUX_UP_PIN, RELAY_OFF);
        digitalWrite(VELUX_DOWN_PIN, RELAY_OFF);
      
        sensors.begin();
        if (!sensors.getAddress(ds18Addr, 0)) 
          Serial.println("************** Unable to find address for Device 0"); 
      
        sensors.setResolution(ds18Addr, 11);
      
        wdt_enable(WDTO_8S);
      
      }
      

      the only driver I use is the one from DallasTemperature library, which I used also in other nodes without any issue.
      This evening I'll try removong it to see if it has any effect.

      Regarding radio issues, this node goes completely offline from that message on: it neither sends nor receive any message.

      posted in Troubleshooting
      DanieleF
      DanieleF
    • NRF24 transport status not initialized

      Hi, I prepared a new node with Arduino Nano (clone) and NRF24.
      Everything seems to work, the node connects to the network and sends the presentation info, but then I receive this in the serial log:

      MCO:BGN:INIT OK,TSP=0
      

      which using the parser translates into:

      Core initialized, transport status 0, (1=initialized, 0=not initialized, NA=not available)
      

      I never had this kind of error with my other node, could someone point me to the meaning of this message (how can it be "not initialized" if it successfully sent the all the presentation messages?) or to the possible cause?
      This is the complete log:

      2093 TSF:MSG:SEND,21-21-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=1,st=OK:1
      2103 TSF:MSG:READ,0-0-21,s=255,c=3,t=25,pt=1,l=1,sg=0:1
      2108 TSF:MSG:PONG RECV,HP=1
      2111 TSM:UPL:OK
      2112 TSM:READY:ID=21,PAR=0,DIS=1
      2117 TSF:MSG:SEND,21-21-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
      2124 TSF:MSG:READ,0-0-21,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
      2131 TSF:MSG:SEND,21-21-0-0,s=255,c=0,t=18,pt=0,l=5,sg=0,ft=0,st=OK:2.3.1
      2140 TSF:MSG:SEND,21-21-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
      2338 TSF:MSG:READ,0-0-21,s=255,c=3,t=6,pt=0,l=1,sg=0:M
      2343 TSF:MSG:ACK REQ
      2347 TSF:MSG:SEND,21-21-0-0,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=OK:M
      2356 TSF:MSG:SEND,21-21-0-0,s=255,c=3,t=11,pt=0,l=20,sg=0,ft=0,st=OK:P2 - Velux Cameretta
      2366 TSF:MSG:SEND,21-21-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
      2374 TSF:MSG:SEND,21-21-0-0,s=1,c=0,t=10,pt=0,l=10,sg=0,ft=0,st=OK:P2 Pioggia
      2384 TSF:MSG:SEND,21-21-0-0,s=2,c=0,t=6,pt=0,l=21,sg=0,ft=0,st=OK:OUT Temperatura tetto
      2395 TSF:MSG:SEND,21-21-0-0,s=3,c=0,t=5,pt=0,l=18,sg=0,ft=0,st=OK:P2 Velux Cameretta
      2405 TSF:MSG:SEND,21-21-0-0,s=4,c=0,t=3,pt=0,l=15,sg=0,ft=0,st=OK:P2 Velux Status
      2412 MCO:REG:REQ
      2415 TSF:MSG:SEND,21-21-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
      2422 TSF:MSG:READ,0-0-21,s=255,c=3,t=27,pt=1,l=1,sg=0:1
      2427 MCO:PIM:NODE REG=1
      2429 MCO:BGN:STP
      2436 MCO:BGN:INIT OK,TSP=0
      2441 TSF:MSG:SEND,21-21-0-0,s=1,c=1,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
      

      I tried changing the NRF24 with another one which works on another node, I tried changing the IRQ pin, or disabling the IRQ, but still the same errors.

      Thanks
      Daniele

      posted in Troubleshooting
      DanieleF
      DanieleF
    • RE: Receive queued mensajes after sleep

      I never used openhab, but your description makes me think about the way your sensor sleeps.
      Are you using sleep or smart sleep?
      If you want to achieve what you described you should use the second one, which informs the controller that the node is awake.

      posted in Development
      DanieleF
      DanieleF
    • RE: Node stops receiving after some time when using MY_RX_MESSAGE_BUFFER_FEATURE

      It works like a charm!
      Thank you for the suggestion, maybe it could be useful to add to the guide on building the ethernet gateway.

      posted in Troubleshooting
      DanieleF
      DanieleF
    • RE: Node stops receiving after some time when using MY_RX_MESSAGE_BUFFER_FEATURE

      An example would be great!
      Thank you very much

      posted in Troubleshooting
      DanieleF
      DanieleF
    • RE: Node stops receiving after some time when using MY_RX_MESSAGE_BUFFER_FEATURE

      @yveaux said in Node stops receiving after some time when using MY_RX_MESSAGE_BUFFER_FEATURE:

      @mathea90 I've used it for over 2 years now on my ethernet gateway and it never failed me.

      Sorry for bringing back an old post, but I tried to enable the messagge buffer on my ethernet gw and I failed due to this error:

      #error RF24 IRQ usage cannot be used with Soft SPI

      My setup is Arduino Uno + W5100 Ethernet Shield + NRF24.
      I'm using soft SPI as explained in the ethernet gw page.

      How did you overcome this problem?
      Thanks
      Daniele

      posted in Troubleshooting
      DanieleF
      DanieleF
    • RE: Log parser error

      It works perfectly now!
      Thanks
      Daniele

      posted in Troubleshooting
      DanieleF
      DanieleF
    • Log parser error

      It's some day that I cannot use the log parser.
      When I open the page, I receive this error message:
      0_1554033560399_44ff6afe-89a0-4bd6-a0fe-4cf411a61d53-image.png
      Is anybody else having the same issue?

      posted in Troubleshooting
      DanieleF
      DanieleF
    • RE: Recompiling for different channels

      Sorry, my mystake!!!
      Pro mini!

      posted in Development
      DanieleF
      DanieleF
    • RE: Recompiling for different channels

      I'm using the definitions from board.txt available in the repo, simply changing the hex file in the folder where the IDE searches the bootloaders.

      posted in Development
      DanieleF
      DanieleF
    • RE: Recompiling for different channels

      The option I found is here.
      When I run make, only one hex file is generated, so I assumed I have to change it in order to configure che frequency of my arduino.

      BTW, I don't understand your reference to MySensors version: I'm compiling a C program, not ann Arduino sketch (and I haven't seen a place to give the path to MySensors library).

      posted in Development
      DanieleF
      DanieleF
    • RE: Recompiling for different channels

      @rejoe2 I tried this, and I also changed the frequency in the makefile (CLK = ... at line 8), but when I flash this bootloader, the arduino hangs and I'm not able to upload any sketch.

      I'm using a micro 3.3V 8MHz and MYSBootloader DEV branch.

      posted in Development
      DanieleF
      DanieleF
    • Recompiling for different channels

      Could someone help me understading how to recmpile MYSBootloader for a different channel?
      I searched around but I haven't found a guide or anything similar.
      I'm not very familiar with gcc and it's configurations...
      I could work both on a Windows or Linux box, I guess the second could be easier to set up.
      Daniele

      posted in Development
      DanieleF
      DanieleF
    • RE: ENC28J60 Gateway - no ping

      I connected a brand new nano, the ethernet leds are powered when I connect a cable, but the log result is always the same.
      Should I deduct that my shield is defective?

      posted in Hardware
      DanieleF
      DanieleF
    • RE: ENC28J60 Gateway - no ping

      I really think you're right at this point.
      I don't have another arduino to do a test, I'll try in the next few days.
      Thanks

      posted in Hardware
      DanieleF
      DanieleF
    • RE: ENC28J60 Gateway - no ping

      @hard-shovel said in ENC28J60 Gateway - no ping:

      ENC28J60

      I tried conneting +5V, GND, then 10-10, 11-11, 12-12, 13-13, RST-RST, but with the same result.
      The odd thing is that I cannot see any led turning on on the shield (neither using it as a shield, neither with external connections).

      posted in Hardware
      DanieleF
      DanieleF
    • ENC28J60 Gateway - no ping

      I'm trying to create a simple ethernet gateway with an arduino nano (chinese clone) and a ENC28J60 shield like this.
      I'm not able to get this ethernet shield working: I used the ENC28J60 GW example from MySensors library (changing IP and MAC address), downloading UIPEthernet from here, tried commenting everything except the basic ethernet configuration, but the shield never acquires the IP.

      This is the sketch I'm using (completely unuseful, just for testing the ethernet interface):

      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      //#define MY_DEBUG_VERBOSE_GATEWAY
      
      // Enable and select radio type attached
      //#define MY_RADIO_NRF24
      //#define MY_RF24_PA_LEVEL   RF24_PA_MIN
      //#define MY_RF24_DATARATE   RF24_250KBPS
      //#define MY_RF24_CHANNEL 120
      
      // When ENC28J60 is connected we have to move CE/CSN pins for NRF radio
      //#define MY_RF24_CE_PIN 5
      //#define MY_RF24_CS_PIN 6
      
      // When ENC28J60 is connected, move SCK, MI and MO pins and enable SPI
      //#define MY_SOFTSPI
      //#define MY_SOFT_SPI_SCK_PIN 7
      //#define MY_SOFT_SPI_MISO_PIN 8
      //#define MY_SOFT_SPI_MOSI_PIN 9
      
      // Enable gateway ethernet module type 
      #define MY_GATEWAY_ENC28J60
      
      // Gateway IP address
      #define MY_IP_ADDRESS 192,168,1,22  
      
      // If using static ip you can define Gateway and Subnet address as well
      //#define MY_IP_GATEWAY_ADDRESS 192,168,1,1
      //#define MY_IP_SUBNET_ADDRESS 255,255,255,0
      
      // The port to keep open on node server mode / or port to contact in client mode
      #define MY_PORT 5003
      
      // Controller ip address. Enables client mode (default is "server" mode). 
      // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. 
      //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254   
      
      // The MAC address can be anything you want but should be unique on your network.
      #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEF
      
      
      #include <SPI.h>
      #include <UIPEthernet.h>
      #include <MySensors.h>
      
      
      void setup()
      {
      }
      
      void loop() 
      {
      }
      

      and this is the only output I can get in the serial monitor:

      0 MCO:BGN:INIT GW,CP=R-NGA---,VER=2.3.0
      

      and clearly I cannot ping the address I set up.
      I know that W5100 is much better (I have 2 of them, and they work like a charm), but I need an ethernet gw for testing purpose and right now I have only 2 ENC28J60 in my pocket...

      Do you have any suggestion?
      How can I debug the sketch to understand where it's blocking?

      posted in Hardware
      DanieleF
      DanieleF
    • Node randomly disconnecting

      Hi there,

      I have 4 nodes built with Arduino nano (Chinese clone), connected to an ethernet gateway thru NRF24. The gateway has an NRF24+ antenna, the others are a cheap version with a printed antenna on the board. All the nodes are powered from USB, with the same model of adapter.
      NRF24 boards are all powered from 5V pin with a voltage regulator.

      The all work perfectly, except for one that randomly disconnects from time to time (sometimes after one day, other times after more than one week). This node is the only one acting as an actuator; in an earlier version it was also controlling a PIR sensor, but trying to understand if the PIR continuos check was causing the issue, I moved away the PIR and now it's only controlling a relay.

      If I turn it off and on, it suddenly works perfectly. The same if I connect it to my laptop to look at the serial monitor.

      Do you have any suggestion on how to debug this kind of behavior?
      I'm quite new to Arduino and mysensors...

      Thanks
      Daniele

      posted in Troubleshooting
      DanieleF
      DanieleF