rfm69 and atc
I have played a little bit with atc examples from lowpowerlab which work well
but I have some trouble to include it in mysensors
Here description of atc for rfm69 : http://lowpowerlab.com/blog/2015/11/11/rfm69_atc-automatic-transmission-control/
What I like is :
- "green" rf (no scream level)
- autoadjust rssi when fresh made node, or you move it (rare)
- optimized low power as it adjust rssi
Very basic setup I am trying to compile:
- from https://github.com/LowPowerLab/RFM69, add rfm69_atc. h and .cpp to rfm69 driver folder
- it will need ifdef at some place, but for dirty test, in transportrfm69:
//#include "drivers/RFM69/RFM69.h" #include "drivers/RFM69/RFM69_ATC.h" // RFM69 _radio(MY_RF69_SPI_CS, MY_RF69_IRQ_PIN, MY_RFM69HW, MY_RF69_IRQ_NUM); RFM69_ATC _radio(MY_RF69_SPI_CS, MY_RF69_IRQ_PIN, MY_RFM69HW, MY_RF69_IRQ_NUM);```
- still in transportrfm69.cpp, in transport.init:
_radio.enableAutoPower(-70); // fixed for tests
That would need some define conf like for example
- MY_ENABLE_ATC to enable atc mode
- MY_ENABLE_ATC_LEVEL_RFM69 for target rss level
I'm getting this really dumb errors!
sketch\SensebenderMicro.ino.cpp.o: In function `transportInit()': C:\Users\scalz\Documents\Arduino\libraries\MySensors/core/MyTransportRFM69.cpp:42: undefined reference to `RFM69_ATC::initialize(unsigned char, unsigned char, unsigned char)' sketch\SensebenderMicro.ino.cpp.o: In function `transportReceive(void*)': C:\Users\scalz\Documents\Arduino\libraries\MySensors/core/MyTransportRFM69.cpp:84: undefined reference to `RFM69_ATC::sendACK(void const*, unsigned char)' collect2.exe: error: ld returned 1 exit status exit status 1
Looking at each rfm, rfm_atc or rfmtransport I don't understand why it's undefined..rfm69_atc class is simply derived from rfm69 class. I am thinking about bad linking, bad inheritance declaration, or something not "in sync" with some params of core class methods (but I don't see where or why)?? Can you explain me? I'm feeling blind, and would like to learn..
@Hek, I'm sure you know what's wrong. don't laugh
I will add more things I need when I will understand my mistake here
Do you include your new ATC cpp here?
@hek no I didn't see this place! thx. I have just added but still same errors. I am still looking..
Edit: I am using dev branch of course! and for the test, I am trying to compile sensebender sketch.
@hek: sorry, it's oki for cpp. I added .h instead So now I have a small lot of errors due to the addition , I will look how to fix it and report here if I have another problem or success. thx
You might need to include both...
both in mysensors.h ? I will try. I need to understand well how it is organized I think.
Yes, include both .cpps, looks like the new class inits the old:
yes I kept the too. but if I remove rfm69.cpp or not, it still have these new errors I'm looking after
In file included from C:\Users\scalz\Documents\Arduino\libraries\MySensors/MySensor.h:265:0, from C:\Users\scalz\AppData\Local\Temp\arduino_modified_sketch_741351\SensebenderMicro.ino:65: C:\Users\scalz\Documents\Arduino\libraries\MySensors/drivers/RFM69/RFM69_ATC.cpp: In member function 'void RFM69_ATC::sendFrame(uint8_t, const void*, uint8_t, bool, bool, bool, int16_t)': C:\Users\scalz\Documents\Arduino\libraries\MySensors/drivers/RFM69/RFM69_ATC.cpp:111:18: error: 'RFM69_CTL_SENDACK' was not declared in this scope SPI.transfer(RFM69_CTL_SENDACK | (sendRSSI?RFM69_CTL_RESERVE1:0)); // TomWS1 TODO: Replace with EXT1 ^ C:\Users\scalz\Documents\Arduino\libraries\MySensors/drivers/RFM69/RFM69_ATC.cpp:118:32: error: 'RFM69_CTL_REQACK' was not declared in this scope SPI.transfer(_targetRSSI ? RFM69_CTL_REQACK | RFM69_CTL_RESERVE1 : RFM69_CTL_REQACK); ^ C:\Users\scalz\Documents\Arduino\libraries\MySensors/drivers/RFM69/RFM69_ATC.cpp:129:66: error: 'RF69_TX_LIMIT_MS' was not declared in this scope while (digitalRead(_interruptPin) == 0 && millis() - txStart < RF69_TX_LIMIT_MS); // wait for DIO0 to turn HIGH signalling transmission finish ^ exit status 1```
Too much for my brain at this hour. You should probably start looking for the missing RFM69_CTL_REQACK define.
yep. thank you very much
cool it compiles after updated rfm69 lib. I do some define and tests, and I will try my first PR I also need to check what are all diff between old and new lib. can't wait to try listenmode now...
I will keep a very close eye on this!
Listen mode is very interesting, but also the possible prolonged battery life from the other sensors!!!
Big thumbs up!
thx. so far so good
I had a little bit time last night...I think I will rename this topic "improvements for our mysensors rfm69 lib" lol
I diff checked with mysensors rfm69 driver lib: latest lowpowerlab rfm69 lib (master+spi transaction version) + few others variant I found to see if something could be missing. So I started from mysensors rfm69 driver one and added step by step the changes, and of course not forgot to keep boards define (atsam, esp, 328...) + checked the purpose of these changes.
The list of improvements I noticed:
- ATC, Automatic Transfer Power Control : merged, working (not the biggest part)
- small improvements on spi transaction part : merged but not full tested. I don't use ethernet shield, so just tested with eeprom but I think this change was mostly made for things like w5100 shield...if I have time I will try to make more tests on this..
- ListenMode : still, in progress but in a good way I think Almost merged but not tested yet (was too late!!). For the moment it compiles. It will need some tests I think to see if all properly works, power consumption..At lowpowerlab they get very few ua (1-2ua order) in listenmode. sounds great I hope to have same success. I need register to their forum at least to thx them. not done. booo
- with this listenmode, I plan to use gammon sketch J. I already did tests and noticed a better low consumption than lowpowerlab sleep of mysensors. but I will check if it's still the same case
- still about sleep mode, I will look if it's possible to improve wakeup time, I read interesting things.
- when all this will be ok, I will try to see if it's interesting to use sort of WDT Listenmode : a wdt done by rssi using listenmode. but that's at the end of the list! and needs to see then if it's better or not than common wdt power consumption. but that looks tempting because common wdt don't do listenmode...
Files impacted for those interested to know:
- rfm69 libs updated
- rfm69_atc added
- myTransportRFM69 updated
- one cpp include in mysensor.h
- few define in myconfig.h
- mysensorscore, transport, hw..to add a SleepWithListenMode method ...For the moment I add my own sleep method to not break anything and keep mysensors archi...
Some stuff, I hope I will have everything ok! But I'm very happy doing this as now I am a lot lot more confident with mysensors archi. very cool
see you soon
very good work ! especially for ATC and Listenmode.
Is the code mods on Github for us to look at??
@scalz how is atc working on the rfm69?
@Francois sorry this work is still in progress, I will work on it this week.
This is handled in the rfm69 lib. And lowpowerlab explains this well: copied from Lowpowerlab
- "The basic idea behind this extension is to allow your nodes to dial down transmission power based on the received signal strength indicator (RSSI)."
- "with RFM69_ATC this is done automatically for you, you just need to indicate a target RSSI. On each packet sent and ACK received (using sendWithRetry(…) is required), the node analyzes the actual RSSI and continuously adjusts its own transmission power level of the RFM69 transceiver to attempt to match the target RSSI (+ or -)"
Require some small changes in libs, but for the moment I have to check/think few things for the listenmode to have everything well packaged with mysensors..not finished yet.
have you tested the code enough to release it for our use and testing??
no, not yet. sorry for delay. I have no time actually..and I think perhaps lowpowerlab team is preparing few changes in their lib. so I am delaying a bit to finish other things in the mean time, and to see if they add new features. then, if nothing new, I will finish this if someone didn't beat me on this
but I will try to do my best
I have it working to some extent, send me what you have and I will add your changes to what I've done to make sure I did not miss anything...
Then I will post the changes to the development branch
tom --at-- lafleur --.-- us