💬 MySensors NRF5 Platform



  • @NeverDie

    So we can not use the normal statement

    int8_t sleep(int interrupt, int mode, unsigned long ms=0);

    I did not realize that was the case as i have never tried it.


  • Hero Member

    I believe hwSleep(..) is the preferred incantation, but beyond that I'm not sure of anything. Maybe @d00616 can comment?

    I should be receiving a number of different PCB projects tomorrow for final assembly and test, and if I can't resolve this soon, I'm simply going to release them without full demo code.


  • Hardware Contributor

    @NeverDie said in 💬 MySensors NRF5 Platform:

    I believe hwSleep(..) is the preferred incantation, but beyond that I'm not sure of anything.

    In MySensors, the regular way to use sleep mode is by using the sleep() functions:
    https://www.mysensors.org/download/sensor_api_20#sleeping

    But like you said, you can also use the raw hwSleep() from the hw abstraction layer. Or you could also rewrite it!
    Which means at each abstraction layer, there are additional logics. sleep() functions have more logics (regarding MySensors states and features) than the raw hwSleep for example (like testing if there is an ongoing ota, smartsleep, heartbeat etc..). I have nodes where i use raw or not, but it's good to know what's behind.



  • @scalz
    So the statement
    int8_t sleep(int interrupt, int mode, unsigned long ms=0);
    Can be used for timer and pin interrupt at he same time on the NRF5 platform just like the arduino?


  • Hero Member

    I'll try it, but I have strong doubts that it's going to work.

    FWIW, here's the pin mapping currently being supplied by digitalPinToInterrupt(..) for the nRF5:
    Digital pin 0 = interrupt pin 0
    Digital pin 1 = interrupt pin 1
    Digital pin 2 = interrupt pin 2
    Digital pin 3 = interrupt pin 3
    Digital pin 4 = interrupt pin 4
    Digital pin 5 = interrupt pin 5
    Digital pin 6 = interrupt pin 6
    Digital pin 7 = interrupt pin 7
    Digital pin 8 = interrupt pin 8
    Digital pin 9 = interrupt pin 9
    Digital pin 10 = interrupt pin 10
    Digital pin 11 = interrupt pin 11
    Digital pin 12 = interrupt pin 12
    Digital pin 13 = interrupt pin 13
    Digital pin 14 = interrupt pin 14
    Digital pin 15 = interrupt pin 15
    Digital pin 16 = interrupt pin 16
    Digital pin 17 = interrupt pin 17
    Digital pin 18 = interrupt pin 18
    Digital pin 19 = interrupt pin 19
    Digital pin 20 = interrupt pin 20
    Digital pin 21 = interrupt pin 21
    Digital pin 22 = interrupt pin 22
    Digital pin 23 = interrupt pin 23
    Digital pin 24 = interrupt pin 24
    Digital pin 25 = interrupt pin 25
    Digital pin 26 = interrupt pin 26
    Digital pin 27 = interrupt pin 27
    Digital pin 28 = interrupt pin 28
    Digital pin 29 = interrupt pin 29
    Digital pin 30 = interrupt pin 30


  • Hero Member

    The last I heard, from @d00616 , we had to supply code such as:

        // Enable interrupt
      NVIC_SetPriority(RTC0_IRQn, 15);
      NVIC_ClearPendingIRQ(RTC0_IRQn);
      NVIC_EnableIRQ(RTC0_IRQn);
    
    

    and

    // This must be in one line
    extern "C" { void RTC0_IRQHandler(void) {rtcInterruptCounter++; NRF5_RESET_EVENT(NRF_RTC0->EVENTS_OVRFLW); NRF_RTC0->EVENTS_OVRFLW=0; }}
    

    to get interrupts to work. Even with that approach, though, I haven't gotten it to support any interrupts in addition to a timed sleeping, though I have gotten it to support one interrupt that's separate from a timed sleeping (basically, sleeps indefinitely until the interrupt happens).


  • Hero Member

    OK, I just now tried:

      sleep(3,CHANGE,3000);
    

    and, as I suspected, it does nothing but sleep for 3 seconds. It's not responsive to any changes on pin P03 on an nRF52.

    @scalz Are you getting a different result? It seems like there's a strong disconnect somewhere between what you're recommending and what I am experiencing.


  • Hardware Contributor

    @NeverDie said in 💬 MySensors NRF5 Platform:

    @scalz Are you getting a different result? It seems like there's a strong disconnect somewhere between what you're recommending and what I am experiencing.

    I didn't give any recommandation, you misread. I just said the regular way to use sleep feature in mysensors, for users, is with sleep(..). But I agree, I misread you too! when you were asking for the specific nrf52 case I guess 🙂

    That said, I got this working when I made my recessed node for door (accelerometer and hall effect sensor with sleeping). Maybe things have changed in the lib?? or not. I'm struggling between different version of the lib, and some are different from the dev branch.. I'll recheck this asap (not sure for this evening).


  • Hero Member

    I tried toying around with it a bit, and I got a useful result:

    #define MY_CORE_ONLY
    
    #include <nrf.h>
    #include <MySensors.h>
    
    
    const byte ledPin = LED_BUILTIN;
    const byte interruptPin = 3;
    volatile byte state = LOW;
    
    void blinkityBlink(uint8_t pulses, uint8_t repetitions) {
      for (int x=0;x<repetitions;x++) {
        for (int i=0;i<pulses;i++) {
          digitalWrite(LED_BUILTIN,HIGH);
          wait(20);
          digitalWrite(LED_BUILTIN,LOW);
          wait(100);
        }    
          wait(500);
      }
    }
    
    void setup() {
      hwPinMode(LED_BUILTIN,OUTPUT_D0H1);
      hwPinMode(interruptPin, INPUT);
      attachInterrupt(digitalPinToInterrupt(interruptPin), blink, RISING);
      blinkityBlink(2,1);  //signify power-on and start of main loop
    }
    
    volatile bool buttonPressed=false;
    void loop() {
      state = !state;
      digitalWrite(ledPin, state);
      sleep(digitalPinToInterrupt(interruptPin), RISING, 3000);
      wait(20);  //wait 20 milliseconds for button to debounce if it was pressed
      if (digitalRead(interruptPin)) { //if button is pressed
        blinkityBlink(2,1);
      }
      if (buttonPressed) {
        buttonPressed=false;
        blinkityBlink(20,1);
      }
    }
    
    void blink() {
      buttonPressed=true;
    }
    

    So, with this approach, pushing the button on pin 3 does wake up the nRF52 from sleep, whereupon the button press can still be detected and serviced, but it also demonstrates that the ISR per se isn't working.

    Anyhow, with this I'm able to get the PIR or leak sensor or magnet sensor or light sensor doing useful things in a timely manner, even if it isn't ideal. That puts me further ahead than I was before. 🙂



  • @NeverDie
    This is a test program that wakes up from either that i was using some time ago.

    /**
       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 - Henrik EKblad
    
       DESCRIPTION
       This sketch provides an example how to implement a distance sensor using HC-SR04
       Use this sensor to measure KWH and Watt of your house meeter
       You need to set the correct pulsefactor of your meeter (blinks per KWH).
       The sensor starts by fetching current KWH value from gateway.
       Reports both KWH and Watt back to gateway.
    
       Unfortunately millis() won't increment when the Arduino is in
       sleepmode. So we cannot make this sensor sleep if we also want
       to calculate/report watt-number.
       http://www.mysensors.org/build/pulse_power
    */
    
    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached
    //#define MY_RADIO_NRF24
    #define MY_RADIO_NRF5_ESB
    //#define MY_RADIO_RFM69
    //#define MY_RADIO_RFM95
    
    #include <MySensors.h>
    #include <Wire.h> // must be included here so that Arduino library object file references work
    #include <RtcDS3231.h>
    RtcDS3231<TwoWire> Rtc(Wire);
    
    #define DIGITAL_INPUT_SENSOR 2  // The digital input you attached your light sensor.  (Only 2 and 3 generates interrupt!)
    #define PULSE_FACTOR 1000       // Nummber of blinks per KWH of your meeter
    //#define SLEEP_MODE false        // Watt-value can only be reported when sleep mode is false.
    #define MAX_WATT 10000          // Max watt value to report. This filetrs outliers.
    #define CHILD_ID 1              // Id of the sensor child
    
    unsigned long SEND_FREQUENCY = 20000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
    double ppwh = ((double)PULSE_FACTOR) / 1000; // Pulses per watt hour
    //bool pcReceived = false;
    volatile unsigned long pulseCount = 0;
    volatile unsigned long lastBlink = 0;
    volatile unsigned long watt = 0;
    volatile unsigned long kwh = 0;
    unsigned long oldWatt = 0;
    double oldKwh;
    unsigned long lastSend;
    MyMessage wattMsg(CHILD_ID, V_WATT);
    MyMessage kwhMsg(CHILD_ID, V_KWH);
    
    
    void setup()
    {
      Serial.begin(115200);
      Rtc.Begin();
      Rtc.Enable32kHzPin(false);
      Rtc.SetSquareWavePinClockFrequency(DS3231SquareWaveClock_1Hz);
      Rtc.SetSquareWavePin(DS3231SquareWavePin_ModeClock);
    
      // Use the internal pullup to be able to hook up this sketch directly to an energy meter with S0 output
      // If no pullup is used, the reported usage will be too high because of the floating pin
      hwPinMode(DIGITAL_INPUT_SENSOR, INPUT_PULLUP);
    
      attachInterrupt(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), onPulse, FALLING);
      //pcReceived = true;
      lastSend = millis();
    }
    
    void presentation()
    {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Energy Meter", "1.0");
    
      // Register this device as power sensor
      present(CHILD_ID, S_POWER);
    }
    
    void loop()
    {
      unsigned long now = millis();
      // Only send values at a maximum frequency or woken up from sleep
      bool sendTime = now - lastSend > SEND_FREQUENCY;
      if (sendTime) {
        // New watt value has been calculated
        if (watt != oldWatt) {
          // Check that we dont get unresonable large watt value.
          // could hapen when long wraps or false interrupt triggered
          if (watt < ((unsigned long)MAX_WATT)) {
            send(wattMsg.set(watt));  // Send watt value to gw
          }
          Serial.print("Watt:");
          Serial.println(watt);
          oldWatt = watt;
        }
    
        // Pulse count has changed
        //kwh = pulseCount;
        //double kwh = ((double)pulseCount / ((double)PULSE_FACTOR));
        send(kwhMsg.set(pulseCount));  // Send kwh value to gw
        Serial.print("Wh = ");
        Serial.println(pulseCount);
        pulseCount = 0;
        lastSend = now;
      }
      sleep(SEND_FREQUENCY);
    }
    
    void receive(const MyMessage &message)
    {
    }
    
    void onPulse()
    {
      unsigned long newBlink = micros();
      unsigned long interval = newBlink - lastBlink;
      if (interval < 50000L) { // Sometimes we get interrupt on RISING
        return;
      }
      watt = (3600000000.0 / interval) / ppwh;
      lastBlink = newBlink;
      pulseCount++;
    }
    

  • Hero Member

    Well, that's interesting. In the sketch I posted, I invoked sleep with:

      sleep(digitalPinToInterrupt(interruptPin), RISING, 3000);
    

    which caused the mcu to wake up immediately after I press the button, but it didn't process the ISR.

    Using an invocation like yours in the sketch you just posted above:

      sleep(3000);
    

    the ISR executes and then terminates when I press the button, but the MCU doesn't wake and continue with the loop as it did with the prior incantation. Instead, it has to wait for the timer cycle to finish.

    What I want is for it to wake up, do the ISR, and continue with the loop where it left off until it is explicitly put back to sleep again. How do I do that?


  • Contest Winner

    @NeverDie I have checked the sleep routine in all three variants. It's working with my setup.

    There is no API stopping the sleep() by another ISR. Sleep only ends at one of the given conditions.

    When you use the MY_CORE_ONLY define, please add "hwInit();" into the setup() routine.


  • Hero Member

    @d00616 said in 💬 MySensors NRF5 Platform:

    @NeverDie I have checked the sleep routine in all three variants. It's working with my setup.

    There is no API stopping the sleep() by another ISR. Sleep only ends at one of the given conditions.

    When you use the MY_CORE_ONLY define, please add "hwInit();" into the setup() routine.

    Would you please post the three demo code examples that you tested?


  • Hero Member

    @d00616 said in 💬 MySensors NRF5 Platform:

    add "hwInit();" into the setup() routine.

    OK, I just now did that, but I'm not getting any difference in the results.


  • Hero Member

    In any case, I'm sure the question will ultimately turn from "How do I wake up based on a pin change?" to "How do I wake up based on the LPCOMP output, which has that pin as its input?" The reason: as covered earlier in this thread, much lower current consumption while sleeping if doing it via LPCOMP rather than the more straightforward pin monitoring.


  • Contest Winner

    @NeverDie said in 💬 MySensors NRF5 Platform:

    In any case, I'm sure the question will ultimately turn from "How do I wake up based on a pin change?" to "How do I wake up based on the LPCOMP output, which has that pin as its input?" The reason: as covered earlier in this thread, much lower current consumption while sleeping if doing it via LPCOMP rather than the more straightforward pin monitoring.

    It's a good question about, how to design the API to do this. I have no good idea.
    Until an API, you can set MY_HW_RTC->CC[0] to (MY_HW_RTC->COUNTER+2). This ends sleep with some latency.


  • Hero Member

    This post is deleted!

  • Hero Member

    This post is deleted!

  • Hero Member

    This post is deleted!

  • Hero Member

    Is it just me, or does the myBoardNrf5 cause I2c to fail during initialization? I have code which worked fine on mNrf5Board but which now hangs during initialization when using myBoardNrf5. 😞 Is it working for anyone else?


  • Hero Member

    @NeverDie said in 💬 MySensors NRF5 Platform:

    Is it just me, or does the myBoardNrf5 cause I2c to fail during initialization? I have code which worked fine on mNrf5Board but which now hangs during initialization when using myBoardNrf5. 😞 Is it working for anyone else?

    I've re-installed everything and am still getting no joy using I2C currently. The non-I2C stuff seems to be working fine though.
    So, before I spin more cycles trying to figure it out, is i2c working for anyone else right now using the latest builds and myBoardNrf5? Or, is I2C currently broken?


  • Hero Member

    It appears that the place where it hangs is this line here in Wire_nRF52.cpp:

      while(!_p_twim->EVENTS_LASTTX && !_p_twim->EVENTS_ERROR);
    

    This is too bad, as I2C seemed to work fine prior to around a couple weeks ago. I think maybe (?) the latest update somehow broke it.

    Please advise.


  • Hero Member

    Well, since I'm dead in the water as things stand, I moved the code over to run on an nRF52 DK. Then, usingy Sandeep's code and none of the mysensors code, I was able to get the nRF52 DK to read an attached Si7021 temperature-humidity sensor. i.e. that worked without hanging.

    So, it would appear that there's something about the mysensors code that is causing the problems. @d00616 Can we please get it fixed?


  • Contest Winner

    @NeverDie said in 💬 MySensors NRF5 Platform:

    So, it would appear that there's something about the mysensors code that is causing the problems. @d00616 Can we please get it fixed?

    I have no I2C Hardware for testing, but I take a look into the I2C and MySensors code soon.


  • Hero Member

    The sooner the better. I'm pretty much stuck until it gets fixed.



  • @neverdie
    I have been using The NRF5 with mysensors for a number of weeks with the si7021.
    So it must be just a recent problem with the mysensors code?


  • Hero Member

    @rmtucker said in 💬 MySensors NRF5 Platform:

    @neverdie
    I have been using The NRF5 with mysensors for a number of weeks with the si7021.
    So it must be just a recent problem with the mysensors code?

    I think so. Are you running the most current version? si7021 was working for me too on earlier versions. The latest update seems to have broken it. It's the one that uses myBoardNrf5 instead of myNrf5Board.


  • Hero Member

    @rmtucker said in 💬 MySensors NRF5 Platform:

    @neverdie
    I have been using The NRF5 with mysensors for a number of weeks with the si7021.
    So it must be just a recent problem with the mysensors code?

    Would you mind trying the most recent version also to see if it breaks on you too? That would at least confirm it.

    Right now my only alternative is to roll-back to the earlier version and just never upgrade again.



  • @neverdie
    Where is myBoardNrf5 so i can check?


  • Hero Member



  • @neverdie
    That explains it i am not using code from d00616.
    I am only using the mysensors library and sandeeps stuff.
    Sorry mate.


  • Hero Member

    Well, in general, it's very handy for handling the pin mappings. Up until the latest release, it has worked fine. It still works fine now, except for the I2C pin mappings.



  • @neverdie
    Hmmm at what cost?
    Maybe i will stick with what i have got as it just works.☺


  • Hero Member

    @d00616 Maybe you can just make it like it was before, where there was only one pair of I2c pins, not two as in your upgraded version? Maybe then it would work again.


  • Hardware Contributor

    @rmtucker said in 💬 MySensors NRF5 Platform:

    That explains it i am not using code from d00616.
    I am only using the mysensors library and sandeeps stuff.
    Sorry mate.

    If you're using mysensors, then you're using d00616 code 🙂 (i'm kidding)

    @NeverDie I can only confirm, it is related to the ArduinoHwNRF5 code as I have not the problem (I'm not using this part yet. I'm still using my own custom board definitions for the moment).
    This should be fixed soon (december can be a busy month..)


  • Contest Winner

    @rmtucker said in 💬 MySensors NRF5 Platform:

    Where is myBoardNrf5 so i can check?

    This is the better repository: https://github.com/mysensors/ArduinoHwNRF5

    @neverdie said in 💬 MySensors NRF5 Platform:

    @d00616 Maybe you can just make it like it was before, where there was only one pair of I2c pins, not two as in your upgraded version? Maybe then it would work again.

    Please give me some time. After an debug session with @scalz and @Yveaux, I think this is a tool chain (GCC 5.3) problem. The pin mapping array is part of the binary, but the Wire constructor gets an array with 0 while the Wire instance has pin mapping information.

    Yesterday, I had a try to port ArduinoHwNRF5 back to the same tool chain (GCC 4.8) used by Arduino Primo and SAMD boards. I think for compatibility, this is the best option.

    If I have no luck, I either remove the option of the pin remapping table or I go back to the old version. I think going back is no good idea, because the NRF52840 has more than one 32 GPIO, which requires advanced parameters.


  • Contest Winner

    @d00616 said in 💬 MySensors NRF5 Platform:
    Back from the compiler hell. There is no chance getting the GCC 4.8 to work without forking the arduino-nrf5 code. Compiling with GCC 4.8 has the same result.

    I have changed the templates a little bit and moved the code for pin mapping generation. Now it works for me. Please give me some time to clear the code and create a new package (0.3.0). With the new package, you have to add '#include <compat_pin_mapping.h>' before '#end" in MyBoardNRF5.cpp. You have to rename the '#ifdefs' and '#define' in both board files to match MYBOARDNRF5 instead of MYNRF5BOARD.


  • Contest Winner

    @d00616 said in 💬 MySensors NRF5 Platform:

    I have changed the templates a little bit and moved the code for pin mapping generation. Now it works for me. Please give me some time to clear the code and create a new package (0.3.0). With the new package, you have to add '#include <compat_pin_mapping.h>' before '#end" in MyBoardNRF5.cpp. You have to rename the '#ifdefs' and '#define' in both board files to match MYBOARDNRF5 instead of MYNRF5BOARD.

    Now, there is a new Version 0.3.0 for MyBoardNRF5 available. It can be installed via the Board Manager. Please change the templates like described above. I think, now the board definition is stable and ready to support other Arduino variants without changing the board definition.


  • Hero Member

    @d00616

    I think I made the changes you recommended, but now I'm getting:

    Board MyBoard_nRF51822 (platform nRF5, package MySensors) is unknown
    
    Error compiling for board MyBoardNRF5 nRF51822.
    

  • Contest Winner

    @neverdie said in 💬 MySensors NRF5 Platform:

    I think I made the changes you recommended, but now I'm getting:
    Board MyBoard_nRF51822 (platform nRF5, package MySensors) is unknown

    Error compiling for board MyBoardNRF5 nRF51822.

    I had the same message. In my case, I have uninstalled arduino-nrf5, cleared files, which are not removed from packages directory (the 0.2.1 MyBoard files) and reinstalled arduino-nrf5. After restarting Arduino it was fine.


  • Hero Member

    @d00616
    I'm still getting the error. I tried deleting arduino-nrf5 library and re-installing it fresh, but I don't know how, on Windows, to clear files and remove them from the packages directory. I'm not even aware of their being a "packages directory." Sorry.


  • Hero Member

    @d00616 You mentioned that it works only with a particular version of GCC. Does that mean I need to have a particular version of the Arduino IDE installed? I'm currently running the latest version of Windows Arduino IDE, which is 1.8.5.


  • Hero Member

    The irony of it all is that the earlier setup from 3 or so weeks ago seemed to work just fine. Unfortunately, I no longer have any idea how to get back to that. 😭


  • Hardware Contributor

    @NeverDie
    C:\Users...\AppData\Local\Arduino15\packages\MySensors\


  • Hero Member

    @scalz said in 💬 MySensors NRF5 Platform:

    @NeverDie
    C:\Users...\AppData\Local\Arduino15\packages\MySensors\

    Thanks!

    The good news is that it compiles now. Also, the pin mapping for an LED is working. However, the bad news is that pin mapping for Serial Rx and Tx doesn't seem to be working, so I can't read any serial debug messages. Therefore, not sure if I2C is working or not.


  • Hero Member

    I did another purge and reinsatall of the boards, and now serial is working. 🙂


  • Hero Member

    Unfortunately, it does not appear that I2C is working.


  • Hero Member

    Curiously, I2c does seem to work on a nRF52 DK using the myboard board definition.


  • Hero Member

    However, it doesn't seem to be working on the nrf51.


  • Contest Winner

    @neverdie said in 💬 MySensors NRF5 Platform:

    @d00616 You mentioned that it works only with a particular version of GCC. Does that mean I need to have a particular version of the Arduino IDE installed? I'm currently running the latest version of Windows Arduino IDE, which is 1.8.5.

    The GCC version is part of the arduino-nrf5 distribution.

    @neverdie said in 💬 MySensors NRF5 Platform:

    Unfortunately, it does not appear that I2C is working.

    I have I2C and serial running with a NRF52832.
    You can try to remove the compat_pin_mapping line and add the 0.1.0 pin map at this place. Then the board definition is nearly the 0.1.0 version.

    @neverdie said in 💬 MySensors NRF5 Platform:

    However, it doesn't seem to be working on the nrf51.

    I check the NRF51 board. What do you mean with no working?


  • Hero Member

    I hope that narrows down the likely cause of the problem. The fact that it's working on the nRF52 gives me some hope it can be made to work on the nRF51.


  • Hero Member

    @d00616 said in 💬 MySensors NRF5 Platform:

    I check the NRF51 board. What do you mean with no working?

    The nRF51 can't find the si7021 device, even though it's connected.


  • Hero Member

    @d00616 said in 💬 MySensors NRF5 Platform:

    I have I2C and serial running with a NRF52832.

    Yes, it does seem to work on the nRF52832. Just not presently on the nRF51822.


  • Hero Member

    @d00616 said in 💬 MySensors NRF5 Platform:

    I check the NRF51 board. What do you mean with no working?

    I'm running the sparkfun si7021 code. When I run it on the nrf52832, it yields:

    Si7021 Found
    Temp:70.51F, Humidity:40.71%
    

    which is correct, but when I run it on the nRF51822, the result is:

    No Devices Detected
    Temp:-51.85F, Humidity:-5.81%
    

    which is incorrect.


  • Contest Winner

    @neverdie said in 💬 MySensors NRF5 Platform:

    @d00616 said in 💬 MySensors NRF5 Platform:

    I have I2C and serial running with a NRF52832.

    Yes, it does seem to work on the nRF52832. Just not presently on the nRF51822.

    Can you check, if the device works with the "Generic NRF51822" board? You can edit the variant files in the arduino-nrf5\variants directory.
    C:\Users...\AppData\Local\Arduino15\packages\sandeepmistry\hardware\nRF5\0.4.0\variants\Generic


  • Hero Member

    @d00616 said in 💬 MySensors NRF5 Platform:

    @neverdie said in 💬 MySensors NRF5 Platform:

    @d00616 said in 💬 MySensors NRF5 Platform:

    I have I2C and serial running with a NRF52832.

    Yes, it does seem to work on the nRF52832. Just not presently on the nRF51822.

    Can you check, if the device works with the "Generic NRF51822" board? You can edit the variant files in the arduino-nrf5\variants directory.
    C:\Users...\AppData\Local\Arduino15\packages\sandeepmistry\hardware\nRF5\0.4.0\variants\Generic

    I tried, but I guess I'm not doing it right. I couldn't even get it to blink an LED that way.


  • Hero Member

    @d00616 said in 💬 MySensors NRF5 Platform:

    You can try to remove the compat_pin_mapping line and add the 0.1.0 pin map at this place. Then the board definition is nearly the 0.1.0 version.

    So, I take it you are suggesting that in myboardnrf5.cpp, where it says:

    #ifdef MYBOARDNRF5
    #include <variant.h>
    #include <compat_pin_mapping.h>
    

    I replace

    #include <compat_pin_mapping.h>
    

    with what exactly? At this point I'm not even sure where 0.1.0 pin-map is, or even what it's called.


  • Hero Member

    @neverdie said in 💬 MySensors NRF5 Platform:

    I tried, but I guess I'm not doing it right. I couldn't even get it to blink an LED that way.

    After I modify the generic variant board definition, is there some trick to making it go "live"?


  • Hardware Contributor

    @NeverDie
    there is no trick.. it should work.
    d00616 said, for a test, to not use his defines, the method that you're used to.
    So change the defines you need in the generic variant file, then in arduino:
    0_1512738526575_2017-12-08_14-02-29.jpg


  • Hero Member

    I think this must be where the disconnect is happening. Where do I find the files or directory for Generic nRF51? The closest I see is a directory called just "Generic":
    0_1512751626224_ss1.png
    That's the one I tried modifying:
    0_1512751648657_ss2.png
    and it had no effect. So, I suspect there must be a different "generic nRF51" somewhere which is closely tied with the menu item you show the picture of. However, I don't see where.


  • Hardware Contributor

    @neverdie did you check there ?
    0_1512752107091_boards_location.png


  • Hero Member

    I didn't try that one, but it's a similar dilemma:
    0_1512752927651_ss3.png
    i.e. Does "Generic" do double duty for both "Generic nRF51" and "Generic nRF52"?


  • Hero Member

    Aha! That did it. Thanks @NCA78. It's working now, including the I2C.

    I had to switch nodes though. It's possible that the mysensors code does work, as the node I was testing it on may have had a bad si7021 module on it. I'll post again after I retry with this different node.


  • Hero Member

    I'm back with the results. The same node where I2C works using the customized "Generic nRF51" does not have working I2c if using the mysensors "MyBoardnRF5 nRF51822".

    So, I think I've taken this as far as I can. Hopefully this info helps you solve whatever the problem is.

    I'm grateful I can keep moving along now using a modified "Generic nRF51822". Thanks everybody! 🙂


  • Hero Member

    Ashes on my head. The mysensors code is working with I2c after all. I confirmed it on the second (alternate) node. I had switched two of the wires in the myboardnrf5 pinout, but hadn't on the generic nRF51 pinout. Correcting for that, it now works.

    What threw me completely off was the defective si7021 module on the first node. Well, now everything is sorted. 🙂


  • Contest Winner

    @neverdie said in 💬 MySensors NRF5 Platform:

    Ashes on my head. The mysensors code is working with I2c after all. I confirmed it on the second (alternate) node. I had switched two of the wires in the myboardnrf5 pinout, but hadn't on the generic nRF51 pinout. Correcting for that, it now works.

    Thank you for reporting this. Great news to hear this.


  • Hero Member

    @d00616 said in 💬 MySensors NRF5 Platform:

    Thank you for reporting this. Great news to hear this.

    You're welcome, of course. Though it was a little bit of a wild goose chase, at least your code is now pretty well tested and proven to be "known good," so others can start using it without fear. 🙂

    With this now out of the way, please do continue your excellent work!



  • This post is deleted!

  • Mod

    @omemanti Shot in the dark: did you swap Tx/Rx by accident?



  • This post is deleted!


  • I'm not sure if I destroyed something on the board.ill try another one.. to not fill-up this forum threat I'll delete my previous posts



  • Hello, @d00616. Could you tell me which ESB library did you use to port it to arduino environment? The one that comes with Nordic SDK? After searching for few hours I haven't find any other realization of ESB mode for arduino IDE except your port included with MySensors. It's a pity. Are you going to release general purpose library, maybe?


  • Contest Winner

    @monte said in 💬 MySensors NRF5 Platform:

    Hello, @d00616. Could you tell me which ESB library did you use to port it to arduino environment? The one that comes with Nordic SDK? After searching for few hours I haven't find any other realization of ESB mode for arduino IDE except your port included with MySensors. It's a pity. Are you going to release general purpose library, maybe?

    The ESB library is written from scratch. At the time of of starting the Nordic SDK license was incompatible with open source projects. I have no plans to release this as stand-alone library. At the moment there is only an subset of the ESB protocol implemented. Enough to be compatible with MySensors RF24 devices.

    Feel free to use my code to create a stand-alone library. If required, we can talk about dual licensing to code with an additional open source license.



  • @d00616 thanks for a reply. I will evaluate my skills for this task, when I actually will get a chip to try it on. I need some really small pcb for my project, and single chip with mcu and rf with the size of nrf51 fits perfectly, but it requires quiet simple communications and full MySensors library will be overkill and hard to adapt for my needs.


  • Contest Winner

    @monte said in 💬 MySensors NRF5 Platform:

    @d00616 thanks for a reply. I will evaluate my skills for this task, when I actually will get a chip to try it on. I need some really small pcb for my project, and single chip with mcu and rf with the size of nrf51 fits perfectly, but it requires quiet simple communications and full MySensors library will be overkill and hard to adapt for my needs.

    You can use the MY_CORE_ONLY mode -> https://forum.mysensors.org/post/76627



  • @d00616 great tip, thanks! I didn't know about that option, to bad it's buried on the deepest level of documentation. I guess this will do the thing. I greatly appreciate your help, it's a pleasure when people are willing to share their knowledge with others 🙂



  • @d00616 one more question. Is your driver able to send broadcast messages, without defined address, or should I just use the same node address on multiple receiving nodes?


  • Contest Winner

    @monte Thank you.

    @monte said in 💬 MySensors NRF5 Platform:

    @d00616 one more question. Is your driver able to send broadcast messages, without defined address, or should I just use the same node address on multiple receiving nodes?

    The broad cast address is hard coded to 0xff (255). Each node must have a uniqe address, because it's not possible to send packages to a node with the same address.


  • Contest Winner

    @monte said in 💬 MySensors NRF5 Platform:

    @d00616 thanks for a reply. I will evaluate my skills for this task, when I actually will get a chip to try it on. I need some really small pcb for my project, and single chip with mcu and rf with the size of nrf51 fits perfectly, but it requires quiet simple communications and full MySensors library will be overkill and hard to adapt for my needs.

    If possible use the nRF52 series. There are some improvements like better radio sensivity, lower current consumption, more RAM and flash, better ADC and a better CPU. Maybe in the future there is a Firmware update OTA functionality which is easier to adapt to the NRF52 than the NRF51 platform. Another reason to use the NRF52 is, that the official Arduino NRF5 port only supports the NRF52. This port has a lot more capabilities than the arduino-nrf5 port, but MySensors is not compatible at the moment.


  • Hardware Contributor

    Should we worry about that ?

    0_1517109432461_primo_retired.png


  • Contest Winner

    @nca78 said in 💬 MySensors NRF5 Platform:

    Should we worry about that ?

    No. There are some ports of Arduino for NRF5. At the moment MySensors is not compatible with the Primo Port, because it comes with the SoftDevice. It changes nothing for the current state.



  • What is the best way to use a pin interrupt to wake up form a sleep?

    like for instance, I got some sort of motion connected to PIN 8.


  • Hero Member

    The source code for the PIR project gives one possible answer.



  • @neverdie
    I've been dealing with that code but for some reason, I don't get it to work, code-wise it seems I'm lacking..

    First i get this error: struct NRF_UARTE_Type' has no member named 'TASKS_SUSPEND
    And when I comment that out it seems like its not waking up.

    I made a test sketch, which reported the status every 1000ms. this worked accurately for the last 3 days so it doesn't look like it is a sensor problem.

    So my hope was that there was an easier methode available..


  • Hero Member

    @omemanti Sounds like maybe you're either missing a library or else not linking to one that's required.



  • @neverdie

    What am I missing, I just reinstalled the whole shabang.

    • Arduino IDE
    • Sandeep
    • Mysensors 2.2.0

    thats all there is installed..


  • Hero Member

    @omemanti You want the mysensors development fork.


  • Hero Member



  • @neverdie

    • removed 2.2.0 => installed 2.2.1 Alpha.
    • boards check.

    Still:

    error: 'struct NRF_UARTE_Type' has no member named 'TASKS_SUSPEND'
    
       NRF_UARTE0->TASKS_SUSPEND = 1;
    
                   ^
    
    exit status 1
    'struct NRF_UARTE_Type' has no member named 'TASKS_SUSPEND'```

  • Plugin Developer

    Let's say I've just bought a $2,50 NRF52 board.

    Does anyone know a good tutorial for absolute beginners?

    For example:

    • I have no idea what a softdevice is. Should I know?
    • I don't know what hardware I need. A normal serial adapter or an ST-link? Should I hack an STM32 into a black magic probe (whatever that is..), or is that for power users?
    • To what pins do I connect to upload a sketch?
    • How are you connecting wires onto the package? Just hotglue and very steady hands? Some cheap adapter or board? Any tips and tricks?
    • There's something about text files that define how the pins work? But the serial pins are always the same? Where does the text-file go? What flavours are there? Which is the most popular?
    • What boards should I enable in the Arduino IDE?
    • How do I debug my sketch? Does the serial monitor work?
    • Do I still need the development version of MySensors now that we are at V2.2?
    • Do I need to set anything in MySensors?
    • Are encryption, signing and the simple options to do this supported?
    • What can it do? Can I connect a 5v sensor to it? Can it power things in the way that an Arduino can?

  • Contest Winner

    @alowhum all security functionality currently available for MySensors is supported om nrf52. There is nothing in the security road map that will not be supported on nrf52. The MAY be features that work best with a security peripheral but there will always be software compatible alternatives for released features that can operate on nrf52 unless it is natively supported by the HW peripherals in the chip.


  • Hardware Contributor

    @alowhum you can start with this:
    https://forum.mysensors.org/topic/6705/mysensors-nrf5-platform/1
    and
    https://forum.mysensors.org/topic/7869/start-with-nrf5-is-very-simple/1

    But you should also check the NRF5 information on Nordic website.
    In short it's 3.3V max (so no 5V peripherals directly), you need to program through the 2 SWD pins (SWDCLK and SWDIO) and you have different options for that, for debugging use a FTDI adapter and connect it to the pins you have assigned as TX/RX.


  • Hardware Contributor

    Hello,

    has someone successfully used VisualMicro with the MySensors NRF5 boards ?
    In the board selector dropdown list I can select any board, including NRF5 boards like "Generic NRF51" or "BBC Microbit", except when I select MySensors NRF51 or NRF52 boards, then it's not doing anything and keeping the previous selected board. I have a message in the status bar saying "the first available board has been selected" and that's all, I don't find anything related to VisualMicro with this error message in Google.
    I have tried with both 0.1 and 0.3 versions of the boards, and with both "Arduino 1.6/1.9" and "Visual Micro (No IDE)" IDE selections.



  • I like VisualMicro and think I got this to work but was mostly using plain Arduino to keep things simple while figuring it out. I haven't worked on an NRF5 board for a few weeks. I will check my setup. Might be a day or two before I can get back to it.



  • @nca78
    No. I was mistaken. I have the same issue as you. I used the arduino program with the MySensors NRF5. I would like to get this to work also. Please post if you find a solution.


  • Hardware Contributor

    @nagelc thank you for taking the time to check, I'll go with Arduino for NRF5 at the moment and keep that for a moment when I'll be more keen on fixing technical problems 🙂



  • What are people using for a gateway with these?

    I'm currently using this from @NeverDie , which seems to work for the most part, but I'm getting a lot of connection errors:

    2018-04-18 18:27:35 ERROR (Thread-2) [mysensors.gateway_tcp] Receive from server failed.
    
    2018-04-18 18:27:35 INFO (Thread-2) [mysensors.gateway_tcp] Closing socket at ('10.0.50.100', 2323).
    2018-04-18 18:27:35 INFO (Thread-2) [mysensors.gateway_tcp] Socket closed at ('10.0.50.100', 2323).
    2018-04-18 18:27:35 INFO (Thread-2) [mysensors.gateway_tcp] Trying to connect to ('10.0.50.100', 2323)
    2018-04-18 18:27:35 INFO (Thread-2) [mysensors.gateway_tcp] Connected to ('10.0.50.100', 2323)
    2018-04-18 18:27:52 INFO (Thread-2) [mysensors.gateway_tcp] Closing socket at ('10.0.50.100', 2323).
    

    They seem to come up about 75% of the time when the gateway receives a message from a node.

    I thought it might be a power thing, so I messed around with a few caps and a separate power source for the hat but nothing seems to have made a difference.

    Everything seems to work despite this, but I don't really want my log to be filled with these errors if I can help it.

    Has anyone attempted to build a wired gateway or anything similar?



  • @shodney i used this one for a couple of tests. I resoldered the caps near the top and connected a new antenna. Works pretty well for testing purposes. I expect some pcb's a week ago😏 for some further testing.


  • Hero Member

    The gateway I've used has been:
    https://www.openhardware.io/view/491/PA-LNA-nRF52832-ESP-LINK-Shield-for-Wemos-D1-Mini-ESP8266
    I haven't noticed any problems.



  • @nca78 I posted to the VisualMicro forum. They responded right away. They are going to fix it in the next release. Something to do with internal naming conventions.



Suggested Topics

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts