Qgelm

RFM12B library | LowPowerLab

Originalartikel

Backup

<html> <p>I&#8217;ve been using the RF12 library from Jeelabs for some time for my Moteino testing. This worked just fine and it was a great starting point. However some things were really confusing and I spent a lot of time redoing the same thing over and over again (eg. copy paste from known working code) just because there was a lot of code-overhead to do simple things like sending, receiving, and ACK management, and of course I couldn&#8217;t remember any of the functions or macros. Right from start, the need emerged to tweak it into a more flexible and more configurable library, so I kept hacking and modding it until it dawned on me&#8230; a new library had to be born. So I decided to completely rewrite it, and wrap the useful functionality in a dedicated C++ class. I modified some of the core features of the Jeelabs version, like adding another header byte to allow 7-bit source <em><strong>and</strong></em> destination addresses (Jeelabs only supports either source or destination in an attempt to save 1 byte), and allow low level configuration of the radio. This yielded a clean and easy to use, yet powerful library (at least it made my life easy). Here&#8217;s a summary:</p><ul><li>easy API with a few simple functions for basic usage</li><li>127 possible nodes on 256 possible networks</li><li>66&#160;128 bytes max message length</li><li>customizable transmit power (8 levels) for low-power transmission control</li><li>customizable air-Kbps rate allows fine tuning the transmission reliability vs speed (transmitting slower is more reliable but takes more time which implies more power usage)</li><li>Sleep/Wakeup functionality for power saving</li><li>Low battery detector with customizable low voltage threshold</li><li>Interrupt driven</li><li>Support for targeted ACK instead of broadcasted ACK (possible because of the new source byte in the header)</li><li>encryption with XXTEA algorithm by David Wheeler, adapted from&#160;<a href=„http://en.wikipedia.org/wiki/XXTEA“>http://en.wikipedia.org/wiki/XXTEA</a></li><li>Support for these chips: ATMega8 family (ATmega168, ATMega328) ATMega2560, ATMega1280, ATMega644P, ATTiny84, ATTiny44, ATMega32u4. So far only tested on ATMega 328/P</li><li><em><strong>The source code and examples are on GitHub:</strong></em>&#160;<a href=„https://github.com/LowPowerLab/RFM12B“ target=„_blank“>RFM12 Library</a></li></ul><p>I did some basic testing of the most common features. I&#8217;m posting this in hope that others will find it useful, start using it and provide some feedback. This code is also part of an effort to promote the <a title=„Moteino &#8211; the wireless low power low cost arduino clone“ href=„http://lowpowerlab.com/blog/2012/12/20/moteino-the-wireless-low-power-low-cost-arduino-clone/“ target=„_blank“>Moteino wireless arduino clone</a> and make it an ubiquitous platform for building very low cost <a href=„http://en.wikipedia.org/wiki/Internet_of_Things“ target=„_blank“>internet of things</a>.</p><p>Here is the packet structure for those interested:<a href=„http://lowpowerlab.com/wp-content/uploads/2012/12/RFM12B_PacketStruct.png“><img class=„aligncenter size-full wp-image-249“ alt=„RFM12B_PacketStruct“ src=„http://lowpowerlab.com/wp-content/uploads/2012/12/RFM12B_PacketStruct.png“ width=„996“ height=„187“ srcset=„https://lowpowerlab.com/wp-content/uploads/2012/12/RFM12B_PacketStruct.png 996w, https://lowpowerlab.com/wp-content/uploads/2012/12/RFM12B_PacketStruct-300x56.png 300w, https://lowpowerlab.com/wp-content/uploads/2012/12/RFM12B_PacketStruct-500x93.png 500w“ sizes=„(max-width: 996px) 100vw, 996px“/></a>The CTL bit in the first header byte is set to 1 when the received packet represents an ACK.&#160;The ACK bit in the second header byte is set to 1 when a sender is requesting an ACK to the current packet. &#160;<strong>NOTE:</strong>&#160;these bits are mutually exclusive (only either one can be set at one time), and an ACK packet can contain as much data as a normal packet &#8211; this would be useful in instances where the sent data is sent back with an ACK to be verified (even though the CRC check of each message will be an almost 100% guarantee of data integrity).</p><p>Here are diagrams for connecting the RFM12B transceiver radio to 3.3V or 5V Arduino clones nased on ATMega168/328:<a href=„http://lowpowerlab.com/wp-content/uploads/2012/12/rfm12B-arduino-moteino-atmega328_3.3v_connections.png“><img class=„aligncenter size-full wp-image-251“ alt=„rfm12B–arduino-moteino-atmega328_3.3v_connections“ src=„http://lowpowerlab.com/wp-content/uploads/2012/12/rfm12B-arduino-moteino-atmega328_3.3v_connections.png“ width=„1072“ height=„761“ srcset=„https://lowpowerlab.com/wp-content/uploads/2012/12/rfm12B-arduino-moteino-atmega328_3.3v_connections.png 1072w, https://lowpowerlab.com/wp-content/uploads/2012/12/rfm12B-arduino-moteino-atmega328_3.3v_connections-300x212.png 300w, https://lowpowerlab.com/wp-content/uploads/2012/12/rfm12B-arduino-moteino-atmega328_3.3v_connections-1024x726.png 1024w, https://lowpowerlab.com/wp-content/uploads/2012/12/rfm12B-arduino-moteino-atmega328_3.3v_connections-422x300.png 422w“ sizes=„(max-width: 1072px) 100vw, 1072px“/></a> <a href=„http://lowpowerlab.com/wp-content/uploads/2012/12/rfm12B-arduino-moteino-atmega328_5V_connections.png“><img class=„aligncenter size-full wp-image-252“ alt=„rfm12B–arduino-moteino-atmega328_5V_connections“ src=„http://lowpowerlab.com/wp-content/uploads/2012/12/rfm12B-arduino-moteino-atmega328_5V_connections.png“ width=„986“ height=„709“ srcset=„https://lowpowerlab.com/wp-content/uploads/2012/12/rfm12B-arduino-moteino-atmega328_5V_connections.png 986w, https://lowpowerlab.com/wp-content/uploads/2012/12/rfm12B-arduino-moteino-atmega328_5V_connections-300x215.png 300w, https://lowpowerlab.com/wp-content/uploads/2012/12/rfm12B-arduino-moteino-atmega328_5V_connections-417x300.png 417w“ sizes=„(max-width: 986px) 100vw, 986px“/></a></p> </html>

Cookies helfen bei der Bereitstellung von Inhalten. Diese Website verwendet Cookies. Mit der Nutzung der Website erklären Sie sich damit einverstanden, dass Cookies auf Ihrem Computer gespeichert werden. Außerdem bestätigen Sie, dass Sie unsere Datenschutzerklärung gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website.Weitere Information