Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Why MySensors isn't using interrupts for nrf24?

Why MySensors isn't using interrupts for nrf24?

Scheduled Pinned Locked Moved Development
24 Posts 7 Posters 10.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • hekH hek

    @Yveaux
    Yep, might be good to dequeue the NRF fifo as fast as possible.

    Same goes for dev-branch
    https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/core/MyTransport.cpp#L47
    Process should probably return true (when new message was available) and be "whiled" from here:
    https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/core/MySensorCore.cpp#L52

    Hmm.. don't recognize the listeningStarted flag.. As you say.. Might be some half done refactoring... Let's ping @thozza .

    YveauxY Offline
    YveauxY Offline
    Yveaux
    Mod
    wrote on last edited by
    #21

    @hek said:

    Yep, might be good to dequeue the NRF fifo as fast as possible.

    Especially for a sleeping slave (which uses the same code as a gateway).

    http://yveaux.blogspot.nl

    tekkaT 1 Reply Last reply
    0
    • YveauxY Yveaux

      @hek said:

      Yep, might be good to dequeue the NRF fifo as fast as possible.

      Especially for a sleeping slave (which uses the same code as a gateway).

      tekkaT Offline
      tekkaT Offline
      tekka
      Admin
      wrote on last edited by
      #22

      @Hek: In the dev branch, _process() is called in main(): https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/core/MyMainDefault.cpp#L12.
      As long as nodes are non-blocking and not sleeping, all queued messages are processed. However, for sleeping nodes we have to make sure the queue is processed before sending the node to sleep. The 800us delay code snippet (if correctly implemented) may help to stabilize the RF after switching to RX...

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Fabien
        wrote on last edited by
        #23

        Ok so I continue my test with the same code. And you are right the sensebender send battery level every 30mins.
        For this test, I use exactly the same hardware and same wiring (including ethernet câble for both sketch). I will post result on monday (about 24h for each sketch).
        Serial 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.
         *
         *******************************
         *
         * 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_MAX
        
        #define MY_SOFTSPI
        #define MY_SOFT_SPI_SCK_PIN 7
        #define MY_SOFT_SPI_MISO_PIN 6
        #define MY_SOFT_SPI_MOSI_PIN 5
        #define MY_RF24_CE_PIN 3
        #define MY_RF24_CS_PIN 8
        
        // Enable serial gateway
        #define MY_GATEWAY_SERIAL
        
        // 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 
        
        //#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 <MySensor.h>  
        
        void setup() { 
          // Setup locally attached sensors
        }
        
        void presentation() {
         // Present locally attached sensors 
        }
        
        void loop() { 
          // Send locally attached sensor data here 
        }
        

        And Ethernet 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.
         *
         *******************************
         *
         * 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_MAX
        
        #define MY_GATEWAY_W5100
        
        #define MY_SOFTSPI
        #define MY_SOFT_SPI_SCK_PIN 7
        #define MY_SOFT_SPI_MISO_PIN 6
        #define MY_SOFT_SPI_MOSI_PIN 5
        #define MY_RF24_CE_PIN 3
        #define MY_RF24_CS_PIN 8
        
        #define MY_IP_ADDRESS 192,168,2,200   // If this is disabled, DHCP is used to retrieve address
        // Renewal period if using DHCP
        //#define MY_IP_RENEWAL_INTERVAL 60000
        // 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.
        // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
        // Note that most of the Ardunio examples use  "DEAD BEEF FEED" for the MAC address.
        #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
        
        // Enable serial gateway
        //#define MY_GATEWAY_SERIAL
        
        // 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 
        
        //#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 <Ethernet.h>
        #include <MySensor.h>  
        
        void setup() { 
          // Setup locally attached sensors
        }
        
        void presentation() {
         // Present locally attached sensors 
        }
        
        void loop() { 
          // Send locally attached sensor data here 
        }
        
        1 Reply Last reply
        0
        • F Offline
          F Offline
          Fabien
          wrote on last edited by
          #24

          After 2 days of test. I lost few packets (5 or 6 in 24 hours and usually humidity ...). I will perform another test after changing all my ethernet câbles.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          15

          Online

          11.7k

          Users

          11.2k

          Topics

          113.1k

          Posts


          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • MySensors
          • OpenHardware.io
          • Categories
          • Recent
          • Tags
          • Popular