nRF5 action!


  • Hero Member

    Maybe nobody uses MY_PASSIVE_NODE? I just did a search of the forum, and nobody but me ever mentions it.


  • Hardware Contributor

    @NeverDie I don't think many people know about it, I didn't know this define existed. But sounds like a good mode for things like temperature sensors with tiny batteries, so thank you for pointing it out.



  • At the moment i am range testing.
    I have the nrf51822 sending v_status true then false every second.
    The esp8266 gateway recieves it and sends it back to the nrf8122 which turns an led on and off accordingly.
    I have the nrf8122 running from a usb powerbank so i can walk around my house.
    There are a few deadspots around the house with the unamplified nrf24l01 on the gateway.
    I tried my nrf24l01 pa lna sma but it seemed to be only working every now and again so waiting on a new one being delivered.


  • Hero Member

    @rmtucker said in nRF5 Bluetooth action!:

    I tried my nrf24l01 pa lna sma but it seemed to be only working every now and again so waiting on a new one being delivered.

    According to hackaday, there's a certain very common model which doesn't perform well unless you wrap it first in saran wrap (as an electrical insulator) and then in aluminum foil (except for the antenna, obviously).


  • Hero Member

    @Nca78 said in nRF5 Bluetooth action!:

    sounds like a good mode for things like temperature sensors with tiny batteries

    Exactly. If you're updating every 5 minutes (which is typical) or less, then it doesn't matter too much if you occasionally lose a packet, because there will be another one coming along in just a few minutes. So, if you can greatly increase your battery life as recompense, most people would

    I'm shocked it's not more prevalent here on the mysensors forum.


  • Mod

    @NeverDie I guess people are happy with 10 years of battery life. I am, so I haven't seen a need for increasing it further.


  • Hero Member

    @mfalkvidd said in nRF5 Bluetooth action!:

    @NeverDie I guess people are happy with 10 years of battery life. I am, so I haven't seen a need for increasing it further.

    Fair enough. How about smaller then? The battery may be the single biggest component. You could trade-off longer battery life for a smaller size.mote i.e. If it's a more energy efficient mote, it can use a smaller battery (or a smaller solar panel and a smaller supercap).



  • @d00616 said in nRF5 Bluetooth action!:

    I have checked the current with my nRF52 board with integrated shunt. I have measured 6.5ยตA while sleeping until timeout or sleeping until interrupt. It doesn't matter if RX/TX are connected but after flashing the firmware a reset by removing the voltage is required.

    Does the onboard regulator on this board not draw any current when not being used?
    ie when feeding the board with 3.3v and bypassing the regulator?


  • Hero Member

    I should be receiving my nRF51 modules a few days from now. Since they lack a 32K oscillator on the module, which "board" should I program it as?

    https://www.aliexpress.com/store/product/NRF51822-04-BLE4-0-Wireless-Bluetooth-Module-TTL-Low-Power-Consumption-3-3V-New/2174074_32821044213.html?spm=2114.12010612.0.0.5bdadf47Dp5sL1


  • Contest Winner

    @NeverDie said in nRF5 Bluetooth action!:

    I should be receiving my nRF51 modules a few days from now. Since they lack a 32K oscillator on the module, which "board" should I program it as?

    With the Generic nRF51822 or the MySensors nRF5 boards, you can switch the oscillator via the tools menu. You have to choose the RC oscillator.


  • Hero Member

    @d00616 said in nRF5 Bluetooth action!:

    @NeverDie said in nRF5 Bluetooth action!:

    I should be receiving my nRF51 modules a few days from now. Since they lack a 32K oscillator on the module, which "board" should I program it as?

    With the Generic nRF51822 or the MySensors nRF5 boards, you can switch the oscillator via the tools menu. You have to choose the RC oscillator.

    If I were to choose RC oscillator in a case where the module (such as the Ebyte nRF52832 module) actually does have an external oscillator, will it no longer spend any power on the external oscillator?


  • Hero Member

    @NeverDie said in nRF5 Bluetooth action!:

    MY_PASSIVE_NODE,

    I found a shlocky workaround for the current problems with MY_PASSIVE_NODE. It turns out that if you have the gateway up and running before the passive node power up, then the passive node often gets stuck in a loop trying to register itself. However, for whatever reason, if you first power up the passive node, let it run for a bit trying to register and failing, and then power on the gateway, the loop is avoided. Then the passive node will broadcast one packet per cycle and the gateway will receive it and send it to the serial port.

    Unfortunately, Domoticz can't really deal with it.

    Soooooo... For now, I'm using Termite on the serial port to capture the packets and time stamp them. That at least allows me to continue with measurements as to whether MY_PASSIVE_NODE saves significant energy or not. It also has 1 second resolution, not the 5 minute time resoluton of Domoticz.


  • Hero Member

    @d00616

    The specification for the nRF52832 advertises: "Fast wake-up using 64 MHz internal oscillator."

    However, there's not a menu item in the tool menu to set that. So, how is it done?


  • Hero Member

    @NeverDie said in nRF5 Bluetooth action!:

    @NeverDie said in nRF5 Bluetooth action!:

    MY_PASSIVE_NODE,

    I found a shlocky workaround for the current problems with MY_PASSIVE_NODE. It turns out that if you have the gateway up and running before the passive node power up, then the passive node often gets stuck in a loop trying to register itself. However, for whatever reason, if you first power up the passive node, let it run for a bit trying to register and failing, and then power on the gateway, the loop is avoided. Then the passive node will broadcast one packet per cycle and the gateway will receive it and send it to the serial port.

    Unfortunately, Domoticz can't really deal with it.

    Soooooo... For now, I'm using Termite on the serial port to capture the packets and time stamp them. That at least allows me to continue with measurements as to whether MY_PASSIVE_NODE saves significant energy or not. It also has 1 second resolution, not the 5 minute time resoluton of Domoticz.

    Good news! Using the above method, I've established that the EByte nRF52832 module consumes an order of magnitude less current if "MY_PASSIVE_NODE" is defined. ๐Ÿ™‚ ๐Ÿ™‚ ๐Ÿ™‚


  • Hardware Contributor

    @NeverDie said in nRF5 Bluetooth action!:

    Good news! Using the above method, I've established that the EByte nRF52832 module consumes an order of magnitude less current if "MY_PASSIVE_NODE" is defined. ๐Ÿ™‚ ๐Ÿ™‚ ๐Ÿ™‚

    Does that mean you are reaching consumption levels as low as atmega+nrf24 ?


  • Hero Member

    @Nca78 said in nRF5 Bluetooth action!:

    @NeverDie said in nRF5 Bluetooth action!:

    Good news! Using the above method, I've established that the EByte nRF52832 module consumes an order of magnitude less current if "MY_PASSIVE_NODE" is defined. ๐Ÿ™‚ ๐Ÿ™‚ ๐Ÿ™‚

    Does that mean you are reaching consumption levels as low as atmega+nrf24 ?

    Not for all cases, but maybe for this case, provided I can run it off of both of its internal resonators (the 32Khz and the 64Mhz). The datasheet promises a "fast wakeup" if run off the internal 64mHz resonator, and its access to the radio should be a lot faster through DMA, which is automatic.

    Presently, running it all night long (12 hours), it lost less than 50mv off the supercap, and some of that is probably just self-discharge by the supercap.

    Also, getting the DCDC to work would no doubt help...


  • Hero Member

    Maybe using the internal oscillator doesn't matter. Thge datasheet says, "The HFXO must be running to use the RADIO..."

    i.e. without the external 64Mhz oscillator, the radio can't be used. So, if that's true, then I guess from my point of view the 64Mhz external oscillator isn't optional after all. Perhaps that explains why there is one on literaly every module I've seen so far.


  • Hero Member

    I'm ordering today some AVX supercaps with smaller Farad values so that I can get more resolution on the amount of energy (at least relatively) being consumed in different configurations.


  • Hero Member

    I received the nRF51822 modules I had ordered (center of photograph):
    0_1502986163619_nRF51822.jpg
    Small enough to fit almost anywhere!


  • Hero Member

    @Nca78
    Did you ever figure out how to reset the MCU on the Ebyte module?



  • @NeverDie
    I connected a new amplified nrf24 to the gateway with the tin foil as mentioned and it is reading -60dB compared to -89dB with the non amplified version.
    Now lets see how far it goes past the original test.๐Ÿ˜‰



  • @rmtucker
    Well outside of the garden now no problem.๐Ÿ˜Š
    On to supercaps now i think.๐Ÿ˜‰


  • Hero Member

    @rmtucker said in nRF5 Bluetooth action!:

    @NeverDie
    I connected a new amplified nrf24 to the gateway with the tin foil as mentioned and it is reading -60dB compared to -89dB with the non amplified version.

    Did the tin foil make a difference? Hackaday seemed to think it made a big difference. I haven't tried it yet.



  • @NeverDie said in nRF5 Bluetooth action!:

    @rmtucker said in nRF5 Bluetooth action!:

    @NeverDie
    I connected a new amplified nrf24 to the gateway with the tin foil as mentioned and it is reading -60dB compared to -89dB with the non amplified version.

    Did the tin foil make a difference? Hackaday seemed to think it made a big difference. I haven't tried it yet.

    I think it did but what do you have to lose๐Ÿ˜‰


  • Hero Member


  • Hardware Contributor

    @NeverDie said in nRF5 Bluetooth action!:

    @Nca78
    Did you ever figure out how to reset the MCU on the Ebyte module?

    Sorry didn't touch my NRF5 in the last weeks. A bit busy on other things...


  • Hero Member

    What's the best way to make a "receive only" gateway? i.e. one that cannot transmit? Then I wouldn't need to worry about whether the gateway is turned on before powering up a MY_PASSIVE_NODE sensor mote. Is there a way to do it simply in hardware, or do I have to sabotage the gateway library code?


  • Hero Member

    It's getting too baroque. What I'd really like to have is a short nRF5 library of just the bare essentials (like the MIRF library is for the RF24).


  • Hero Member

    Hmmm... it looks like radiohead may be such a library: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__NRF52.html


  • Contest Winner

    @NeverDie said in nRF5 Bluetooth action!:

    It's getting too baroque. What I'd really like to have is a short nRF5 library of just the bare essentials (like the MIRF library is for the RF24).

    You can take a look into the actual Nordic NRF SDK. There are the ESB library for nRF24 compatible communication.


  • Hero Member

    @d00616 said in nRF5 Bluetooth action!:

    @NeverDie said in nRF5 Bluetooth action!:

    It's getting too baroque. What I'd really like to have is a short nRF5 library of just the bare essentials (like the MIRF library is for the RF24).

    You can take a look into the actual Nordic NRF SDK. There are the ESB library for nRF24 compatible communication.

    The RadioHead library seems very easy to pickup and start using. Maybe it's me, but I can't say the same for the Nordic SDK.

    Interestingly, it looks as though @Yveaux may (?) have written the nRF51 part of the RadioHead library.


  • Hero Member

    I was able to program the tiny nRF51822 (earlier photograph above) by programming it as an xxaa Generic nRF51 with an RC oscillator.

    Nice!


  • Hero Member

    Here's a close-up photo:
    0_1503098146155_tinynRF51.jpg


  • Hero Member

    FWIW, range on the tiny nRF51822 does seem compromised when compared against larger sized nRF52832 modules. Not really surprising, but I had hoped it might be a little better than it is.


  • Contest Winner

    @NeverDie said in nRF5 Bluetooth action!:

    FWIW, range on the tiny nRF51822 does seem compromised when compared against larger sized nRF52832 modules. Not really surprising, but I had hoped it might be a little better than it is.

    This is an idea, I don't know if this helps. The two pins near the antenna are GND. Try to solder an 3cm isolated wire to the pin near your PCB and route it parallel of your pcb away from the nRF51 board. The extends the GND pane size.



  • Just in case anyone uses the waveshare ble400 board.
    The board was consuming 150uA when fed with 3.3v bypassing the regulator.
    I have cut through one of the tracks and now it is only consuming 4-5uA and it can still be used normally with the usb lead 5v as long as i place a dupont link across 2 pins.
    If anyone needs photo's let me know.


  • Hero Member

    @d00616 said in nRF5 Bluetooth action!:

    @NeverDie said in nRF5 Bluetooth action!:

    FWIW, range on the tiny nRF51822 does seem compromised when compared against larger sized nRF52832 modules. Not really surprising, but I had hoped it might be a little better than it is.

    This is an idea, I don't know if this helps. The two pins near the antenna are GND. Try to solder an 3cm isolated wire to the pin near your PCB and route it parallel of your pcb away from the nRF51 board. The extends the GND pane size.

    I'll give it a try. Is your idea to make it like a dipole antenna?


  • Hero Member

    @d00616
    Is this what you had in mind?
    0_1503148850641_bipolar.jpg


  • Hero Member

    Also, there are a couple of what look like large solder pads on the back of the PCB. I have no idea what they're for. Anyone know or care to guess?
    0_1503149224079_pads.jpg



  • @scalz said in nRF5 Bluetooth action!:

    I don't think sendSignalStrength function is implemented yet, but you should be able to get this info with:

    int16_t transportGetSendingRSSI(void)
    int16_t transportGetReceivingRSSI(void)
    

    Just wondering what both of these mean?
    I assumed the transportGetReceivingRSSI(void) was the strength of signal from my Gateway ?
    But what is the transportGetSendingRSSI(void)?


  • Contest Winner

    @rmtucker said in nRF5 Bluetooth action!:

    But what is the transportGetSendingRSSI(void)?

    This is the RSSI of the receiver. With nRF5 it's part of the ACK payload.



  • Out of curiosity i stuck a cake tin over the top of the node and it just carried on transmitting,so i put it behind 4 walls and 1 floor down then behind the fuse box and consumer unit and eventually got it to drop to -68dB for received rssi but send rssi stayed at -45dB so it seems to be booming out and in.๐Ÿ˜‰


  • Hero Member

    0_1503148850641_bipolar.jpg

    Results: I don't think it made the link worse, but it's not obvious that it made the link better either. Range seems about the same.

    Even more surprising: prior to adding this piece of wire, I didn't notice much improvement when I went from 2Mbps at Tx 0db to 250kbps at Tx 4db either. I had really thought it would be a tangible improvement in range, but if there was any improvement (and I'm not sure that there was), it seemed like only a modest amount.

    Conclusions/recommendations/suggestions/comments?


  • Mod

    @NeverDie I don't know how much work is needed to make this work with nrf5, but @Yveaux has created a range tester that might be useful. https://github.com/Yveaux/MySensorsRangeTest

    It does use MySensors though, so it might provide more overhead than the bare-bone functionality you are looking for.


  • Hardware Contributor

    @NeverDie is your wire soldered to gnd?? if so, i would have soldered it to the antenna transmission line, as a monopole, with taking care of disabling the pcb antenna. i guess you're trying sort of dipole, but one branch is meandered/"coiled" so not sure if that would improve a lot like you noticed..


  • Hero Member

    @scalz said in nRF5 Bluetooth action!:

    @NeverDie is your wire soldered to gnd?? if so, i would have soldered it to the antenna transmission line, as a monopole, with taking care of disabling the pcb antenna. i guess you're trying sort of dipole, but one branch is meandered/"coiled" so not sure if that would improve a lot like you noticed..

    In this instance, I don't see a way to attach to the actual antenna. On some boards I see a little hole where a wire can be attached. On this one, I guess maybe it could be done by carefully scraping off the solder mask and then soldering to the trace.... Its a gamble though: t would be all too easy to scrape off the trace in the process.

    Anyhow, enlarging the footprint of the board kinda defeats the purpose of its small size. I think maybe it just is what it is, and the relatively poor performance explains its relatively low price.

    Maybe what would rescue it is an adequate ground plane on whatever PCB it attaches to. For instance, I'm thinking it might be a nice match for a "Chirp" soil moisture sensor, which maybe (I'd have to look) has a long--though narrow--ground plane. Making the Chirp wireless would be a nice upgrade. ๐Ÿ™‚ It has an attiny MCU, which (unless someone knows differently) isn't enough to control, say, an SMD nRF24l01. I suppose it could be redesigned to use an atmega328p (which would be preferable), but you can already buy cheap pre-made attiny Chirps from China, so there's an argument for leveraging that instead by attaching maybe this cheap wireless module to it.


  • Hero Member

    Interesting discovery! Despite what you would think from the look of them (especially the one on the left), the two large solder pads both have continuity to ground.

    So, I'm hypothesizing that both are meant to be soldered to a larger ground plane on whatever PCB the module is soldered to.

    0_1503149224079_pads.jpg


  • Hardware Contributor

    @NeverDie
    i would have unsoldered the last pad of the passive before the antenna feed point to disable it, and would have soldered the wire antenna to passive, so without scratching anything ๐Ÿ˜‰ but i have no idea about nrf51 range, i'm not using this mcu :simple_smile:
    I have my own design for soil moisture..not really interested by "chirp" like sensors, but i agree nrf52 are nice mcu.


  • Hero Member

    @scalz said in nRF5 Bluetooth action!:

    @NeverDie
    i would have unsoldered the last pad of the passive before the antenna feed point to disable it, and would have soldered the wire antenna to passive, so without scratching anything ๐Ÿ˜‰ but i have no idea about nrf51 range, i'm not using this mcu :simple_smile:
    I have my own design for soil moisture..not really interested by "chirp" like sensors, but i agree nrf52 are nice mcu.

    If you feel like posting it, I'd certainly be interested in a good soil moisture sensor. ๐Ÿ™‚

    This is the only nRF51 I've tried, but @rmtucker seems to be getting good range (beyond his garden) with his nRF51. I previously drank the Kool-aid and thought the nRF52 generally performs better, but I'm not I'm not really sure anymore.



  • @NeverDie
    What are you using at the other end,just a standard nrf24 or the amplified version.
    I switched to rfm69 some time ago because of poor range/coverage.
    But i am astounded with the nrf51 and wemos/nrf24 pa setup.
    Maybe it is the tin foil wrapping Lol.๐Ÿ˜ƒ



  • @rmtucker
    I did eventually manage to stop it by putting it in the fridge.
    My other half has never laughed so much.๐Ÿ˜ƒ๐Ÿ˜ƒ


  • Hero Member

    @rmtucker said in nRF5 Bluetooth action!:

    @rmtucker
    I did eventually manage to stop it by putting it in the fridge.
    My other half has never laughed so much.๐Ÿ˜ƒ๐Ÿ˜ƒ

    If you switch to Lithium batteries (I'm partial to the Energizer AA's because they have good datasheets), your node should still work even in the freezer.


  • Hero Member

    @rmtucker said in nRF5 Bluetooth action!:

    @NeverDie
    What are you using at the other end,just a standard nrf24 or the amplified version.
    I switched to rfm69 some time ago because of poor range/coverage.
    But i am astounded with the nrf51 and wemos/nrf24 pa setup.
    Maybe it is the tin foil wrapping Lol.๐Ÿ˜ƒ

    I did it both ways when with datarates of 250kbps and 1Mbps, but when I upgraded the nRF52832 to 2Mbps, the connection stopped working. For expediency, I switched to an nRF52 DK as the gateway, rather than debug the nRF24 just then. Eventually I'll circle back and try to figure out what the problem is/was with the 2Mbps on the nRF24's. So, the nRF52 DK is what I'm presently using.



  • @rmtucker
    On the supercapacitor subject.
    Nick Gammon used a 0.47uf 5.5v capacitor and you have been trying a 10uf 2.7v.
    So i was going to try a 4uf 5.5v super cap and an mcp1700-33 to power the nrf at 3.3v.
    I was going to charge the supercap initially with an adjustable dc-dc converter set to 5v while experimenting,anyone see a problem?


  • Hero Member

    @rmtucker said in nRF5 Bluetooth action!:

    @rmtucker
    On the supercapacitor subject.
    Nick Gammon used a 0.47uf 5.5v capacitor and you have been trying a 10uf 2.7v.
    So i was going to try a 4uf 5.5v super cap and an mcp1700-33 to power the nrf at 3.3v.
    I was going to charge the supercap initially with an adjustable dc-dc converter set to 5v while experimenting,anyone see a problem?

    I'm assuming Nick Gammon was using not an Nordic radio but just an atmega chip? I don't think you'll get much runtime on a 0.47uF supercap, nor a 4uF supercap, because of the radio.

    On the plus side, it should charge up almost instantly. ๐Ÿ™‚

    On the other hand, 100uF should be enough to send at least one packet. I haven't tried that low an amount on the nrf52, but I have done it with a 100uF (charged to 2.7v) powering an atmega328p+RFM69 combo.



  • @NeverDie
    I think he was using an nrf24 just the same as us.
    He was getting 32hours without re-charging and transmitting every 5mins.


  • Hero Member

    @rmtucker said in nRF5 Bluetooth action!:

    mcp1700-33

    It appears to be just an LDO. So, you won't get any advantage to charging your capacitor to greater than 3.3v.


  • Hero Member

    @rmtucker said in nRF5 Bluetooth action!:

    @NeverDie
    I think he was using an nrf24 just the same as us.
    He was getting 32hours without re-charging and transmitting every 5mins.

    Really? Wow. That I'd like to see. I don't see how it's even possible. Do you have a link?




  • Hero Member

    @rmtucker said in nRF5 Bluetooth action!:

    Nick Gammon used a 0.47uf 5.5v capacitor

    Re-read your link. He used a 0.47F capacitor, not a 0.47uF capacitor. That's a million times difference.

    0.47F works. I arrived at 10F because it seems to be a sweet spot in the way that supercaps are priced. You can get a lot of Farads for just $2.



  • @NeverDie
    My Mistake but his results were impressive don't you think?
    Anyway i was just going to use 4f because i can get one.
    How are you charging your Cap?


  • Hero Member

    @rmtucker said in nRF5 Bluetooth action!:

    How are you charging your Cap?

    6v mini solar panel run through diode and a 2.7v ldo. That works for me indoors even 15-20 feet away from a window.



  • @NeverDie
    Hmm the only 2.7v ldo i can see are surface mount in the uk.
    Thats a no no for me.


  • Hero Member

    @rmtucker said in nRF5 Bluetooth action!:

    @NeverDie
    Hmm the only 2.7v ldo i can see are surface mount in the uk.
    Thats a no no for me.

    Yeah, I'm using surface mount, but I solder it on manually the old fashioned way. Not all surface mount are difficult just because they're SMD. Simply avoid the ones with too small a pitch.



  • @NeverDie
    Part number?


  • Hero Member


  • Hero Member

    Where is the sleep(...) function defined for the nrf5? I've looked, but I can't seem to find which library it is in. Anyone know?


  • Contest Winner

    @NeverDie said in nRF5 Bluetooth action!:

    Where is the sleep(...) function defined for the nrf5? I've looked, but I can't seem to find which library it is in. Anyone know?

    It's defined in "hal/architecture/MyHwNRF5.cpp"



  • If anybody need cheap NRF52 DK, Arrow has them for ca. $30 with free courier shipping!


  • Hardware Contributor

    @Toyman said in nRF5 Bluetooth action!:

    If anybody need cheap NRF52 DK, Arrow has them for ca. $30 with free courier shipping!

    10% discount at the moment so 29.48$. Given the price per unit of a nrf52 if you buy in small numbers, it's worth buying it just for the extra chips provided ๐Ÿ˜„


  • Hero Member

    Speaking as a noob myself, I think the DK's are great for noobs, especially when first getting started. I don't have as big a need for them now, but they definitely helped in the beginning. They pretty much "just work" without a lot of fuss.


  • Hero Member

    I'm presently playing around with the radioHead library. I can:

    1. Send and receive backets between two nRF5 modules.
      or
    2. Send and receive packets between two nRF24L01 modules.

    However, at present, I can't send or receive packets successfully between an nRF24 and an nRF5 module, even though it appears they share the same network ID, the same datarate, and the same channel.

    I'm guessing there exists some kind of compatability mode (?) that would bridge this gap, but I haven't found it. ๐Ÿ˜ž


  • Hardware Contributor

    @NeverDie
    d00616 added the support of NRF5 + ESB to MySensors.
    Radiohead lib doesn't handle this mode (explained in the description of his NRF51class).


  • Hero Member

    Yeah, MySensors can definitely do it. Nice work @d00616 !

    It turns out that with RadioHead, I am almost able to send packets from an nRF24L01 to an nRF5 module: it's just that the packets arrive as garbage. So, the packet and/or frame formatting must be different, but indeed the network ID's are matching or else I wouldn't be receiving anything at all.


  • Hero Member

    I found the smoking gun in the radiohead documentation. Turns out RadioHead does indeed use a different packet format for the nRF5 that is "NOT compatible with the one used by RH_NRF24 and the nRF24L01 product specification, mainly because the nRF24 only supports 6 bits of message length." ๐Ÿ˜ž

    Well, that stinks.



  • @NeverDie Ya, that really sucks. It would have been great to mix and match.


  • Contest Winner

    @NeverDie said in nRF5 Bluetooth action!:

    Yeah, MySensors can definitely do it. Nice work @d00616 !
    Thanks.

    It turns out that with RadioHead, I am almost able to send packets from an nRF24L01 to an nRF5 module: it's just that the packets arrive as garbage. So, the packet and/or frame formatting must be different, but indeed the network ID's are matching or else I wouldn't be receiving anything at all.

    The ID's are reversed between nRF5 and nRF24. Look into the code how to reverse the ID's.

    @NeverDie said in nRF5 Bluetooth action!:

    I found the smoking gun in the radiohead documentation. Turns out RadioHead does indeed use a different packet format for the nRF5 that is "NOT compatible with the one used by RH_NRF24 and the nRF24L01 product specification, mainly because the nRF24 only supports 6 bits of message length."

    You have to choose the correct number of bits for length, S0 and S1. I have played a while to find out the correct configuration. When ACK is enabled you have to do a lot of timing work.

    @Terrence said in nRF5 Bluetooth action!:

    @NeverDie Ya, that really sucks. It would have been great to mix and match.

    At the moment I have no opinion to the "GPL or commercial" license of Readiohead. So I have no plans to port my Code .

    The Nordic SDK has an ESB library supporting the nRF24 mode. IMHO Starting with SDK 13 the license is more Open Source friendly.


  • Hero Member

    I'm realizing I can live with it. It just means I need to add a separate nRF24 gateway if I want to use nRF24's. I'm already adding separate gateways to support RFM69's and LoRa's, so, actually, it's no big deal.

    Meanwhile, I've found that the RadioHead and the MySensors libraries are at least minimally compatible. So, presently I'm using RadioHead for my low power transmissions, but I'm using the sleep(...) function from MySensors to sleep the nRF52 and wake it up. ๐Ÿ™‚

    The only weirdness I'm noticing is that immediately after sending the very first packet in this configuration, there's a mysterious several second delay that occurs before the code continues. However, after the initial hiccup, everything appears to run exactly as fast as it should. I have no clue as to what is causing that initial delay though. It doesn't happen if I don't #include the MySensors.h file.



  • I was playing with sleep tonight and found the following problem.
    when using sleep as below it always returns a figure 252 ms bigger than the sleep figure.
    ie sleep 10000 always returns 10251
    ie sleep 3000 always returns 3251.
    I know the nrf51822 has a 32khz rtc so why is this?

      oldmillis = hwMillis();
      hwSleep(10000);
      newmillis = hwMillis();
      Serial.println(newmillis - oldmillis);
    


  • Seems it may have something to do with this in the code.

    // Calculate sleep time
    		// 8 Hz -> max 582.542 hours sleep.
    		MY_HW_RTC->PRESCALER = 4095;
    		// Set compare register to 1/125ms + 2 to garantee event triggering
    		MY_HW_RTC->CC[0] = (ms / 125) + 2;```


  • MY_HW_RTC->CC[0] = (ms / 125) + 2;

    It seems the +2 above is adding 250ms.
    Why is it done like this???


  • Hero Member

    What more can be done to reduce current consumption on an nRF52832 when the MySensors "sleep" function is being used with RTC wakeup. I've measured a 300mv drop on a 10F capacitor over a 12 hour time period. Of that 300mv, perhaps 20mv was lost due to self-discharge of the supercap. So, that still leaves 280mv of loss due to the nRF52832 . That is too high a rate of loss.



  • @NeverDie
    Seeing Your sketch would help?


  • Contest Winner

    @rmtucker said in nRF5 Bluetooth action!:

    MY_HW_RTC->CC[0] = (ms / 125) + 2;

    It seems the +2 above is adding 250ms.
    Why is it done like this???

    A minimum of two ticks are required to be sure the CC[0] is triggered.

    What accuracy is your requirement? I can add more code here to dynamical change the pre scaler plus a check if ms/125>=2



  • @d00616
    My initial thoughts were how the nrf51822 could be used for energy meters (counting pulses and the gap between them),But unlike the arduino's which can not run timers when in sleep mode,The nrf5 can of course do this.
    So the nrf5 would be able to report watts and usage while still using sleep mode.
    But seeing the inaccuracy of the timer has put the brakes on that.
    Yes being able to change the prescaler dynamically would help a great deal as 125ms / 582.542 hours is not really useful for most applications with a 250ms overrun.



  • Just wondering what the prescaler etc would have to be set to for ms accuracy and how long before overflow.(aint got my maths head on today)๐Ÿ˜Š


  • Contest Winner

    @NeverDie said in nRF5 Bluetooth action!:

    What more can be done to reduce current consumption on an nRF52832 when the MySensors "sleep" function is being used with RTC wakeup. I've measured a 300mv drop on a 10F capacitor over a 12 hour time period. Of that 300mv, perhaps 20mv was lost due to self-discharge of the supercap. So, that still leaves 280mv of loss due to the nRF52832 . That is too high a rate of loss.

    Wh = 0.5 * 10F * 280mV = 0.392 Wh = 0.0326667 W
    I=0.0326667/2.56V = 12.76mA

    Looks like the node is most time fully active.


  • Contest Winner

    @rmtucker said in nRF5 Bluetooth action!:

    @d00616
    My initial thoughts were how the nrf51822 could be used for energy meters (counting pulses and the gap between them),But unlike the arduino's which can not run timers when in sleep mode,The nrf5 can of course do this.
    So the nrf5 would be able to report watts and usage while still using sleep mode.

    If you have the idea to store the results into the EEPROM like storage the nRF5, then read the hints about this: https://github.com/d00616/arduino-NVM/#nvramh

    The virtual EEPROM, the radio or debugging output are adding latency to the main loop. You will see more timing errors in long term run when you trust the sleep() time.

    The nRF5 can help you to count without adding latency by the cpu. You can use a timer in counter mode which TASK_COUNT and TASKS_CAPTURE[0] are triggered by PPI. Then you can compare the hwMillis() with the last seen CC[0] content and do precise calculation of events.

    With nRF52 there is an unused RTC wich can trigger TASKS_CAPTURE[0] at a specific time. One RTC is used for millis() in arduino-nrf5 and one RTC is used for sleep.

    But seeing the inaccuracy of the timer has put the brakes on that.
    Yes being able to change the prescaler dynamically would help a great deal as 125ms / 582.542 hours is not really useful for most applications with a 250ms overrun.

    I will change this.


  • Hero Member

    @rmtucker
    Here it is, though it's rather messy. Nonetheless, all it does is measure the supercap and solar panel voltages, send them, then sleep for 12 hours. Then repeats:

    // nrf51_client.pde
    // -*- mode: C++ -*-
    // Example sketch showing how to create a simple messageing client
    // with the RH_NRF51 class. RH_NRF51 class does not provide for addressing or
    // reliability, so you should only use RH_NRF51 if you do not need the higher
    // level messaging abilities.
    // It is designed to work with the other example nrf51_server.
    // Tested on RedBearLabs nRF51822 and BLE Nano kit, built with Arduino 1.6.4.
    // See http://redbearlab.com/getting-started-nrf51822/
    // for how to set up your Arduino build environment
    // Also tested with Sparkfun nRF52832 breakout board, witth Arduino 1.6.13 and
    // Sparkfun nRF52 boards manager 0.2.3
    #include <RH_NRF51.h>
    #include <MySensors.h>
    
    
    unsigned long SLEEP_TIME = 43200000; // 12 hour sleep time between measurements (in milliseconds)
    //unsigned long SLEEP_TIME = 3600000; // 1 hour sleep time between measurements (in milliseconds)
    //unsigned long SLEEP_TIME = 300000; // 5 minute sleep time between measurements (in milliseconds)
    //unsigned long SLEEP_TIME = 1000; // 1 second sleep time between measurements (in milliseconds)
    #define SUPERCAP_PIN A2  //input pin for reading the supercap's voltage
    #define SOLAR_PANEL_PIN A4  //input pin for reading the solar panel's voltage
    #define LDO_ENABLE_PIN 8  //D8 (P0.19) is output pin for enabling (HIGH) or disabling (LOW) the LDO
    #define NUM_MEASUREMENTS_TO_AVERAGE 3  //number of measurements to collect and then average
    #define MAX_MEASUREMENTS 10 //Maximum number of voltage measurements before returning a result.
    
    // Singleton instance of the radio driver
    RH_NRF51 nrf51;
    uint8_t data[10];
    
    uint16_t batteryVoltage() {
      uint16_t lastRawVoltage, newRawVoltage;
      //uint16_t counter=0;
      //lastRawVoltage = hwCPUVoltage();  //throw away the first voltage measurement
      newRawVoltage = hwCPUVoltage();
    
        
      return newRawVoltage; 
    }
    
    
    
    
    uint16_t readRawVoltageOnPin(uint8_t thePin) {
      uint16_t lastRawVoltage, newRawVoltage;
      uint16_t counter=0;
      lastRawVoltage = analogRead(thePin);
      newRawVoltage = analogRead(thePin);
      while (((newRawVoltage != lastRawVoltage)) && (counter<MAX_MEASUREMENTS)) {  //measure until two consecutive measurements match
        lastRawVoltage=newRawVoltage;
        newRawVoltage=analogRead(thePin);
        counter++;
      }
      uint32_t sumOfMeasurements=0;
      for (int i=0;i<NUM_MEASUREMENTS_TO_AVERAGE;i++) {
        sumOfMeasurements=sumOfMeasurements+analogRead(thePin);
      }
        
      return (sumOfMeasurements/NUM_MEASUREMENTS_TO_AVERAGE); 
    }
    
    void myBaro()
    {
    
      uint32_t superCapVoltage=0;
      uint32_t solarPanelVoltage=0;
      uint32_t superCapRawVoltage=0;
      uint32_t solarPanelRawVoltage=0;
    
      digitalWrite(LDO_ENABLE_PIN, LOW);  //disconnect solar panel
      superCapRawVoltage = readRawVoltageOnPin(SUPERCAP_PIN);
      
      superCapVoltage = (3048*(((superCapRawVoltage)*3127)/4095))/1591;
      //Serial.print("SuperCap voltage=");
      //Serial.println(superCapVoltage);
    
      //send(msg1_S_BARO_P.set(superCapVoltage));  //superCap's raw voltage
    //  wait(500);
    
    //  wait(500);
      //delayMicroseconds(1000);  //wait for voltage to adjust after LDO disabled.  Necessary???
      
      solarPanelRawVoltage=readRawVoltageOnPin(SOLAR_PANEL_PIN);
      digitalWrite(LDO_ENABLE_PIN, HIGH);  //re-connect solar panel
      solarPanelVoltage=(5500*(((solarPanelRawVoltage)*3181)/4095))/1289;
      //Serial.print("Solar Panel Voltage=");
      //Serial.println(solarPanelVoltage);
      //superCapVoltage=1234;
    
      data[0]= (superCapVoltage/1000)+'0';
      data[1]= ((superCapVoltage%1000)/100)+'0';
      data[2]= ((superCapVoltage%100)/10)+'0';
      data[3]= (superCapVoltage%10)+'0';
      data[4]=',';
      data[5]= (solarPanelVoltage/1000)+'0';
      data[6]= ((solarPanelVoltage%1000)/100)+'0';
      data[7]= ((solarPanelVoltage%100)/10)+'0';
      data[8]= (solarPanelVoltage%10)+'0';
      data[9]='\0';
      nrf51.send(data, sizeof(data));
      nrf51.waitPacketSent();
    }
    
    
    void setup() 
    {
      pinMode(LDO_ENABLE_PIN, OUTPUT);  // Enable/Disable pin for the LDO
      digitalWrite(LDO_ENABLE_PIN, HIGH);  //enable the LDO.
    
      analogReadResolution(12);  //use 12-bit ADC resolution
      pinMode(SUPERCAP_PIN,INPUT);  //Supercap voltage measurement pin
      pinMode(SOLAR_PANEL_PIN,INPUT);  //Solar panel voltage measurement pin
      
      //delay(1000); // Wait for serial port etc to be ready
      Serial.begin(250000);
      //while (!Serial) 
        ; // wait for serial port to connect. 
      if (!nrf51.init())
        Serial.println("init failed");
      // Defaults after init are 2.402 GHz (channel 123), 2Mbps, 0dBm
      if (!nrf51.setChannel(123))
        Serial.println("setChannel failed");
      if (!nrf51.setRF(RH_NRF51::DataRate2Mbps, RH_NRF51::TransmitPower4dBm))
        Serial.println("setRF failed"); 
      
      // AES encryption can be enabled by setting the same key in the sender and receiver
    //  uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
    //                    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
    //  nrf51.setEncryptionKey(key);
    
    //  nrf51.printRegisters();
      Serial.println("Setup of nr51 client completed.");
      Serial.println("Sending to nrf51_server...");
      Serial.flush();
    }
    
    uint32_t sentCounter=0;
    uint32_t replyCounter=0;
    
    void loop()
    {
      //uint16_t theBatteryVoltage;
      //theBatteryVoltage=batteryVoltage();
      //theBatteryVoltage=batteryVoltage();
     // Serial.print("Battery voltage = ");
      //Serial.print(theBatteryVoltage);
      //Serial.println(" millivolts.");
      
      // Send a message to nrf51_server
      //uint8_t data[] = "Hello World!";
    /*
      data[0]= (theBatteryVoltage/1000)+'0';
      data[1]= ((theBatteryVoltage%1000)/100)+'0';
      data[2]= ((theBatteryVoltage%100)/10)+'0';
      data[3]= (theBatteryVoltage%10)+'0';
      data[4]='\0';
      nrf51.send(data, sizeof(data));
      sentCounter++;
      nrf51.waitPacketSent();
    
     */
      myBaro();
    
      /*
      // Now wait for a reply
      uint8_t buf[RH_NRF51_MAX_MESSAGE_LEN];
      uint8_t len = sizeof(buf);
    
      if (nrf51.waitAvailableTimeout(500))
      { 
        // Should be a reply message for us now   
        if (nrf51.recv(buf, &len))
        {
          Serial.print("got reply: ");
          Serial.println((char*)buf);
          replyCounter++;
        }
        else
        {
          Serial.println("recv failed");
        }
      }
      else
      {
        Serial.println("No reply, is nrf51_server running?");
      }
      Serial.print("sentCounter="); 
      Serial.print(sentCounter);
      Serial.print(", replyCounter=");
      Serial.println(replyCounter);
      Serial.flush();
      */
     
      sleep(SLEEP_TIME); // Sleeps for 12 hours in deep sleep
    }
    

    Using Termite to timestamp the output received, what I got was:

    2017/08/25 17:04:13: got request: 2684,0085
    
    2017/08/26 05:04:12: got request: 2396,0076
    

    You can ignore the solar panel measurements, because I disconnected it so as to not interfere.

    On the bright side, it woke up and reported within 1 second of when it was supposed to, after a 12 hour sleep.


  • Contest Winner

    @NeverDie said in nRF5 Bluetooth action!:

    Here it is, though it's rather messy. Nonetheless, all it does is measure the supercap and solar panel voltages, send them, then sleep for 12 hours. Then repeats:

    RadioHead sets the radio into the Idle state. The radio isn't powered off. There is no call in RadioHead to power off the radio.



  • @NeverDie
    So your sketch only wakes up every 12hours.
    What current is it drawing using the radiohead library vs mysensors for an equivalent 12 hour sleep because in past discussions with you i remember you saying 5-6uA while sleeping,is this still correct?
    I dont see much advantage to the radiohead library if only sending at 12hour intervals.


  • Hero Member

    @rmtucker said in nRF5 Bluetooth action!:

    @NeverDie
    So your sketch only wakes up every 12hours.
    What current is it drawing using the radiohead library vs mysensors for an equivalent 12 hour sleep because in past discussions with you i remember you saying 5-6uA while sleeping,is this still correct?
    I dont see much advantage to the radiohead library if only sending at 12hour intervals.

    The 6ua was measured with it in deep sleep, where it relied on an external interrupt to wakeup. This measurement was intended to see what it would be if it woke-up using the RTC. So, the 12 hour interval is artificial, for measurement purposes.

    @d00616
    I had wrongly assumed that the "sleep(...)" command would sleep the radio. Thanks for pointing out my error. How/when is it that Mysensors puts the radio to sleep? Does it just happen automatically at the end of every sending/receiving?


  • Contest Winner

    @NeverDie said in nRF5 Bluetooth action!:

    I had wrongly assumed that the "sleep(...)" command would sleep the radio. Thanks for pointing out my error. How/when is it that Mysensors puts the radio to sleep? Does it just happen automatically at the end of every sending/receiving?

    We are both not 100% correct ๐Ÿ˜‰ The hwSleep() function doesn't disable the radio, but the sleep() function does it, when MY_SENSOR_NETWORK is defined.

    After Sleep transportReInitialise() is called. Then you have to initialize RadioHead again.


  • Hero Member

    @d00616 said in nRF5 Bluetooth action!:

    After Sleep transportReInitialise() is called. Then you have to initialize RadioHead again.

    So, even with RAM retention active while sleeping, each time the radio is awoken, it needs to be re-initialized?


  • Contest Winner

    @NeverDie said in nRF5 Bluetooth action!:

    So, even with RAM retention active while sleeping, each time the radio is awoken, it needs to be re-initialized?

    The Radio has to be initialized after power down. This doesn't depend on RAM retention.


  • Hero Member

    According to Table 39 of the mRF52832 datasheet, there is only one radio state resembling sleep, and that is the DISABLED radio state where "No operations are going on inside the radio and the power consumption is at a minimum."

    Apparently the radio is disabled through register TASKS_DISABLE, offset 0x010, Disable RADIO, as indicated by Table 41 register overview.


  • Hero Member

    But how exactly does one read or write to these registers? It looks like a quite different arrangement than writing to registers for an nRF24 or an RFM69 or a LoRa chip.


  • Contest Winner

    @NeverDie said in nRF5 Bluetooth action!:

    But how exactly does one read or write to these registers? It looks like a quite different arrangement than writing to registers for an nRF24 or an RFM69 or a LoRa chip.

    You have to include nrf.h. To disable the radio, you can do this:

    https://github.com/mysensors/MySensors/blob/development/drivers/NRF5/Radio_ESB.cpp#L264

    If your transmitting power is 0dbm, then "TX only run current PRF = 0dBm" with 11.6 mA is near the calculated current, when the radio stays in TX mode after sending the data.


  • Hero Member

    @d00616
    Will this block of code guarantee that the radio is disabled?

      Serial.println("Testing whether radio is disabled...");
      Serial.print("NRF_RADIO->EVENTS_DISABLED=");
      Serial.println(NRF_RADIO->EVENTS_DISABLED);
      while (!(NRF_RADIO->EVENTS_DISABLED)) {
        Serial.print("NRF_RADIO->EVENTS_DISABLED=");
        Serial.println(NRF_RADIO->EVENTS_DISABLED);
        NRF_RADIO->TASKS_DISABLE = 1;  //sleep the radio
      }
      Serial.println("Radio disabled.");
    

  • Contest Winner

    @NeverDie said in nRF5 Bluetooth action!:

    Will this block of code guarantee that the radio is disabled?

    This one is better:

    if (NRF_RADIO->STATE != RADIO_STATE_STATE_Disabled) {
    	NRF_RADIO->TASKS_DISABLE = 1;
    }

Log in to reply
 

Suggested Topics

  • 8
  • 7
  • 44
  • 1
  • 90
  • 1

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts