{"id":477,"date":"2014-02-08T22:12:33","date_gmt":"2014-02-08T22:12:33","guid":{"rendered":"http:\/\/www.oaktreelabs.co.uk\/blog\/?p=477"},"modified":"2014-10-18T14:50:25","modified_gmt":"2014-10-18T14:50:25","slug":"a-denser-llap-serial-rf-data-format","status":"publish","type":"post","link":"https:\/\/www.richardmudhar.com\/blog\/2014\/02\/a-denser-llap-serial-rf-data-format\/","title":{"rendered":"A denser LLAP serial RF data format"},"content":{"rendered":"<p>Ciseco&#8217;s <a title=\"LLAP format as documented here\" href=\"http:\/\/openmicros.org\/index.php\/articles\/85-llap-lightweight-local-automation-protocol\/297-llap-reference\" target=\"_blank\">LLAP format<\/a> is a nice lightweight and PIC microcontroller and Arduino friendly serial protocol. I use their XRF modules for RF communication, these support power-down so they are well-suited to intermittent operation off a battery. Standing current on receive is 23mA so continuous operation is more of a challenge, for instance at the RF to SMS gateway. It has 12 bytes like so:<\/p>\n<h4>LLAP Message format<\/h4>\n<p>Each message is exactly 12 characters long and in three distinct sections:<\/p>\n<ul>\n<li>One start byte<\/li>\n<li>Two bytes for the device identifier<\/li>\n<li>Nine data bytes, padded by dashes if necessary.<\/li>\n<\/ul>\n<p>&lt;SB&gt; &lt;ID&gt; &lt;ID&gt; &lt;D&gt; &lt;D&gt; &lt;D&gt; &lt;D&gt; &lt;D&gt; &lt;D&gt; &lt;D&gt; &lt;D&gt; &lt;D&gt;<\/p>\n<p>See <a href=\"http:\/\/openmicros.org\/index.php\/articles\/85-llap-lightweight-local-automation-protocol\/297-llap-reference#Permissible%20LLAP%20message%20characters\" target=\"_blank\">Appendix 3<\/a> for details of the permissible characters in each field.<\/p>\n<p>Their examples, however, send only one data value per LLAP message, with a descriptive section. Hence<\/p>\n<p>aAATMPA12345<\/p>\n<p>Which is wasteful IMO. A lot of sensors have two data points,for instance temperature difference measurements, or temperature and relative humidity.<\/p>\n<p>Few real world sensors\u00a0 can justify the precision of using all the digits; I don&#8217;t have any with an accuracy of more than three digits. Sensing temperature to an accuracy of 0.1C is unusual &#8211; the popular dalas 18B20 is accurate to 0.5C but to do much more implies a piece of laboratory equipment. Useful values of temperature in the UK would be -20 to 120 \u00b0C, Relative humidity is 0 to 100 &#8211; cheap sensors don&#8217;t really justify a .x so allocating four digits covers most bases. Negative values give the ugly -21. as the &#8211; takes up a digit but it&#8217;s only a machine that sees it. So I can make a double density device as<\/p>\n<p>aAA12.34X5.67<\/p>\n<p>and keep within the spec. I use **** for failed or missing sensors, and the X is replaced by L,M or H for battery status. M and H are operational, L means may be about to switch off in a few cycles. In sensors that support H then M means would still accept charge, H is enough. However I use a simple comparator at about 4.4 V on a PIC 16F628 so I can only show L and M.<\/p>\n<p>This saves me precious power, and allows me to consolidate two temperature sensors to one radio saving cost of the radio and aggravation of maintaining batteries.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_484\" aria-describedby=\"caption-attachment-484\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.richardmudhar.com\/blog\/wp-content\/uploads\/2014\/02\/140208_sensor_DSCN2349.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"wp-image-484 size-medium\" src=\"https:\/\/i0.wp.com\/www.richardmudhar.com\/blog\/wp-content\/uploads\/2014\/02\/140208_sensor_DSCN2349-300x225.jpg?resize=300%2C225\" alt=\"two-sensor PIC and XRF device\" width=\"300\" height=\"225\" srcset=\"https:\/\/i0.wp.com\/www.richardmudhar.com\/blog\/wp-content\/uploads\/2014\/02\/140208_sensor_DSCN2349.jpg?resize=300%2C225&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.richardmudhar.com\/blog\/wp-content\/uploads\/2014\/02\/140208_sensor_DSCN2349.jpg?resize=624%2C468&amp;ssl=1 624w, https:\/\/i0.wp.com\/www.richardmudhar.com\/blog\/wp-content\/uploads\/2014\/02\/140208_sensor_DSCN2349.jpg?w=1024&amp;ssl=1 1024w\" sizes=\"auto, (max-width: 300px) 85vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-484\" class=\"wp-caption-text\">two-sensor PIC and XRF device<\/figcaption><\/figure>\n<p>I couldn&#8217;t use JAL for this because I laid out the board to use the 16F628&#8217;s internal oscillator that runs at 4MHz and the <a title=\"JAL one-wire lib\" href=\"https:\/\/code.google.com\/p\/jallib\/source\/browse\/trunk\/include\/external\/one_wire\/one_wire.jal?r=2428\" target=\"_blank\">JAL one-wire lib<\/a> wants to run at 20MHz. So I had to code it in assembler \ud83d\ude41 Next time I&#8217;ll leave space for a 20MHz resonator on the board that will save me all that grief.<\/p>\n<p>I now get to read two temp sensor and the battery status, all in one LLAP message \ud83d\ude42<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ciseco&#8217;s LLAP format is a nice lightweight and PIC microcontroller and Arduino friendly serial protocol. I use their XRF modules for RF communication, these support power-down so they are well-suited to intermittent operation off a battery. Standing current on receive is 23mA so continuous operation is more of a challenge, for instance at the RF &hellip; <a href=\"https:\/\/www.richardmudhar.com\/blog\/2014\/02\/a-denser-llap-serial-rf-data-format\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;A denser LLAP serial RF data format&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[275,13],"tags":[263,7],"class_list":["post-477","post","type-post","status-publish","format-standard","hentry","category-greenmantle","category-sensors","tag-llap","tag-pic-micro"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5aOO7-7H","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/posts\/477","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/comments?post=477"}],"version-history":[{"count":1,"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/posts\/477\/revisions"}],"predecessor-version":[{"id":1426,"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/posts\/477\/revisions\/1426"}],"wp:attachment":[{"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/media?parent=477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/categories?post=477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.richardmudhar.com\/blog\/wp-json\/wp\/v2\/tags?post=477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}