<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LoRaWAN &#8211; Wayne Connor</title>
	<atom:link href="https://wayneconnor.com/category/lorawan/feed" rel="self" type="application/rss+xml" />
	<link>https://wayneconnor.com</link>
	<description>My life scattered around the web - family, technology, church - a bit of everything.</description>
	<lastBuildDate>Thu, 17 Oct 2024 03:49:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">104631517</site>	<item>
		<title>How to set up an alert</title>
		<link>https://wayneconnor.com/lorawan/how-to-set-up-an-alert.html</link>
					<comments>https://wayneconnor.com/lorawan/how-to-set-up-an-alert.html#respond</comments>
		
		<dc:creator><![CDATA[Wayne]]></dc:creator>
		<pubDate>Thu, 17 Oct 2024 03:49:52 +0000</pubDate>
				<category><![CDATA[LoRaWAN]]></category>
		<guid isPermaLink="false">https://wayneconnor.com/?p=1629</guid>

					<description><![CDATA[I wanted Home assistant to alert my phone of the Main water tank has a leak. (Is emptying too fast for longer than 1/2 hr)]]></description>
										<content:encoded><![CDATA[
<p>I wanted Home assistant to alert my phone of the Main water tank has a leak. (Is emptying too fast for longer than 1/2 hr)</p>



<p></p>



<h2 class="wp-block-heading">Monitor Flow Rate</h2>



<p>Need to monitor flow rate. </p>



<p>Go to Settings: Devices and Services then Helpers</p>



<p> Click on + Create Helper </p>



<p>Select Derivative</p>



<p>Choose your tank level as the sensor, then select the time duration.</p>



<p>The Helper will use calculate to give hte derivative of the sensor (turn the absolute level into a flow rate).</p>



<figure class="wp-block-image size-full"><a href="https://i0.wp.com/wayneconnor.com/wp-content/uploads/2024/10/Screenshot-2024-10-17-at-2.46.01%E2%80%AFpm.png?ssl=1"><img data-recalc-dims="1" fetchpriority="high" decoding="async" width="628" height="616" src="https://i0.wp.com/wayneconnor.com/wp-content/uploads/2024/10/Screenshot-2024-10-17-at-2.46.01%E2%80%AFpm.png?resize=628%2C616&#038;ssl=1" alt="" class="wp-image-1630" srcset="https://i0.wp.com/wayneconnor.com/wp-content/uploads/2024/10/Screenshot-2024-10-17-at-2.46.01%E2%80%AFpm.png?w=628&amp;ssl=1 628w, https://i0.wp.com/wayneconnor.com/wp-content/uploads/2024/10/Screenshot-2024-10-17-at-2.46.01%E2%80%AFpm.png?resize=300%2C294&amp;ssl=1 300w" sizes="(max-width: 628px) 100vw, 628px" /></a></figure>



<p></p>



<h2 class="wp-block-heading">Watch the flow rate to determine normal values</h2>



<p>Create a card in your dashboard and watch the flow rate for a few days. <br>You will be able to see what the flow rate normally is.</p>



<h2 class="wp-block-heading">Create an Automation to detect large values</h2>



<p>Create an automatic that says When flow rate is below &#8216;xxx&#8217; warn me.</p>



<p>For me it was when dam tank derivative is below -0.18 send a notification via mobile_app_wayne with message &#8220;Dam tank is flowing fast&#8221;</p>



<ol class="wp-block-list"></ol>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://wayneconnor.com/lorawan/how-to-set-up-an-alert.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1629</post-id>	</item>
		<item>
		<title>How to add a new LoRaWAN end device in Node-RED in Home Assistant</title>
		<link>https://wayneconnor.com/lorawan/how-to-add-a-new-end-device-in-node-red-in-home-assistant.html</link>
					<comments>https://wayneconnor.com/lorawan/how-to-add-a-new-end-device-in-node-red-in-home-assistant.html#respond</comments>
		
		<dc:creator><![CDATA[Wayne]]></dc:creator>
		<pubDate>Fri, 12 Jan 2024 02:36:25 +0000</pubDate>
				<category><![CDATA[LoRaWAN]]></category>
		<guid isPermaLink="false">https://wayneconnor.com/?p=1562</guid>

					<description><![CDATA[Here is the flow of data: All these elements need to be installed into Home Assistant. The RAK gateway forwards nicely to Home Assistant. It&#8217;s a WISgate RAK7268V2 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p></p>



<p>Here is the flow of data: </p>



<ol class="wp-block-list">
<li>End Device (dragino temp sensor) </li>



<li>RAK LoRaWAN gateway </li>



<li>RAK MQTT packet forwarder </li>



<li>HA MQTT broker</li>



<li>Node-RED MQTT topic listener</li>



<li>Nore-RED fPort filter</li>



<li>Node-RED function to decode payload </li>



<li>Node-RED sensor entity </li>



<li> HA dashboard</li>
</ol>



<p>All these elements need to be installed into Home Assistant. </p>



<p>The RAK gateway forwards nicely to Home Assistant. It&#8217;s a WISgate RAK7268V2 </p>



<p>I started with a Milesight gateway and could not get it to forward vie MQTT to Home Assistant.</p>



<p></p>



<p>Here are the videos explaining how:</p>



<p><a href="https://youtube.com/shorts/jk0A3mvTW9Y" target="_blank" rel="noopener">How to add a LoRaWAN end device to Home Assistant &#8211; Part 1</a></p>



<p><a href="https://youtu.be/TYHyDfo_69E" target="_blank" rel="noopener">Part 2 &#8211; add the end device to the RAK</a></p>



<p><a href="https://youtube.com/shorts/ZTNerH4AKb0" target="_blank" rel="noopener">Part 3 &#8211; send a packet form the end device</a></p>



<p><a href="https://youtu.be/Wl6Ofg88jr4" target="_blank" rel="noopener">Part 4 &#8211; listening to the MQTT message</a></p>



<p><a href="https://youtu.be/YgrstJnClFQ" target="_blank" rel="noopener">Part 5 &#8211; setting the the decoder payload</a></p>



<p><a href="https://youtu.be/Iy6k_5uM1IU" target="_blank" rel="noopener">Part 6 &#8211; creating a sensor entity</a> (note this one has an error that is resolved in the next video!)</p>



<p><a href="https://youtu.be/TA3ysffn64I" target="_blank" rel="noopener">Part 7 Adding your device to the dashboard</a></p>



<p></p>



<p>Here&#8217;s the first one:</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe class="youtube-player" width="790" height="445" src="https://www.youtube.com/embed/jk0A3mvTW9Y?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=en-US&#038;autohide=2&#038;wmode=transparent" allowfullscreen="true" style="border:0;" sandbox="allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox"></iframe>
</div></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://wayneconnor.com/lorawan/how-to-add-a-new-end-device-in-node-red-in-home-assistant.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1562</post-id>	</item>
		<item>
		<title>Understanding LoRaWAN payloads</title>
		<link>https://wayneconnor.com/lorawan/understanding-lorawan-payloads.html</link>
					<comments>https://wayneconnor.com/lorawan/understanding-lorawan-payloads.html#respond</comments>
		
		<dc:creator><![CDATA[Wayne]]></dc:creator>
		<pubDate>Sat, 28 Oct 2023 01:18:11 +0000</pubDate>
				<category><![CDATA[LoRaWAN]]></category>
		<guid isPermaLink="false">https://wayneconnor.com/?p=1544</guid>

					<description><![CDATA[I have a Dragino Water Pressure meter and the depth values didn&#8217;t seem to be updating. So I was trying to work out which numbers in the raw [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>I have a Dragino Water Pressure meter and the depth values didn&#8217;t seem to be updating. So I was trying to work out which numbers in the raw payload data represented the mA readings of the meter. It turns out the data is encrypted. So you cannot manually extract the payload data you need to have it decrypted by your gateway.</p>



<p>See these:</p>



<p>ASCII payload              HEX payload                                       mA reading</p>



<p>DMYAACArAAAA      44 4D 59 41 41 43 41 72 41 41 41 41    8.23   </p>



<p>DMYAAB0RAAAA      44 4D 59 41 41 42 30 52 41 41 41 41   7.44</p>



<p>DMYAABnOAAAA      44 4D 59 41 41 42 6E 4F 41 41 41 41  6.06</p>



<p>DMYAABYvAAAA       44 4D 59 41 41 42 59 76 41 41 41 41   5.67</p>



<p>DMYAABKWAAAA     44 4D 59 41 41 42 4B 57 41 41 41 41  4.75</p>



<p>The mA readings have no obvious correlation to the payloads as the payloads are encrypted.</p>



<p></p>



<p></p>



<p> </p>



<p></p>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://wayneconnor.com/lorawan/understanding-lorawan-payloads.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1544</post-id>	</item>
		<item>
		<title>LoRaWAN dragino Pressure sensor payload for datacake PS-LB</title>
		<link>https://wayneconnor.com/lorawan/lorawan-dragino-pressure-sensor-payload-for-datacake-ps-lb.html</link>
					<comments>https://wayneconnor.com/lorawan/lorawan-dragino-pressure-sensor-payload-for-datacake-ps-lb.html#comments</comments>
		
		<dc:creator><![CDATA[Wayne]]></dc:creator>
		<pubDate>Wed, 25 Oct 2023 05:49:01 +0000</pubDate>
				<category><![CDATA[LoRaWAN]]></category>
		<guid isPermaLink="false">https://wayneconnor.com/?p=1513</guid>

					<description><![CDATA[I ordered one of these: It&#8217;s a 5m depth water sensor. PS-LB Dragino Depth Formula There&#8217;s a formula in the payload decoder to convert the mA to water [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p></p>



<p>I ordered one of these:</p>



<figure class="wp-block-image size-full is-resized"><a href="https://i0.wp.com/kee.vvw.mybluehost.me/wayneconnor/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-4.48.15-pm.png" target="_blank" rel="noopener"><img data-recalc-dims="1" decoding="async" width="553" height="552" src="https://i0.wp.com/kee.vvw.mybluehost.me/wayneconnor/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-4.48.15-pm.png?resize=553%2C552" alt="" class="wp-image-1514" style="aspect-ratio:1;width:348px;height:auto" srcset="https://i0.wp.com/wayneconnor.com/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-4.48.15-pm.png?w=553&amp;ssl=1 553w, https://i0.wp.com/wayneconnor.com/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-4.48.15-pm.png?resize=300%2C300&amp;ssl=1 300w, https://i0.wp.com/wayneconnor.com/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-4.48.15-pm.png?resize=150%2C150&amp;ssl=1 150w" sizes="(max-width: 553px) 100vw, 553px" /></a></figure>



<p>It&#8217;s a 5m depth water sensor.</p>



<p><a href="https://www.aliexpress.com/item/1005005658072312.html?spm=a2g0o.order_list.order_list_main.5.342918027eNnN7" target="_blank" rel="noopener">PS-LB Dragino</a></p>



<h2 class="wp-block-heading">Depth Formula</h2>



<p>There&#8217;s a formula in the payload decoder to convert the mA to water depth:</p>



<p>(((decode.IDC_input_mA-4.0)<em>(bytes[3]</em>100/16)).toFixed(3));</p>



<p>Byte[3] of my dragino was returning 65, which is what it would be for a 5m sensor. </p>



<p>But mine must have a 4m sensor on it, because hte levels are out by 80%</p>



<p> I changed the 65 to 52 and it&#8217;s more accurate now.</p>



<p>The formula for the 5m sensor is:</p>



<p>depth = 65 x 100 /16 x (mA -4) </p>



<p>A 20ma reading would lead to 6.5m  ( I guess the 5m sensor doesn&#8217;t go above 15.4mA)</p>



<p>Here&#8217;s the formulas I calculated for various probes to convert from mA to the depth</p>



<p><strong>depth(mm) = 130 x probe length x (mA &#8211; 4)/16</strong></p>



<p>5m probe depth =  5 x 130 x (mA-4)/16 </p>



<p>Which is 650/16 x (mA-4)</p>



<p>4m probe = 520/16 x (mA-4)</p>



<p>2m probe = 260/16 x (mA-4)</p>



<p>1m probe = 130/16 x (mA-4)</p>



<p></p>



<h2 class="wp-block-heading">Payload Decoder</h2>



<p>If you have a dragino PS-LB  and you want it to work in Things network you need to put this formula into the payload code. </p>



<p>The default payload code  tries to work out the probe type (3m, 5m, etc) and use a multiplier but i found in TNN it was not reading the multiplier properly.</p>



<p>Mine was reading the multiplier as 65 but that&#8217;s the multiplier for the 5m version! </p>



<p>I multiplied the reading manually, so I needed to change this line :    </p>



<p>decode.Water_deep_cm= parseFloat(((decode.IDC_input_mA-4.0)*(bytes[3]*100/16)).toFixed(3));</p>



<p>to</p>



<p>decode.Water_deep_cm= parseFloat(((decode.IDC_input_mA-4.0)*(65*100/16)).toFixed(3));</p>



<p>Here&#8217;s the new code:</p>



<h2 class="wp-block-heading"><strong>PS-LB pressure sensor with 5m sensor, TNN Payload Decoder</strong></h2>



<pre class="wp-block-code"><code>function datalog(i,bytes){
  var aa= parseFloat((bytes&#91;2+i]&lt;&lt;8 | bytes&#91;2+i+1])/1000).toFixed(3); 
  var string='&#91;'+ aa +']'+',';  
  return string;
}

function Decoder(bytes, port) {
  if(port==5)
  {
  	var freq_band;
  	var sub_band;
    var sensor;
    
    if(bytes&#91;0]==0x16)
      sensor= "PS-LB";
      
	  var firm_ver= (bytes&#91;1]&amp;0x0f)+'.'+(bytes&#91;2]&gt;&gt;4&amp;0x0f)+'.'+(bytes&#91;2]&amp;0x0f);
	  
    if(bytes&#91;3]==0x01)
        freq_band="EU868";
  	else if(bytes&#91;3]==0x02)
        freq_band="US915";
  	else if(bytes&#91;3]==0x03)
        freq_band="IN865";
  	else if(bytes&#91;3]==0x04)
        freq_band="AU915";
  	else if(bytes&#91;3]==0x05)
        freq_band="KZ865";
  	else if(bytes&#91;3]==0x06)
        freq_band="RU864";
  	else if(bytes&#91;3]==0x07)
        freq_band="AS923";
  	else if(bytes&#91;3]==0x08)
        freq_band="AS923_1";
  	else if(bytes&#91;3]==0x09)
        freq_band="AS923_2";
  	else if(bytes&#91;3]==0x0A)
        freq_band="AS923_3";
  	else if(bytes&#91;3]==0x0F)
        freq_band="AS923_4";
  	else if(bytes&#91;3]==0x0B)
        freq_band="CN470";
  	else if(bytes&#91;3]==0x0C)
        freq_band="EU433";
  	else if(bytes&#91;3]==0x0D)
        freq_band="KR920";
  	else if(bytes&#91;3]==0x0E)
        freq_band="MA869";
  	
    if(bytes&#91;4]==0xff)
      sub_band="NULL";
	  else
      sub_band=bytes&#91;4];

    var bat= (bytes&#91;5]&lt;&lt;8 | bytes&#91;6])/1000;
    
  	return {
  	  SENSOR_MODEL:sensor,
      FIRMWARE_VERSION:firm_ver,
      FREQUENCY_BAND:freq_band,
      SUB_BAND:sub_band,
      BAT:bat,
  	};
  }
  else if(port==7)
  {
    var Bat= (bytes&#91;0]&lt;&lt;8 | bytes&#91;1])/1000;
    for(var i=0;i&lt;bytes.length-2;i=i+2)
    {
      var data= datalog(i,bytes);
      if(i=='0')
        data_sum=data;
      else
        data_sum+=data;
    }
    return{
    Bat_V:Bat,
    DATALOG:data_sum
    };    
  }
  else
  {
    var decode={};
    decode.Bat_V= (bytes&#91;0]&lt;&lt;8 | bytes&#91;1])/1000;
    decode.Probe_mod= bytes&#91;2];   
    decode.IDC_input_mA= (bytes&#91;4]&lt;&lt;8 | bytes&#91;5])/1000;  
    decode.VDC_intput_V= (bytes&#91;6]&lt;&lt;8 | bytes&#91;7])/1000; 
    decode.IN1_pin_level= (bytes&#91;8] &amp; 0x08)? "High":"Low";   
    decode.IN2_pin_level= (bytes&#91;8] &amp; 0x04)? "High":"Low";   
    decode.Exti_pin_level= (bytes&#91;8] &amp; 0x02)? "High":"Low";  
    decode.Exti_status= (bytes&#91;8] &amp; 0x01)? "True":"False";
    

        decode.Water_deep_cm= parseFloat(((decode.IDC_input_mA-4.0)*(65*100/16)).toFixed(3));

    
    if(bytes.length!=1)
    {
      return decode;
    }
  }
}</code></pre>



<p></p>



<p></p>



<p></p>



<p></p>



<p>If you want to use this in datacake it needs to be modified to this:</p>



<h2 class="wp-block-heading"><strong>PS-LB pressure sensor with 5m sensor, Datacake Payload Decoder</strong></h2>



<p></p>



<pre class="wp-block-code"><code>function decodeUplink(input) {
        return { 
            data: Decode(input.fPort, input.bytes, input.variables)
        };   
}
function datalog(i,bytes){
  var aa= parseFloat((bytes&#91;2+i]&lt;&lt;8 | bytes&#91;2+i+1])/1000).toFixed(3); 
  var string='&#91;'+ aa +']'+',';  
  return string;
}

function Decoder(bytes, fPort) {
    
      // Output raw payload coming from webhook of your LNS
  //  console.log(JSON.stringify(rawPayload,0,4));    
    
    
    
  if(fPort==5)
  {
  	var freq_band;
  	var sub_band;
    var sensor;
    
    if(bytes&#91;0]==0x16)
      sensor= "PS-LB";
      
	  var firm_ver= (bytes&#91;1]&amp;0x0f)+'.'+(bytes&#91;2]&gt;&gt;4&amp;0x0f)+'.'+(bytes&#91;2]&amp;0x0f);
	  
    if(bytes&#91;3]==0x01)
        freq_band="EU868";
  	else if(bytes&#91;3]==0x02)
        freq_band="US915";
  	else if(bytes&#91;3]==0x03)
        freq_band="IN865";
  	else if(bytes&#91;3]==0x04)
        freq_band="AU915";
  	else if(bytes&#91;3]==0x05)
        freq_band="KZ865";
  	else if(bytes&#91;3]==0x06)
        freq_band="RU864";
  	else if(bytes&#91;3]==0x07)
        freq_band="AS923";
  	else if(bytes&#91;3]==0x08)
        freq_band="AS923_1";
  	else if(bytes&#91;3]==0x09)
        freq_band="AS923_2";
  	else if(bytes&#91;3]==0x0A)
        freq_band="AS923_3";
  	else if(bytes&#91;3]==0x0F)
        freq_band="AS923_4";
  	else if(bytes&#91;3]==0x0B)
        freq_band="CN470";
  	else if(bytes&#91;3]==0x0C)
        freq_band="EU433";
  	else if(bytes&#91;3]==0x0D)
        freq_band="KR920";
  	else if(bytes&#91;3]==0x0E)
        freq_band="MA869";
  	
    if(bytes&#91;4]==0xff)
      sub_band="NULL";
	  else
      sub_band=bytes&#91;4];

    var bat= (bytes&#91;5]&lt;&lt;8 | bytes&#91;6])/1000;
    
  	return {
  	  SENSOR_MODEL:sensor,
      FIRMWARE_VERSION:firm_ver,
      FREQUENCY_BAND:freq_band,
      SUB_BAND:sub_band,
      BAT:bat,
  	};
  }
  else if(fPort==7)
  {
    var Bat= (bytes&#91;0]&lt;&lt;8 | bytes&#91;1])/1000;
    for(var i=0;i&lt;bytes.length-2;i=i+2)
    {
      var data= datalog(i,bytes);
      if(i=='0')
        data_sum=data;
      else
        data_sum+=data;
    }
    return{
    Bat_V:Bat,
    DATALOG:data_sum
    };    
  }
  else
  {
    var decode={};
    decode.Bat_V= (bytes&#91;0]&lt;&lt;8 | bytes&#91;1])/1000;
    decode.Probe_mod= bytes&#91;2];   
    decode.IDC_intput_mA= (bytes&#91;4]&lt;&lt;8 | bytes&#91;5])/1000;  
    decode.VDC_intput_V= (bytes&#91;6]&lt;&lt;8 | bytes&#91;7])/1000; 
    decode.IN1_pin_level= (bytes&#91;8] &amp; 0x08)? "High":"Low";   
    decode.IN2_pin_level= (bytes&#91;8] &amp; 0x04)? "High":"Low";   
    decode.Exti_pin_level= (bytes&#91;8] &amp; 0x02)? "High":"Low";  
    decode.Exti_status= (bytes&#91;8] &amp; 0x01)? "True":"False";
    
    decode.probe_multiplier = bytes&#91;3];
    decode.Water_deep_cm= parseFloat(((decode.IDC_intput_mA-4.0)*(65*10/16)).toFixed(3));
   
    if(bytes.length!=1)
    {
      // Array where we store the fields that are being sent to Datacake
    var datacakeFields = &#91;]
    
    // take each field from decodedElsysFields and convert them to Datacake format
    for (var key in decode) {
        if (decode.hasOwnProperty(key)) {           
            datacakeFields.push({field: key.toUpperCase(), value: decode&#91;key]})
        }
    }      
    
    // forward data to Datacake
    return datacakeFields;
    }
  }
}</code></pre>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://wayneconnor.com/lorawan/lorawan-dragino-pressure-sensor-payload-for-datacake-ps-lb.html/feed</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1513</post-id>	</item>
	</channel>
</rss>
