<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[DefProc Engineering]]></title><description><![CDATA[DefProc Engineering]]></description><link>https://foxtrot.defproc.co.uk/blog/</link><image><url>https://foxtrot.defproc.co.uk/blog/favicon.png</url><title>DefProc Engineering</title><link>https://foxtrot.defproc.co.uk/blog/</link></image><generator>Ghost 2.23</generator><lastBuildDate>Tue, 11 Nov 2025 23:09:37 GMT</lastBuildDate><atom:link href="https://foxtrot.defproc.co.uk/blog/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[HackSpace Magazine: Meet the Maker]]></title><description><![CDATA[<p>We recently had the pleasure of <a href="https://defproc.co.uk/blog/author/jen/">Jen</a> being in the 'Meet the Maker' article of <a href="https://hackspace.raspberrypi.org/">HackSpace</a> magazine, where everything from starting the business to the latest client work is covered. </p><p>We may be biased but it's certainly worth a read, so pickup the latest September copy of HackSpace to check</p>]]></description><link>https://foxtrot.defproc.co.uk/blog/hackspace-magazine-meet-the-maker/</link><guid isPermaLink="false">5d70fef7670f403ca366e3ed</guid><category><![CDATA[Update]]></category><dc:creator><![CDATA[Mike Bone]]></dc:creator><pubDate>Thu, 05 Sep 2019 16:01:45 GMT</pubDate><media:content url="https://foxtrot.defproc.co.uk/blog/content/images/2019/09/DSC_0456---Cropped--2-.jpg" medium="image"/><content:encoded><![CDATA[<img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/09/DSC_0456---Cropped--2-.jpg" alt="HackSpace Magazine: Meet the Maker"><p>We recently had the pleasure of <a href="https://defproc.co.uk/blog/author/jen/">Jen</a> being in the 'Meet the Maker' article of <a href="https://hackspace.raspberrypi.org/">HackSpace</a> magazine, where everything from starting the business to the latest client work is covered. </p><p>We may be biased but it's certainly worth a read, so pickup the latest September copy of HackSpace to check it out or alternatively <a href="https://hackspace.raspberrypi.org/features/meet-the-maker-jen-fenner">read it online</a>!</p><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/09/HS_22_Cover_Web.png" class="kg-image" alt="HackSpace Magazine: Meet the Maker"><figcaption>HackSpace - September 2019</figcaption></figure><!--kg-card-end: image-->]]></content:encoded></item><item><title><![CDATA[Labelin' made easy]]></title><description><![CDATA[<p>Recently at DefProc there's been a shift towards organising, a late 'spring clean' if you will. As more projects get taken on, more parts and bits appear around the office and there comes a point where you're hunting around for a particular thing and you realise that enough is enough!</p>]]></description><link>https://foxtrot.defproc.co.uk/blog/dymo-label-printer/</link><guid isPermaLink="false">5d4bf6cb670f403ca366e129</guid><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[Mike Bone]]></dc:creator><pubDate>Thu, 05 Sep 2019 12:24:52 GMT</pubDate><media:content url="https://foxtrot.defproc.co.uk/blog/content/images/2019/08/1287059218_634159.jpg" medium="image"/><content:encoded><![CDATA[<img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/08/1287059218_634159.jpg" alt="Labelin' made easy"><p>Recently at DefProc there's been a shift towards organising, a late 'spring clean' if you will. As more projects get taken on, more parts and bits appear around the office and there comes a point where you're hunting around for a particular thing and you realise that enough is enough! </p><p>So, with that in mind, <a href="https://www.defproc.co.uk/blog/author/alexandra/">Alex </a>and <a href="https://defproc.co.uk/blog/author/patrick/">Pat </a>set out to organise all the stock using <a href="https://partsbox.io/">partsbox.io</a>. For more information on how they went about it, a <a href="https://partsbox.io/blog/how-to-organize-electronic-parts-04-2017.html">handy guide from partsbox themselves</a> explains it perfectly. </p><p>Part of the new storage plan is labelling all the components with a custom printed label that contains the relevant information for us, including a QR code that when scanned responds with the partsbox URL for that particular part so you can immediately view all the information on it. The problem with this, and the Dymo label printer, is the software for it... isn't great. It's clunky to use and more importantly it's a hassle trying to get it to automate printing labels. Partsbox lets you download a CSV file containing all the information about the selected parts, so ideally we wanted a way to import the CSV and have the Dymo print out a label for each part, no fuss!</p><p>The software that comes with the printer does include a way to print from a CSV file, but it requires importing it and going through a wizard each time. By automating it we could save time on not selecting the correct paper-size and printer, going through a wizard and assigning data to label fields etc. </p><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/08/blog1.PNG" class="kg-image" alt="Labelin' made easy"><figcaption>Example of using the Dymo wizard to print from a CSV file</figcaption></figure><!--kg-card-end: image--><p>So lets discuss how we can automate our printing! Since August 2016, the Dymo Label Web Service is automatically installed along with the Dymo Label Software. Using this web service we can talk directly to the printer. </p><p>So first;</p><ul><li>Install the <a href="http://www.dymo.com/en-US/online-support/">Dymo Label Software and Dymo Label Web Service.</a></li><li>Save a copy of the <a href="http://labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.3.0.js">Dymo JavaScript Framework</a>. </li></ul><p>You can check if you have the web service correctly installed by following <a href="http://developers.dymo.com/2016/08/08/dymo-label-web-service-faq/">this blog post</a> from Dymo themselves. (Sadly this is for Mac and Windows only as Linux is not supported). </p><p>The SDK, SDK documentation and framework overview aren't great from Dymo and commonly are either outdated or don't work. The very few examples it gives for JavaScript aren't event complete. The one reference that does have some benefit is the <a href="http://labelwriter.com/software/dls/sdk/docs/DYMOLabelFrameworkJavaScriptHelp/index.html">documentation for the JavaScript framework</a> we downloaded. With that in mind, we should be able to get this printing. </p><p>The first step is we need a layout for the label. This is the only time we have to open up and use the included software. Well, it's not <em>required</em> but it is easier if you don't fancy writing out all the layout XML yourself. Opening the 'Dymo Label v.8' and selecting a label type / size, you're ready to add the components you need. </p><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/08/blog2.PNG" class="kg-image" alt="Labelin' made easy"><figcaption>Our label, including a barcode for the MPN and a QR code for the partsbox URL</figcaption></figure><!--kg-card-end: image--><p>One important step here is that each component of the label needs a reference name setting. This can usually be found by right clicking &gt; properties &gt; advanced. Here I would advise that you preface each of the reference names with a constant in case you need to search through the XML for adjustments. Additionally make a note of these as you'll need the reference names later. </p><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/08/blog3.PNG" class="kg-image" alt="Labelin' made easy"><figcaption>Setting the barcode reference name</figcaption></figure><!--kg-card-end: image--><p>After the layout is done save it somewhere safe so we can import it later and close down the Dymo software. From here we can start creating our process for printing the labels. As we're using the web service pack we're going to create a basic web page (styling can be saved for another day). On the page a user can import or drag a downloaded CSV file from partsbox and then upon clicking the print button the page prints a label for each part included in the CSV. No pop up menus, no selecting the right printer, no import wizards. Just plug and print!</p><p>Because the web page is talking to a locally plugged in printer, this won't work if hosted online (security issues). Instead I recommend having the web page hosted on GitLab and then if changes are made the user can pull the latest version before opening the page locally in their browser. </p><p>For the basic web page I created a single html file. At the top I imported B<a href="https://getbootstrap.com/">ootstrap</a> for some very quick and easy styling (optional) and then imported two JavaScript files, the first being the download Dymo framework from earlier and the second being a custom JavaScript file where we will write our code to tie it all together. </p><!--kg-card-begin: code--><pre><code class="language-html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;DefBox&lt;/title&gt;
    &lt;link rel="stylesheet" href="./assets/css/Bootstrap.min.css"&gt;

    &lt;script src="./assets/js/jquery-3.4.1.min.js" type="text/javascript" charset="UTF-8"&gt;&lt;/script&gt;
    &lt;script src="./assets/js/bootstrap.bundle.min.js" type="text/javascript" charset="UTF-8"&gt;&lt;/script&gt;
    &lt;script src="./assets/js/DYMO.Label.Framework.latest.js" type="text/javascript" charset="UTF-8"&gt;&lt;/script&gt;
    &lt;script src="./assets/js/defbox.js" type="text/javascript" charset="UTF-8"&gt;&lt;/script&gt;
  &lt;/head&gt;</code></pre><!--kg-card-end: code--><p>For the body, I used a <a href="https://getbootstrap.com/docs/4.3/components/jumbotron/">Jumbotron</a> from Bootstrap and after adding a title, subheading and logo it was mostly done in terms of layout and styling. I finished it off with a file input so we can get access to the CSV file with an id of <code>partsbox_csv_file</code> so we can access it later from the custom JavaScript, and a button with an on click call to <code>CheckEnv()</code>, our first function.</p><!--kg-card-begin: code--><pre><code class="language-html">  &lt;body&gt;
    &lt;div class="container"&gt;
      &lt;div class="jumbotron"&gt;
        &lt;div class="container"&gt;
          &lt;div class="row"&gt;
            &lt;div class="col-8"&gt;
                &lt;h1 class="display-4"&gt;DefBox&lt;/h1&gt;
                &lt;p class="lead"&gt;This is a basic web app to print downloaded parts data from partsbox.io as labels.&lt;/p&gt;
            &lt;/div&gt;
            &lt;div class="col-4"&gt;
                &lt;img class="img-fluid" src="assets/img/dpeLogoBlack.png"/&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;hr class="my-4"&gt;
        &lt;p&gt;Drag the downloaded csv data here or select it with choose file.&lt;/p&gt;
        &lt;input class="btn btn-primary btn-lg" type="file" name="file" id="partsbox_csv_file"/&gt;
      &lt;/div&gt;
      &lt;button type="button" class="btn btn-success btn-lg btn-block" onClick="CheckEnv()"&gt;Print Labels&lt;/button&gt;
    &lt;/div&gt;

    &lt;div class="upload fs-upload-element fs-upload fs-light"&gt;&lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;</code></pre><!--kg-card-end: code--><p>All of that gives us a simple but functional web page that does all we need it to.</p><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/08/blog4.PNG" class="kg-image" alt="Labelin' made easy"><figcaption>The basic web page for printing the labels</figcaption></figure><!--kg-card-end: image--><p>With the web page done, we need to do the behind the scenes code to actually parse the CSV and tell the printer to create a label. One of the first things is define a global variable <code>var df;</code>. This is so we can attribute <code>dymo.label.framework</code> to it, due to it being used frequently, so this saves time and formats the code nicely.</p><p>Then, as mentioned earlier, the first function we set up is <code>CheckEnv()</code>. Here we check that there's a printer connected otherwise throw an alert to the user (quick albeit alerts aren't the nicest UX). If everything is okay then call the next function to get the CSV file input. </p><!--kg-card-begin: code--><pre><code class="language-JavaScript">function CheckEnv() {
  df = dymo.label.framework;

  var printers = df.getPrinters();
  if (printers.length == 0) {
    alert("No DYMO printers are installed. Install DYMO printers.");
    return;
  }

  if (!printers[0].isConnected) {
    alert("DYMO printer is not connected.");
    return;
  }

  GetFileInput();
}</code></pre><!--kg-card-end: code--><p>The second <code>if</code> to check if the printer is connected (assuming there's only one printer connected which we do throughout) might seem redundant compared to the first check but, upon testing, <code>getPrinters()</code> will be successful after first time it runs even if you unplug the printer. Checking <code>isConnected</code> on the printer actively checks the connection. </p><p>For getting the file input we can use <a href="https://developer.mozilla.org/en-US/docs/Web/API/FileReader">FileReader</a>. We read the uploaded file name using the <code>partsbox_csv_file</code> id, pass it into a <code>FileReader</code>, and the determine two functions for it. One for successfully reading the file and one for it throwing an error. Finally we have to actively start reading the file to get one of these functions to fire.</p><!--kg-card-begin: code--><pre><code class="language-JavaScript">function GetFileInput() {
  // Read the 'uploaded' file name and pass into file reader
  var fileInput = document.getElementById("partsbox_csv_file").files[0];
  if (fileInput == undefined) {
    alert("No uploaded file detected.");
    return;
  }
  const reader = new FileReader();

  // Error function for reading the file
  reader.onerror = function(error) {
    console.log(error);
    alert("Error with uploaded file");
    return;
  };

  // Success function for reading the file
  reader.onload = function(event) {
    var csvString = event.target.result;
    var csvArray = ConvertCsvStringTo3dArray(csvString);
    GetDYMOPrinters(csvArray);
  };

  // Start reading the file
  reader.readAsText(fileInput);
}</code></pre><!--kg-card-end: code--><p>On success, due to reading the file input as a string, we need to convert the string to an array we can use. This function initially splits the string by each newline (as each line in the CSV represents the info on one part from partsbox) and adds it to an array <code>newLineArray</code>. Then for each line in the array it;</p><ul><li>Removes the quotes at the start &amp; end</li><li>Splits it by each section into an array using <code>split('","')</code></li><li>Pushes it to <code>csvArray</code></li></ul><p>Finally, we remove the first element in the array as this contains the CSV headers, which we don't want to print.</p><!--kg-card-begin: code--><pre><code class="language-JavaScript">function ConvertCsvStringTo3dArray(csvString) {
  // Split by newline to get each line of the csv in an array
  var newlineArray = csvString.split('\n');
  var csvArray = [];

  // Split each line into its individual components
  newlineArray.forEach(line =&gt; {
    if (line !== "") {
      // Remove the quotes on each end of the line
      contentLine = line.substring(1, line.length-1);
      splitLine = contentLine.split('","');
      csvArray.push(splitLine);
    }
  });

  // Remove the first line of csv headers
  csvArray.shift();
  return csvArray;
}</code></pre><!--kg-card-end: code--><p>From here we setup what we need to print the label. This includes getting the printer and loading the label XML (as .label format). Then for each line in the CSV array we call the <code>PrintLabel()</code> function. Here we replace the label components (using the reference name we setup on each component earlier) with our CSV data before then creating the print settings, and firing off <code>printLabel</code> to send it to the Dymo printer.</p><!--kg-card-begin: code--><pre><code class="language-JavaScript">function GetDYMOPrinters(csvArray) {
  // Get the first printer
  var printer = df.getPrinters()[0].modelName;

  // Load the label layout file
  var currentLoc = window.location.pathname;
  var currentDir = currentLoc.substring(0, currentLoc.lastIndexOf('/'));
  var labelDir = "/assets/layouts/LabelLayout.label";
  var labelUri = "file:///" + currentDir + labelDir;
  var label = df.openLabelFile(labelUri);

  // For each line in the csv, print a label
  csvArray.forEach(csvLine =&gt; {
    PrintLabel(label, csvLine, printer)
  });
}

function PrintLabel(label, labelInfo, printer) {
  // Replace the label objects with the CSV data
  // 0) Name 1) Description 2) Footprint 3) Manufacturer 4) MPN 5) Storage 6) Total Stock 7) URL 8) Meta-Parts
  console.log(labelInfo);
  label.setObjectText('PF_DESCRIPTION', labelInfo[1]);
  label.setObjectText('PF_MPN_BARCODE', labelInfo[4]);
  label.setObjectText('PF_PART_TITLE', labelInfo[0]);
  label.setObjectText('PF_MFN', labelInfo[3]);
  label.setObjectText('PF_LOCATION', labelInfo[5]);
  label.setObjectText('PF_QRCODE', labelInfo[7]);

  // Set the print options
  var labelXml = label.getLabelXml();
  var printQuality = df.LabelWriterPrintQuality.Auto;
  var paramsXml = df.createLabelWriterPrintParamsXml({ copies: 1, printQuality: printQuality});

  // Print
  df.printLabel(printer, paramsXml, labelXml);
}</code></pre><!--kg-card-end: code--><p>If this is all done successfully, you should get a printed label (or a few) when running through the web page!</p><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/08/blog5.jpg" class="kg-image" alt="Labelin' made easy"></figure><!--kg-card-end: image-->]]></content:encoded></item><item><title><![CDATA[Decoding Nerf Laser Ops]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Every so often, I try to do some <a href="https://foxtrot.defproc.co.uk/blog/tag/5-minute-projects/">short projects</a> that don't take too long, but let me learn something new. When the new Nerf Laser Ops range came out in September 2018, I had a pair of blasters on the first day — because they seemed to be using targeted</p>]]></description><link>https://foxtrot.defproc.co.uk/blog/decoding-nerf-laserops/</link><guid isPermaLink="false">5cd3ff41c3e3797874ba2c9d</guid><category><![CDATA[5 Minute Projects]]></category><category><![CDATA[Analysis]]></category><dc:creator><![CDATA[Patrick Fenner]]></dc:creator><pubDate>Thu, 03 Jan 2019 12:00:00 GMT</pubDate><media:content url="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/alphapoint-in-pieces-5.png" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/alphapoint-in-pieces-5.png" alt="Decoding Nerf Laser Ops"><p>Every so often, I try to do some <a href="https://foxtrot.defproc.co.uk/blog/tag/5-minute-projects/">short projects</a> that don't take too long, but let me learn something new. When the new Nerf Laser Ops range came out in September 2018, I had a pair of blasters on the first day — because they seemed to be using targeted infra-red signals and that looked very hackable.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/alphapoint-in-pieces-8.png" class="kg-image" alt="Decoding Nerf Laser Ops"><figcaption><em>The first thing to when you get a new device is take it apart!</em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>I had an <a href="https://learn.adafruit.com/introducing-circuit-playground/overview">Adafruit Circuit Playground Express</a> from some teaching classes that we'd been doing recently, and the onboard infra-red (IR) receiver and sender, plus the onboard RGB LEDs, looked like a nice way of duplicating the <a href="https://foxtrot.defproc.co.uk/blog/projects/made-invaders/">foam dart sensors</a> but this time, for the new IR blasters.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/MakeCPlay-2.png" class="kg-image" alt="Decoding Nerf Laser Ops"><figcaption><em><strong>Adafruit Circuit Playground Express in <a href="https://makecode.adafruit.com/">Makecode</a></strong></em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>While I'd been meaning to write this up for a while, <a href="http://bigl.es">Les Pounder</a>'s article in <a href="https://hackspace.raspberrypi.org/issues">issue 14 of Hackspace Magazine (page 120)</a> reminded me that I'd never actually published it! [<em>Thanks Les!</em>]</p>
<h2 id="tldr">TL;DR</h2>
<p>Without having to know the exact infra-red sending pattern that Nerf use for the Laser Ops series, the following hash values are enough to use <a href="https://github.com/cyborg5/IRLib2">IRLib2</a> on Arduino with the Hash Decoder functions to identify which colour team last &quot;hit&quot; the IR receiver with an Alphapoint blaster. It's not known if this works for the Deltaburst, as I don't have one to try at the time of writing.</p>
<pre><code class="language-c">/* IR hashes for Nerf LaserOps standard game */
static const long PURPLE = 0x67228B44;
static const long RED = 0x78653B0E;
static const long BLUE = 0x2FFEA610;
</code></pre>
<h2 id="receivingir">Receiving IR</h2>
<p>While it would be entirely possible that Nerf/Hasbro would use a completely custom IR sending arrangement, most IR signals are sent by modulating the signal using a common frequency to prevent interference from other devices (eg. incandescent bulbs). The receiver then minuses the known frequency from the received signal, and the result comes out as a set of pulses of specific length.</p>
<p>A quick check by firing the blaster at a TV IR receiver I have that always lights up as long as it's receiving any signal, confirmed to me that the blaster uses the same IR hardware as every other common remote or IR device.</p>
<p>Then it was on to finding out the exact signal that the blasters use.</p>
<h2 id="irlib2">IRLib2</h2>
<p>A quick google found <a href="https://github.com/cyborg5">Chris Young</a>'s IR library for Arduino, and it is especially suitable because it has example Arduino sketches to show the raw timing of incoming signals — useful in this case because (<em>spoiler alert</em>) the Nerf Laser Ops signal doesn't use TV manufacturer codes for the blasters.</p>
<p>The first order of business then is to see what the incoming signals actually look like.</p>
<p>By using a raw receiver example from the library that's lightly modified to match the pin assignments for the Circuit Playground Express (<a href="https://github.com/DefProc/LaserOps-utils/tree/master/rawRecv">rawRecv</a>) and starting the Alphapoint blaster as the purple team and firing at the IR sensor; the results look something like this:</p>
<pre><code class="language-c">#define RAW_DATA_LEN 36
uint16_t rawData[RAW_DATA_LEN]={
	2895, 5992, 2897, 2053, 841, 2059, 846, 2054,
	851, 2061, 824, 2076, 1817, 2108, 787, 2112,
	844, 2056, 838, 2062, 1863, 2062, 842, 2057,
	848, 2052, 843, 2057, 848, 2051, 843, 2070,
	825, 2074, 790, 1000};
</code></pre>
<p>In the raw results from the library, each number in the array indicates either the number of microseconds of a mark (signal high) or a space (signal low).</p>
<p>The stream starts with the length of the first mark (<code>2895µs</code>), followed by the length of the next space (<code>5992µs</code>). The sequence continues with alternating marks and spaces until the final recorded mark (<code>790µs</code>) and the sketch adds a trailing space of a set length (<code>1000µs</code>) to allow it to be used in another program without needing to worry about running into the start of the next sent signal.</p>
<p>Now, these results would be fine to just copy and paste into a sketch if we just wanted to resend these to another blaster, but with a little guess work, I figured it might be reasonable to make an educated guess to the structure of the message.</p>
<h2 id="decoding">Decoding</h2>
<p>The numbers from rawRecv are alternating mark &amp; space times, in microseconds, so assuming some variation on the exact timings of the received signals, they are likely to actually be sent as a round number of microseconds. Eg.</p>
<pre><code class="language-c">uint16_t rawData[RAW_DATA_LEN]={
	3000, 6000, 3000, 2000, 800, 2000, 800, 2000,
	800, 2000, 800, 2000, 1800, 2000, 800, 2000,
	800, 2000, 800, 2000, 1800, 2000, 800, 2000,
	800, 2000, 800, 2000, 800, 2000, 800, 2000,
	800, 2000, 800, 1000};
</code></pre>
<p>And knowing that lots of signals start with a <em>preamble</em> to allow the receiver to identify the start of the signal, the rest starts to look a lot like two possible length marks that each follow a fixed length space.</p>
<p>If the preamble is:</p>
<ul>
<li><code>(mark)3000, (space)6000, (mark)3000</code></li>
</ul>
<p>The rest of the message looks a lot more regular. And I'm guessing that the rest of the mark lengths will indicate either a binary <code>0</code> or <code>1</code>. Assuming that zeros make up more of the message, that would suggest that after the preamble:</p>
<ul>
<li><code>(space)2000, (mark)800</code> is a <code>0</code>, and</li>
<li><code>(space)2000, (mark)1800</code> is a <code>1</code>.</li>
</ul>
<p>So this could be translated as:</p>
<pre><code class="language-c">uint16_t rawData[RAW_DATA_LEN]={
  3000, 6000, 3000, // preamble (3ms mark, 6ms space, 3ms mark)
  2000, 800, 2000, 800, 2000, 800, 2000, 800,  // 0, 0, 0, 0
  2000, 1800, 2000, 800, 2000, 800, 2000, 800, // 1, 0, 0, 0
  2000, 1800, 2000, 800, 2000, 800, 2000, 800, // 1, 0, 0, 0
  2000, 800, 2000, 800, 2000, 800, 2000, 800,  // 0, 0, 0, 0
  1000 // added by the sketch
};
</code></pre>
<p>I've broken these up in to 4 bits lines (a nybble), on a hunch. The position of those <code>1</code> bits suggests that there might be 4 fields of 4 bytes each, encoded with the least significant bit to the earliest bit (least significant bit to the left).</p>
<p>Running each of the colour in the same mode gives us some more information:</p>
<pre><code class="language-c">// PURPLE
#define RAW_DATA_LEN 36
uint16_t rawData[RAW_DATA_LEN]={
  2888, 5987, 2893,
  2058, 848, 2052, 843, 2069, 795, 2104, 791,  // 0, 0, 0, 0
  2109, 1816, 2109, 837, 2063, 842, 2057, 848, // 1, 0, 0, 0
  2052, 1873, 2055, 840, 2059, 846, 2054, 841, // 1, 0, 0, 0
  2071, 794, 2106, 789, 2111, 795, 2105, 841,  // 0, 0, 0, 0
  1000
};
</code></pre>
<pre><code class="language-c">// RED
#define RAW_DATA_LEN 36
uint16_t rawData[RAW_DATA_LEN]={
  2899, 5977, 2897,
  2065, 842, 2058, 849, 2051, 845, 2055, 842,  // 0, 0, 0, 0
  2058, 1869, 2056, 851, 2061, 826, 2074, 792, // 1, 0, 0, 0
  2108, 789, 2111, 836, 2064, 843, 2057, 840,  // 0, 0, 0, 0
  2060, 846, 2054, 843, 2057, 850, 2050, 847,  // 0, 0, 0, 0
  1000
};
</code></pre>
<pre><code class="language-c">// BLUE
#define RAW_DATA_LEN 36
uint16_t rawData[RAW_DATA_LEN]={
  2896, 5979, 2902,
  2060, 836, 2064, 843, 2057, 848, 2052, 844,  // 0, 0, 0, 0
  2055, 1870, 2055, 851, 2052, 844, 2065, 820, // 1, 0, 0, 0
  2080, 795, 2105, 1821, 2104, 792, 2111, 836, // 0, 1, 0, 0
  2063, 843, 2057, 838, 2062, 845, 2055, 840,  // 0, 0, 0, 0
  1000
};
</code></pre>
<p>While this doesn't give all the answers, it strongly suggests that the number of the ID for the team that sent the pulse is encoded in the third data line.</p>
<p>If I assume that it is nybbles with the least significant bit sent first:</p>
<table>
<thead>
<tr>
<th>Nybble</th>
<th>Identifier</th>
<th>Values</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>Unknown</td>
<td>0</td>
</tr>
<tr>
<td>1</td>
<td>Unknown <ul><li>Game type?</li><li>Number of hits?</li><li>Blaster type?</li></ul></td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>Team</td>
<td><ul><li>Red = 0</li><li>Purple = 1</li><li>Blue = 2</li></ul></td>
</tr>
<tr>
<td>3</td>
<td>Unknown</td>
<td>0</td>
</tr>
</tbody>
</table>
<h2 id="hash">Hash</h2>
<p>While having this information is good, and sending identical codes back out of the Circuit Playground Express IR sender will &quot;hit&quot; a blaster of the appropriate team, there's not enough information yet to fully decode the signal, and because it's not a known encoding in the library, it would need specific decoder writing for the library to use.</p>
<p>But because, the library can only identify a limited set of &quot;standard&quot; IR patterns, it also includes a way of identifying <em>any</em> signal, even an unknown one by generating a 32 bit &quot;hash&quot; of the sequence. I've not looked to closely at the hash algorithm used, but it's designed to allow for the intrinsic timing jitter in the received IR signals and it's expected to be robust enough that repeated sends of the same message will always give the same hash.</p>
<p>Using the <a href="https://github.com/DefProc/LaserOps-utils/tree/master/hashDecode">hashDecode</a> sketch, the hash code will be printed on the serial monitor.</p>
<p>The values for each team I got are:</p>
<pre><code class="language-c">/* IR hashes for Nerf LaserOps standard game */
static const long PURPLE = 0x67228B44;
static const long RED    = 0x78653B0E;
static const long BLUE   = 0x2FFEA610;
</code></pre>
<p>And as we know the hashes, checking for these values specifically will allow identification of the team who's signal has been received:</p>
<pre><code class="language-c">if (myDecoder.value == PURPLE) {
  // indicate Purple on the LEDs...
}
</code></pre>
<p>I've already created an example sketch that uses these hashes, and lights up the LEDs on the Circuit Playground, depending on the incoming signal. As with the other sketches, I've included a <a href="https://blog.adafruit.com/2017/04/28/uf2-bootloader-on-express-boards/"><code>UF2</code> file</a>, that can just be downloaded, dragged and dropped onto the <code>CPLAYBOOT</code> drive to flash onto the Circuit Playground Express:</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/teamHitColour-1.gif" class="kg-image" alt="Decoding Nerf Laser Ops"><figcaption><em><strong>Team hit colour on the Circuit Playground Express</strong></em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><h2 id="todo">TODO</h2>
<p>There's enough here to be able to identify incoming signals, and send replica signals out, so it's possible to create alternate game components that interact with the blasters.</p>
<p>Still outstanding questions include:</p>
<ul>
<li>What do the other fields in the IR signal relate to?</li>
<li>Does the message change for other game types? Especially, does an ID for each blaster get included in games using the app for scoring?</li>
<li>Does the Deltaburst signal change to indicate its &quot;double shot&quot; mode?</li>
<li>What's the best approach to write an IRLib2 library file for decoding these signals?</li>
</ul>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Hello World for LoRaWAN]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Welcome <a href="http://thethingsconference.uk">The Things Conference UK</a> workshop participants, and others on the internet. This workshop guide is designed to let you start from very simple beginnings, and take you through creating a simple temperature sensor that sends data at regular intervals through to <a href="http://thethingsnetwork.org">The Things Network</a> via LoRaWAN.</p>
<h2 id="youwillneed">You will need:</h2>]]></description><link>https://foxtrot.defproc.co.uk/blog/hello-world-lorawan/</link><guid isPermaLink="false">5cd3ff41c3e3797874ba2c9e</guid><category><![CDATA[Tutorial]]></category><category><![CDATA[The Things Network]]></category><category><![CDATA[Arduino]]></category><category><![CDATA[LoRaWAN]]></category><dc:creator><![CDATA[Patrick Fenner]]></dc:creator><pubDate>Sun, 14 Oct 2018 10:54:00 GMT</pubDate><media:content url="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/ttn.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/ttn.jpg" alt="Hello World for LoRaWAN"><p>Welcome <a href="http://thethingsconference.uk">The Things Conference UK</a> workshop participants, and others on the internet. This workshop guide is designed to let you start from very simple beginnings, and take you through creating a simple temperature sensor that sends data at regular intervals through to <a href="http://thethingsnetwork.org">The Things Network</a> via LoRaWAN.</p>
<h2 id="youwillneed">You will need:</h2>
<ul>
<li>A computer with the <a href="http://arduino.cc/downloads">Arduino software installed</a>,</li>
<li>A Things Uno (or similar), Arduino compatible board with a LoRaWAN modem attached. The Things Uno comes with a USB cable to connect to the computer, otherwise you may need your own.</li>
<li>A DS18B20 One-Wire Temperature sensor to connect to the arduino</li>
<li>A 4.7k resistor is recommended for power stability for the One-Wire sensor..</li>
<li>A small breadboard to connect all the components into.</li>
<li>3 jumper wires, one red, one black, and one another colour of your choice (yellow in this guide). Ensure that they're long enough to reach beween the Arduino ports around the side, and the breadboard you're using.</li>
<li>To be in an area with LoRaWAN coverage from The Things Network (if you're at The Things Conference UK, you will have <em>plenty</em> of coverage!).</li>
</ul>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/kit.jpg" class="kg-image" alt="Hello World for LoRaWAN"><figcaption><em>The kit components, all knolled</em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><h2 id="circuitconstruction">Circuit construction</h2>
<p>With the arduino software installed, and the all the parts available, place the DS18B20 temperature sensor into the breadboard.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/temp-sensor.jpg" class="kg-image" alt="Hello World for LoRaWAN"></figure><!--kg-card-end: image--><p>Connect the 4.7k resistor between pin 2 and pin 3 of the temperature sensor.</p><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/add-resistor.jpg" class="kg-image" alt="Hello World for LoRaWAN"></figure><!--kg-card-end: image--><p>Connect a red jumper wire to pin 3, a black jumper wire to pin 1, and the other jumper wire (pictured in yellow) to pin 2.</p><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/3-wires.jpg" class="kg-image" alt="Hello World for LoRaWAN"></figure><!--kg-card-end: image--><p>Pin 1 is Ground on the temperature sensor, so connect the other end of the black wire to a GND port on the Things Uno.</p><p>Pin 2 is the Data line on the temperature sensor, so connect the yellow jumper wire to Digital pin 6 on the Things Uno.</p><p>Pin 3 is the power line on the temperature sensor, so connect the red wire to the 5V port on the Things Uno.</p><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/complete.jpg" class="kg-image" alt="Hello World for LoRaWAN"></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><h2 id="installingthesoftwareandlibraries">Installing the Software and libraries</h2>
<p>Install the <a href="https://www.arduino.cc/en/Main/Software">Arduino IDE</a> if it isn't already, and open a new window.</p>
<p>Then install the following Arduino libraries in the IDE from the top menu, by following: <code>Sketch</code> → <code>Include Library</code> → <code>Manage Libraries</code> → <code>The Things Network</code> → <code>install</code> and typing each library name into the serch box. Click install for each choice before repeating with the next.</p>
<ul>
<li><a href="https://github.com/TheThingsNetwork/arduino-device-lib">The Thing Network</a></li>
<li><a href="https://www.pjrc.com/teensy/td_libs_OneWire.html">OneWire</a></li>
<li><a href="https://github.com/milesburton/Arduino-Temperature-Control-Library">DallasTemperature</a></li>
</ul>
<p>Then you're ready to start programming.</p>
<h2 id="connectingtothethingsnetwork">Connecting to The Things Network</h2>
<p>Because each device on LoRaWAN needs to be authenticated with the service and application that we will be sending to, you will need to know the unique ID number of the device that you're using now - its <code>DeviceEUI</code>.</p>
<p>To get your device to report the radio ID, copy and paste the following in to a new Arduino sketch, and upload to the board.</p>
<pre><code class="language-cpp">#include &lt;TheThingsNetwork.h&gt;
#define lora Serial1

#define debugSerial Serial
#define loraSerial lora

TheThingsNetwork ttn(loraSerial, Serial, TTN_FP_EU868);

void setup()
{
  debugSerial.begin(115200);
  loraSerial.begin(57600);
  delay(1000);
}   

void loop()
{
   debugSerial.println(&quot;Device Information&quot;);
   debugSerial.println();
   ttn.showStatus();
   debugSerial.println();
   debugSerial.println(&quot;Use the EUI to register the device for OTAA&quot;);
   debugSerial.println(&quot;-------------------------------------------&quot;);
   debugSerial.println();
   delay(10000);
}
</code></pre>
<p>Ensure the board is set to be an <code>Arduino Leonardo</code> (from <code>Tools → Board</code>), and the port is set correctly once the Things Uno board is plugged in (from <code>Tools → Port</code>, select the Arduino in the list).</p>
<p>Once uploaded, open the serial monitor (click the magnifying glass in the top right of the Arduino IDE window). Check that the baud rate (from the drop down box in the bottom right of the serial monitor window) is set to <code>115200</code>. Then the device EUI should be printed out in the window.</p>
<p>Then create a TTN application and register your device:</p>
<ul>
<li>Make an account on <a href="https://account.thethingsnetwork.org/register">The Things Network</a>,</li>
<li>go to the <a href="https://console.thethingsnetwork.org/">TTN console</a></li>
<li>select <code>applications</code> and <code>+ add application</code></li>
<li>Set
<ul>
<li>Description (a name to describe the application to yourself later),</li>
<li>Handler registration to <code>ttn-handler-eu</code></li>
</ul>
</li>
<li>From your application page, <code>+ register device</code>
<ul>
<li>Device ID (a name to describe this device to yourself later),</li>
<li>Device EUI (copy and paste from the serial monitor),</li>
</ul>
</li>
</ul>
<h2 id="testthelorawanconnection">Test the LoRaWAN connection</h2>
<p>Before adding the temperature sensor, the sketch below will send a single value to over LoRaWAN that you can watch on the TTN Console connetion to verify that your device is actually making a connection to The Things Network.</p>
<p>In a new sketch window, copy and paste the following code:</p>
<pre><code class="language-cpp">#include &lt;TheThingsNetwork.h&gt;

// Set your AppEUI and AppKey
const char *appEui = &quot;0000000000000000&quot;; // replace with your `App EUI`
const char *appKey = &quot;00000000000000000000000000000000&quot;; // replace with your `App Key`

#define lora Serial1
#define debugSerial Serial
#define loraSerial lora

TheThingsNetwork ttn(loraSerial, Serial, TTN_FP_EU868);

void setup()
{
   debugSerial.begin(115200);
   loraSerial.begin(57600);

   // Wait a maximum of 10s for Serial Monitor
   while (!debugSerial &amp;&amp; millis() &lt; 10000);

   debugSerial.println(&quot;-- STATUS&quot;);
   ttn.showStatus();

   debugSerial.println(&quot;-- JOIN&quot;);
   ttn.join(appEui, appKey);
}

void loop()
{
   debugSerial.println(&quot;-- LOOP&quot;);

   // Prepare payload of 1 byte to indicate LED status
   byte payload[1];
   payload[0] = (digitalRead(LED_BUILTIN) == HIGH) ? 1 : 0;

   // Send it off
   ttn.sendBytes(payload, sizeof(payload));

   delay(10000);
}
</code></pre>
<p>To make this device send data to your new application, and not anyone else's, you will need to change the two lines to match your own device setting for the application:</p>
<pre><code class="language-cpp">const char *appEui = &quot;0000000000000000&quot;;
const char *appKey = &quot;00000000000000000000000000000000&quot;;
</code></pre>
<p>Each application has a unique <code>appEui</code>, and each device on each application has a unique <code>appKey</code>. These are used to authenticate and verify each device against its <code>deviceEui</code> when it performs its join request to the LoRaWAN network. If successful, these are also used derive the unique session keys that encrypt all the traffic sent from the device to TTN application.</p>
<p>This information is available from the TTN Console page for the chosen application. Follow <code>Devices</code> → <code>[click on a device]</code> → <code>settings</code> shows the <code>AppEUI</code> and <code>AppKey</code>. Copy and paste the values for the device you just created into the sketch, and upload to the board.</p>
<p>You can watch the data being sent on the serial monitor, and being received on the <code>data</code> tab of the TTN Console for your application.</p>
<h2 id="sendtemperature">Send Temperature</h2>
<p>With the connection to the application confirmed, the next step is to send the readings from the temperature sensor, and set the TTN application to decode the values into JSON to make reading easier, and to allow them to be passed on to another service.</p>
<blockquote>
<p>This example uses the Cayenne LPP format so it can be recreated back into a JSON objects without having to do any custom float to <a href="https://www.thethingsnetwork.org/docs/devices/bytes.html">byte array translation or javascript re-building</a>. You can also create your own encoding and decoding schemes dependent on your application requirements.</p>
</blockquote>
<p>To decode each message when received in the TTN Console, set the <code>Payload Formats</code> to be <code>CayenneLPP</code> from the dropdown.</p>
<p>Copy and paste the following code in to a new Arduino sketch, changing the <code>appEui</code> and <code>appKey</code> to the same values as used in the previous sketch.</p>
<pre><code class="language-cpp">#include &lt;TheThingsNetwork.h&gt;
#include &lt;CayenneLPP.h&gt;
#include &lt;OneWire.h&gt;
#include &lt;DallasTemperature.h&gt;

// Set your AppEUI and AppKey
const char *appEui = &quot;0000000000000000&quot;;
const char *appKey = &quot;00000000000000000000000000000000&quot;;

// Data wire is plugged into port 6 on the Arduino
#define ONE_WIRE_BUS 6

#define lora Serial1
#define loraSerial lora
#define debugSerial Serial

TheThingsNetwork ttn(loraSerial, debugSerial, TTN_FP_EU868);
CayenneLPP lpp(51);

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&amp;oneWire);

// arrays to hold device address
DeviceAddress deviceAddress;

void setup()
{
   debugSerial.begin(115200);
   loraSerial.begin(57600);

   // Wait a maximum of 10s for Serial Monitor
   while (!debugSerial &amp;&amp; millis() &lt; 10000);

   // Get device address
   if (!sensors.getAddress(deviceAddress, 0)) Serial.println(&quot;Unable to find address for Device 0&quot;);

   // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions)
   sensors.setResolution(deviceAddress, 12);

   debugSerial.println(&quot;-- STATUS&quot;);
   ttn.showStatus();

   debugSerial.println(&quot;-- JOIN&quot;);
   ttn.join(appEui, appKey);
}

void loop()
{
   debugSerial.println(&quot;-- LOOP&quot;);

   // get the current temperature
   sensors.requestTemperatures();
   float degC = sensors.getTempC(deviceAddress);
   debugSerial.println(degC, 6);

   lpp.reset();
   lpp.addTemperature(1, degC);

   // Send it off
   ttn.sendBytes(lpp.getBuffer(), lpp.getSize());

   delay(30000);
}
</code></pre>
<p>New messages should appear in the applicaton, and the incoming data should show a <code>&quot;temperature_1&quot;: 00.0</code> in the processed payload. This then appears as a value:key pair in any JSON messages that are passed on to other services.</p>
<h2 id="externaldata">External Data</h2>
<p>While there is a specific workshop during The Things Conference UK 2018 on this topic, there are some services that connect very easily to The Things Network, especially for dashboards. While the conference workshop with Dave Mee focusses on Node-Red, the myDevices Cayenne service (of CayenneLPP fame) is an easy first step, if ultimately less flexible.</p>
<p>Creating a myDevices Cayenne dashboard:</p>
<ul>
<li>Ensure the 'Payload Format' in the TTN application is set to 'CayenneLPP',</li>
<li>create an account at <a href="https://mydevices.com/cayenne/signup/">myDevices Cayenne</a></li>
<li><code>Add new</code> → <code>Devices &amp; Wigets</code> → <code>LoRa (beta)</code> → <code>The Things Network</code> → <code>Cayenne LPP</code></li>
<li>Enter the <code>Device EUI</code> from the TTN console,</li>
<li>Back on the TTN console for the application → <code>Applications</code> → <code>+ add integration</code> → choose <code>Cayenne</code>,
<ul>
<li>Enter a <code>Process ID</code> of your choice (anything),</li>
<li>Select an <code>Access Key</code> (one of the allowed MQTT passwords on the application to pass to Cayenne)</li>
</ul>
</li>
<li>new data from this device will automatically propogate to myDevices Cayenne, so entries for <code>temperature</code>, <code>RSSI</code> and <code>SNR</code> for this device will appear when it next sends.</li>
</ul>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Sensor City Office]]></title><description><![CDATA[<p>Since our foundation five years ago, we at DefProc have always tried to be at the bleeding edge of new developments, both socially and in tech, so we’re delighted to announce that we have recently moved into new accommodation in the LJMU/UoL joint venture; Sensor City.</p><!--kg-card-begin: embed--><figure class="kg-card kg-embed-card"><blockquote class="twitter-tweet"><p lang="en" dir="ltr">Still can&</p></blockquote></figure>]]></description><link>https://foxtrot.defproc.co.uk/blog/sensor-city-office/</link><guid isPermaLink="false">5cd3ff41c3e3797874ba2c9f</guid><category><![CDATA[Update]]></category><dc:creator><![CDATA[Seán Gleeson]]></dc:creator><pubDate>Tue, 19 Jun 2018 12:00:00 GMT</pubDate><media:content url="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/project_sensor-city-1.jpg" medium="image"/><content:encoded><![CDATA[<img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/project_sensor-city-1.jpg" alt="Sensor City Office"><p>Since our foundation five years ago, we at DefProc have always tried to be at the bleeding edge of new developments, both socially and in tech, so we’re delighted to announce that we have recently moved into new accommodation in the LJMU/UoL joint venture; Sensor City.</p><!--kg-card-begin: embed--><figure class="kg-card kg-embed-card"><blockquote class="twitter-tweet"><p lang="en" dir="ltr">Still can&#39;t quiet believe that this is now <a href="https://twitter.com/DefProc?ref_src=twsrc%5Etfw">@DefProc</a> new office building! <a href="https://twitter.com/SensorCityUK?ref_src=twsrc%5Etfw">@SensorCityUK</a> Looking lovely in the sunshine 🌞 <a href="https://t.co/sKHXQdE7V4">pic.twitter.com/sKHXQdE7V4</a></p>&mdash; Jen Fenner (@RedVioletJen) <a href="https://twitter.com/RedVioletJen/status/981834840000663552?ref_src=twsrc%5Etfw">April 5, 2018</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</figure><!--kg-card-end: embed--><p>This brand new building right next to Liverpool’s main Lime Street Station is home to some awesome people as well as some very exciting machinery, both of which we hope to be able to utilise in our ongoing quest to design, create and manufacture the most interesting, fun and useful things we can. At this point, Patrick’s major concern is just how he’s going to find the time to fit in all the playing he wants to do around the work that needs to get done!</p><p>We’re really excited about this move, for a few reasons. Firstly, it means we have our own dedicated office space with lots of room for testing, building and other far less interesting things, and which we might even manage to avoid being taken over by boxes and NERF guns. Secondly, it’s helping us to meet some very cool people that we hope to be able to collaborate with on projects in the future. And thirdly, this extra space, coupled with the work that has made it both necessary and possible, means that we’ll be able to take on new staff to do some of the stuff that we just don’t find that interesting. Job creation makes us very happy.</p><p>Oh, and of course all the exciting machinery. You can never forget about the exciting machinery.</p><p>We’ve been lucky enough to work on some very interesting and challenging projects in the recent past, from developing low cost river level sensors for the Environment Agency, building a replica Minimum Wage Machine installation for FACT, to our current work tackling social isolation as part of the Liverpool 5G Health and Social Care Consortium, and we’re looking forward to continuing to do so here. Other than our address, the art on the walls and the plants on the bookshelves, nothing has changed - we’re still the same company with the same ethos, work ethic and stupendous abilities, and we will keep on developing and making the kind of kit that makes lives easier.</p><p>The opening of Sensor City is yet another step on the road towards Liverpool becoming THE place to be in the UK when it comes to technology, IoT and digital manufacturing, and we are really proud to be among its first residents. We’re just looking forward to the day the blue plaque bearing our names goes up outside.</p>]]></content:encoded></item><item><title><![CDATA[Maker Difference with Circuit Playground Express]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>We have recently had the privilege to learn about some new tech and work with some super talented and enthusiastic young people as part of the <a href="http://makerdifferenceliverpool.org/">Maker Difference Project</a> with Liverpool Libraries and Sefton Libraries in conjunction with the amazing <a href="http://www.liverpoolgirlgeeks.co.uk/">Liverpool Girl Geeks</a>.</p>
<p>We have just complete a four-part course</p>]]></description><link>https://foxtrot.defproc.co.uk/blog/maker-difference-with-cpx/</link><guid isPermaLink="false">5cd3ff41c3e3797874ba2ca5</guid><category><![CDATA[Update]]></category><category><![CDATA[MakeFest]]></category><dc:creator><![CDATA[DefProc Engineering]]></dc:creator><pubDate>Tue, 06 Mar 2018 15:01:00 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>We have recently had the privilege to learn about some new tech and work with some super talented and enthusiastic young people as part of the <a href="http://makerdifferenceliverpool.org/">Maker Difference Project</a> with Liverpool Libraries and Sefton Libraries in conjunction with the amazing <a href="http://www.liverpoolgirlgeeks.co.uk/">Liverpool Girl Geeks</a>.</p>
<p>We have just complete a four-part course at Parklands Library, Speke, Liverpool. Our Saturday mornings have been spent teaching and inspiring 11-14 year old girls to understand coding and how it can be used creatively. We also ran a shorter version of this over 3 mornings during February half term at <a href="https://sefton.gov.uk/schools-learning/libraries/your-local-library/netherton-library.aspx">Netherton Library</a> and Activity Center.</p>
<p>While going into some important technical aspects; the sessions were designed to spark ideas of what they could achieve with the Circuit Playground Express and how creativity is important for innovative programming in the future. We explored the sensor inputs such as light, sound and accelerometer and ventured into creating coloured light animations with sounds and games.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/cpx_kit.jpg" class="kg-image"><figcaption><em>This is the kit that they got to take home on the last day</em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>The thing that I have been blown away by throughout this, is the young people’s ability to to pick up a piece of new technology and start trying to have a go at getting a result. On our first session, as soon as I had handed the kits out and demonstrated how to download a simple animation, suddenly they were saying, “look what I have made!” or there was experimental musical sounds coming from the whole room. They were so excited to get going and learn about it!</p>
<p>We did some guided learning so they could understand in more detail how to program the Circuit Playground Express to do what they wanted and we went through some preplanned activities. The important thing that I tried to facilitate throughout this was to give them the opportunity to play and expand the activities. Which they did and really enjoyed themselves in the process. We had lots of imaginative uses for the <code>On Shake</code> input (accelerometer) and how to use the <code>On Loud Sound</code> event. It was interesting when they all decided to see what was the funniest noise they could all make to set the light animations off!</p>
<p>Our final session of the 4 we programmed the Circuit Playground Express so we could play some games. We created a basic game that we all had giggle at called the Hot Potato Game. This is where the timer counts down (slowly at first) and then it gets faster and faster until the alarm goes off and whoever is holding it is out. This was to explore the concept of variables in the program and why they are used. Lots of laughing and having fun ensued!</p>
<p>The second game we created was a target practice style game where the Circuit Playground Express counts how many times you hit the target and when all 10 LEDs are lit it plays a tune and an animation. We also made some basic targets out of corrugated cardboard, wrapping paper and tape; stuck the Circuit Playground Express to the cardboard and set it up so they could shoot at it using foam dart blasters (we used Nerf™ blasters). Everyone had a fantastic session and went away wanting to come again and do more.</p>
<p>I loved teaching this new course and looking forward to doing it again! I would like to thank Liverpool Girl Geeks for their support in this project and encouraging me to take the leap into teaching tech to teens. And also, thank you to Liverpool Libraries for all the hard work that has gone into creating such a great project and bringing making to libraries across the city.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/cpx_reviews.jpg" class="kg-image"><figcaption><em>Some of the reviews from the participants</em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>Come along to <a href="https://lpoolmakefest.org/2018/02/05/young-makefest-2018/">Young MakeFest</a> at Liverpool Central Library on 23rd March 2018 11am until 3pm I will be doing a drop in Circuit Playground Express workshop! We will also have <a href="https://foxtrot.defproc.co.uk/blog/projects/made-invaders">Made Invaders</a> there too!</p>
<p><a href="https://lpoolmakefest.org/tickets/">Liverpool MakeFest</a> 2018 this year is on 30th June Liverpool Central Library 9am until 5pm!</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Product Development Sessions]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Do have an idea for a product?</p>
<p>Do you have a proof of concept or prototype that you are developing but aren’t sure on the next steps?</p>
<p>We are offering free, friendly advice at our drop-in session at <a href="https://www.google.co.uk/maps/place/Central+Library/">Liverpool Central Library</a> from 5:30pm until 7:30pm on the</p>]]></description><link>https://foxtrot.defproc.co.uk/blog/product-development-sessions/</link><guid isPermaLink="false">5cd3ff41c3e3797874ba2ca6</guid><category><![CDATA[Update]]></category><dc:creator><![CDATA[DefProc Engineering]]></dc:creator><pubDate>Wed, 07 Feb 2018 15:07:00 GMT</pubDate><media:content url="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/idea.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/idea.jpg" alt="Product Development Sessions"><p>Do have an idea for a product?</p>
<p>Do you have a proof of concept or prototype that you are developing but aren’t sure on the next steps?</p>
<p>We are offering free, friendly advice at our drop-in session at <a href="https://www.google.co.uk/maps/place/Central+Library/">Liverpool Central Library</a> from 5:30pm until 7:30pm on the second Tuesday of every second month.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: html--><iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2378.273667155271!2d-2.9829757841591578!3d53.40993167999247!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x487b213b05a3aa69%3A0x5f4ca882f45b6b5d!2sCentral+Library!5e0!3m2!1sen!2suk!4v1518009299540" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe><!--kg-card-end: html--><!--kg-card-begin: markdown--><p>Each session is 45 mins long and you can talk about your ideas in confidence and explore the possibilities for the next steps. Patrick, our Design Engineer, hosts these events and can offer you advice from <em>quick and easy ways to get started creating your proof of concept</em> to <em>what the process is for getting your product ready for manufacture</em>.</p>
<p>We have already helped a wide range of people through these sessions and are really enjoying being part of their process to realising their big ideas.</p>
<p>Sign up by emailing <a href="mailto:libraries.enquiries@liverpool.gov.uk">libraries.enquiries@liverpool.gov.uk</a>, or take a look at the <a href="https://www.eventbrite.co.uk/o/business-amp-ip-centre-liverpool-5420728329">Eventbrite listing for the Business &amp; IP Centre Liverpool</a>.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[How to Reduce Arduino Uno Power Usage by 95%]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Sometimes you have to use an Arduino UNO, instead of something more efficient like an Arduino Pro Mini — maybe you're using an Arduino shield…</p>
<p>Sometimes you have to run that same project from battery power, and every milliAmp counts…</p>
<p>Sometimes that means that you'll have to adjust the UNO to</p>]]></description><link>https://foxtrot.defproc.co.uk/blog/uno-low-power/</link><guid isPermaLink="false">5cd3ff41c3e3797874ba2ca0</guid><category><![CDATA[Tutorial]]></category><category><![CDATA[Arduino]]></category><dc:creator><![CDATA[Patrick Fenner]]></dc:creator><pubDate>Sat, 25 Nov 2017 12:00:00 GMT</pubDate><media:content url="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/arduino_uno.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/arduino_uno.jpg" alt="How to Reduce Arduino Uno Power Usage by 95%"><p>Sometimes you have to use an Arduino UNO, instead of something more efficient like an Arduino Pro Mini — maybe you're using an Arduino shield…</p>
<p>Sometimes you have to run that same project from battery power, and every milliAmp counts…</p>
<p>Sometimes that means that you'll have to adjust the UNO to be much more power efficient, so you pick up a sharp scalpel, bring over the big loupe, and warm up the fine tipped soldering iron…</p>
<blockquote>
<p>The post formed part of development work performed for the <a href="https://www.gov.uk/government/organisations/environment-agency">Environment Agency</a>. It has been re-published here with their kind permission, as part of the project commitment to open source development.</p>
</blockquote>
<p>The Arduino UNO is designed as a development board, instead of a specific low power device, it is built with several design choices that mean it uses more power that the minimum necessary.</p>
<p>TL;DR: To reduce the overall power usage of the Arduino UNO board significantly:</p>
<ul>
<li>replace the linear regulator with a DC-DC converter,</li>
<li>adjust the USB-to-Serial circuit so it's only powered from the USB port,</li>
<li>cut out (or desolder) the always-on LED's on the board,</li>
<li>use the processor sleep mode.</li>
</ul>
<p>Using on-board circuit changes, selective replacement of components and the use of microcontroller sleep mode can reduce the continuous idle power usage of an Arduino UNO to only <strong>5%</strong> of the default draw.</p>
<h2 id="experimentalsetup">Experimental Set Up</h2>
<p>Current measurements were made using the blink sketch that forms part of the standard Arduino Optiboot bootloader. This ensures the results are comparable across any board, and may be tested on other controllers using the default sketch. Additionally, a blink sketch is available in the examples provided with the Arduino IDE, and can be loaded on to a board without any additional software libraries.</p>
<p>Current measurements were all made the same way, with the same equipment. A <a href="https://www.eevblog.com/projects/ucurrent/">&quot;µCurrent Gold&quot;</a> was inserted between the 12V supply and the DC jack on the Arduino UNO on the 12V line. The same DC supply was used for all tests, a PowerPax SW4298D 12V, 2A mains to DC supply.</p>
<p>The µCurrent Gold is a precision current adaptor converts the current measurement across a sense resistor and amplifies the voltage to provide very accurate measurements (±0.1%) with very low voltage drop on the input (20µV/mA) to minimise the supply change. The output signal is 1mV/mA, so it can be read manually as milliAmps with a multimeter on the milliVolts range.</p>
<p>Initial readings were taken over several cycles and averaged to give a single value, and values are given for both the built-in LED off and LED on condition during the LED blink sketch.</p>
<table>
<thead>
<tr>
<th>State</th>
<th>LED off</th>
<th>LED on</th>
</tr>
</thead>
<tbody>
<tr>
<td>Base UNO</td>
<td>53mA</td>
<td>55mA</td>
</tr>
</tbody>
</table>
<p><em>Table 1: Base Arduino Uno current measurement.</em></p>
<h2 id="voltageregulator">Voltage Regulator</h2>
<p>The biggest power loss in the standard Arduino UNO board is from the voltage regulator that limits the input voltage to the DC input jack. The board uses a linear regulator, which dissipates any supply voltage above the target voltage as heat. With a 12V input, and a 5V output, around <strong>58%</strong> of the input energy is lost, either dissipated as heat, or used for the internal supply of the regulator.</p>
<p>Changing the regulator for a more efficient &quot;buck&quot; converter will reduce the power losses — as DC-DC step-down converters can be as high as 92% efficient, depending on the specific usage.</p>
<p>Unfortunately there is no pin-equivalent buck converter that matches the SOT-223 footprint of the <a href="http://www.onsemi.com/PowerSolutions/product.do?id=NCP1117">NCP1117</a> linear regulator used on the board; particularly as it has a non-standard regulator pin assignment (1. Ground, 2. Output, 3. Input). However a leaded DC-DC converter can be made to fit the available footprint.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/sm_NCP1117.jpg" class="kg-image" alt="How to Reduce Arduino Uno Power Usage by 95%"><figcaption><em>The default NCP1117ST50T3G 5V 1A linear voltage regulator</em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>The Traco <a href="http://www.farnell.com/datasheets/2200606.pdf">TSRN-1</a>-2450 is a 5V switching regulator with built in capacitors. As a pin compatible replacement, it can be used in place of 78xx series linear regulators with out requiring any external components. Efficiency of the switching regulator is up from the linear, with a typical 83% transmission of power, although this depends on supply voltage.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/sm_traco-legs.jpg" class="kg-image" alt="How to Reduce Arduino Uno Power Usage by 95%"><figcaption><em>Bend the legs to match the pad position</em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/sm_regulator-pads.jpg" class="kg-image" alt="How to Reduce Arduino Uno Power Usage by 95%"><figcaption><em>Clip the NCP1117 and unsolder the remainder from the pads</em></figcaption></figure><!--kg-card-end: image--><p>Although the Traco TSRN-1 is not a pin compatible replacement, by bending the legs, it can be placed on and soldered to the surface mount pads where the NCP1117 has been removed from.</p><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/sm_traco-in-situ.jpg" class="kg-image" alt="How to Reduce Arduino Uno Power Usage by 95%"><figcaption><em>The Traco TSRN-1 switching regulator soldered in place</em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>Changing the regulator reduces the current usage of the board by <strong>48%</strong>. Although this reduction may vary, as the efficiency of the regulator varies, depending on the current demands of any driven circuit.</p>
<table>
<thead>
<tr>
<th>State</th>
<th>LED off</th>
<th>LED on</th>
</tr>
</thead>
<tbody>
<tr>
<td>Base UNO</td>
<td>53mA</td>
<td>55mA</td>
</tr>
<tr>
<td>Traco DC-DC</td>
<td>27.5mA</td>
<td>28.5mA</td>
</tr>
</tbody>
</table>
<p><em><strong>Table 2: Replacing the linear regulator.</strong></em></p>
<h2 id="usbtoserialconverter">USB to Serial converter</h2>
<p>In addition to the main ATmega328 microcontroller on the Arduino UNO board, there is also a USB-to-Serial converter chip, the ATmega16U2. This is a general purpose microcontroller with on-board USB capability that is programmed to act in this job.</p>
<p>Although the chip is suitable for use as a USB-to-Serial (UART) converter, no power saving measures are implemented on the chip, meaning that it remains in a full power idle when not being used. If the chip could be automatically powered down when not in use, this could significantly reduce the idle current draw of the whole board.</p>
<p>We decided not to investigate if the chip can be put into a low power mode via the firmware as updating the firmware on this chip requires a separate ISCP programmer and would not be as simple as uploading a new program to the main microcontroller via the Arduino IDE. Instead only hardware changes were investigated; though the restriction of maintaining functionality is required.</p>
<p>Like the main microcontroller, the UART chip is powered from the regulated 5V line, so it is powered from the USB line when only USB power is supplied, and is powered from the regulated DC input when present. A comparator and MOSFET perfect diode switch ensure only one source is selected.</p>
<p>From the Arduino UNO <a href="https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf">schematic</a>, the ATmega16U2 (U3 on the board) is powered through pins 32 &amp; 4 from the rectified 5V line. As this line is physically close to the USBVCC bus, the tracks on the PCB to pins 32 and 4 can be cut, and reconnected to USBVCC so the chip is only powered when voltage is present on the USB connection. Athough this is not a recommended power connection for the chip, as the USB supply voltage must be 5V ±0.2V, there should not be enough difference between the supply and any signal voltages to damage the chip.</p>
<p>First cut the 5V supply on the bottom of the board that supplies 5V to the 16U2 (to pin 32). This chip is a in a 32 pin package, where the pins are numbered anti-clockwise from the top left corner — indicated by a dot on the top of the package. The cut is made on a trace on the reverse, so the capacitor between pin 32 and ground is not separated from pin 32.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/sm_5V-16U2-supply.jpg" class="kg-image" alt="How to Reduce Arduino Uno Power Usage by 95%"><figcaption><em>Reveal the 5V supply for pin 32 without compromising C7</em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/sm_5V-16U2-cut.jpg" class="kg-image" alt="How to Reduce Arduino Uno Power Usage by 95%"><figcaption><em>Cut across the trace and remove the centre material</em></figcaption></figure><!--kg-card-end: image--><p>Pin 4 also needs to be separated from the 5V line, and can be done on the top layer of the board. At the same time, the track from pin 32 should be exposed along with an area of the track connected to pin 31, so pin 4 &amp; 32 can be connected to the USBVCC line of pin 31.</p><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/sm_16U2-stripped-traces.jpg" class="kg-image" alt="How to Reduce Arduino Uno Power Usage by 95%"><figcaption><em>Expose the traces on pins 4, 31 &amp; 32</em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/sm_pin4-16U2-cut.jpg" class="kg-image" alt="How to Reduce Arduino Uno Power Usage by 95%"><figcaption><em>Cut the trace from pin 4 without disconnecting the local capacitor</em></figcaption></figure><!--kg-card-end: image--><p>Pin 4 &amp; 32 can be connected back to pin 31 with a single jumper wire. By using 30AWG "wire wrap" solid core wire, cut to 13mm long with 2mm stripped back on each end and turned at 90 degrees in plane, the three connections can be made with one jumper wire.</p><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/sm_16U2-reconnected.jpg" class="kg-image" alt="How to Reduce Arduino Uno Power Usage by 95%"><figcaption><em>A 13mm long jumper wire with the ends stripped back by 2mm each connects the supply voltage to the USB supply only</em></figcaption></figure><!--kg-card-end: image--><p>Please note that just changing the supply source is not sufficient to completely remove the power usage from the chip. Because the RX and TX LEDs are connected to 5V and sink power through the ATmega16U2 when lit, removing power from the microcontroller means they will always be lit. The only choices then are to cut the traces to the LEDs or desolder them, so they cannot be used.</p><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/sm_clip-rx-tx.jpg" class="kg-image" alt="How to Reduce Arduino Uno Power Usage by 95%"><figcaption><em>Cut the RX and TX LED traces at the anode to prevent them sinking current through the unpowered ATmega16U2</em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>Changing the board so the UART converter is only powered from the USB connection — and therefore only uses power when the programming connection is made — reduces the power usage by <strong>44.7%</strong>. This change does not affect the programming of the board; when a computer is connected by USB, the chip is powered by the computer only, and the main ATmega328 can be programmed by the Arduino IDE as normal (although resetting the board can now cause the USB port to be renumbered by a connected computer).</p>
<table>
<thead>
<tr>
<th>State</th>
<th>LED off</th>
<th>LED on</th>
</tr>
</thead>
<tbody>
<tr>
<td>Base UNO</td>
<td>53mA</td>
<td>55mA</td>
</tr>
<tr>
<td>USB power the UART</td>
<td>29.2mA</td>
<td>31.5mA</td>
</tr>
</tbody>
</table>
<p><em>Table 3: Remove power to the ATmega16U2 UART converter.</em></p>
<h2 id="powerled">Power LED</h2>
<p>As the Arduino UNO is designed to be a development board, it has a continuous indicator that the board is powered using an always on LED. For low power usage, this continuous current drain is not required, but the LED can only be disabled by cutting a track on the PCB, or desoldering it from the board.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/sm_power-led.jpg" class="kg-image" alt="How to Reduce Arduino Uno Power Usage by 95%"><figcaption><em>Cut the track between the power indicator LED and the inline resistors</em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><table>
<thead>
<tr>
<th>State</th>
<th>LED off</th>
<th>LED on</th>
</tr>
</thead>
<tbody>
<tr>
<td>Base UNO</td>
<td>53mA</td>
<td>55mA</td>
</tr>
<tr>
<td>Disconnect LED</td>
<td>46mA</td>
<td>48mA</td>
</tr>
</tbody>
</table>
<p><em>Table 4: Disconnect the power indicator LED to lower current by 7mA.</em></p>
<h2 id="combined">Combined</h2>
<p>For the voltage regulator change, this is a largely geometric change, as the overall efficiency of voltage conversion is increased, although note that this is very non-linear. Total power reduction with all changes is <strong>76.8%</strong>.</p>
<table>
<thead>
<tr>
<th>State</th>
<th>LED off</th>
<th>LED on</th>
</tr>
</thead>
<tbody>
<tr>
<td>Base UNO</td>
<td>53mA</td>
<td>55mA</td>
</tr>
<tr>
<td>No LED, USB, Traco</td>
<td>12.3mA</td>
<td>13.2mA</td>
</tr>
</tbody>
</table>
<p><em>Table 5: Changing regulator, UART power and indicator LED.</em></p>
<h2 id="sleepmode">Sleep mode</h2>
<p>The power reduction from all three of the previous improvements is quite significant. The savings from the changes to the UART chip and power indicator LED both add up, as they are arithmetic reductions in the used power, as the components are no longer being powered by the source.</p>
<p>It is possible to make further savings though. Using all the above changes , and adding the lowest sleep mode for the ATmega328 micocontroller, the LED-off current usage of the board is reduced to <strong>2.5mA</strong>, a <strong>95%</strong> reduction compared to the standard board.</p>
<p>There are some great resources already for using sleep mode on the UNO. Here are some from my bookmarks:</p>
<ul>
<li><a href="http://www.engblaze.com/hush-little-microprocessor-avr-and-arduino-sleep-mode-basics/">engblaze.com/hush-little-microprocessor-avr-and-arduino-sleep-mode-basics/</a></li>
<li><a href="http://www.nongnu.org/avr-libc/user-manual/group__avr__sleep.html">nongnu.org/avr-libc/user-manual/group__avr__sleep.html</a></li>
<li><a href="https://jeelabs.org/pub/docs/jeelib/classSleepy.html">jeelabs.org/pub/docs/jeelib/classSleepy.html</a></li>
</ul>
<p>Happy battery powering…</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Hackday: Connecting Sensors with LoRaWAN]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Now there's a larger coverage area of <a href="https://www.thethingsnetwork.org/community/liverpool">LoRaWAN in Liverpool</a> that provides free access to the public The Things Network service, it's the ideal time to start connecting more devices, more sensors, and taking advantage of this long range, low power, low cost way of connecting devices to the internet.</p>]]></description><link>https://foxtrot.defproc.co.uk/blog/connecting-sensors-with-lorawan/</link><guid isPermaLink="false">5cd3ff41c3e3797874ba2ca1</guid><category><![CDATA[Tutorial]]></category><category><![CDATA[Arduino]]></category><category><![CDATA[LoRaWAN]]></category><category><![CDATA[The Things Network]]></category><dc:creator><![CDATA[Patrick Fenner]]></dc:creator><pubDate>Mon, 17 Jul 2017 12:33:00 GMT</pubDate><media:content url="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/LoRaWAN-2.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/LoRaWAN-2.jpg" alt="Hackday: Connecting Sensors with LoRaWAN"><p>Now there's a larger coverage area of <a href="https://www.thethingsnetwork.org/community/liverpool">LoRaWAN in Liverpool</a> that provides free access to the public The Things Network service, it's the ideal time to start connecting more devices, more sensors, and taking advantage of this long range, low power, low cost way of connecting devices to the internet.</p>
<p>The great <a href="https://github.com/TheThingsNetwork/arduino-device-lib">Arduino library</a> from The Things Network means that getting started with using LoRaWAN is just a matter of finding coverage and a LoRaWAN modem. At the current time though, the TTN hardware has not started shipping, so we made some <a href="https://github.com/ttn-liv/LoRaWANshield">LoRaWAN shields</a>, and ran <a href="https://www.meetup.com/iotliverpool/events/240479864/?">a hackday at DoES Liverpool</a> to get more people connected.</p>
<p>As is traditional in hackdays, progress on the day was captured in a shared document. While the main focus for many was on setting up their first LoRaWAN connection, and finding out how LoRaWAN might fit in with their project ideas, there were some great projects taking shape.</p>
<p>Links to the shared document:</p>
<ul>
<li><a href="https://hackmd.io/s/H1lA3HLrb">Original Hackmd.io document</a></li>
<li><a href="https://gist.github.com/DefProc/7eb552c299983d679451209a1bd4cd25">Github Gist at the end of the day</a></li>
</ul>
<h3 id="temperaturesensor">Temperature Sensor</h3>
<p>One of my focuses of the day was to complete an initial <a href="https://en.wikipedia.org/wiki/%22Hello,_World!%22_program">hello world</a> for those new to Arduino, or those looking for a base to start using LoRaWAN that goes from sensor to online recording.</p>
<p>Using a DS18B20 temperature sensor, take a reading, report it over LoRaWAN to The Things Network (TTN) using the <code>Cayenne</code> payload structure, set the payload interpreter to <code>Cayenne</code>, connect to myDevices Cayenne, and create a dashboard to show current temperature.</p>
<h4 id="gettingstarted">Getting started:</h4>
<ul>
<li><a href="https://www.arduino.cc/en/Main/Software">Arduino IDE</a></li>
<li><a href="https://github.com/TheThingsNetwork/arduino-device-lib">TTN library</a></li>
<li><code>Sketch</code> → <code>Include Library</code> → <code>Manage Libraries</code> → <code>The Things Network</code> → <code>install</code></li>
</ul>
<p>Device Info sketch for the Uno &amp; shield:</p>
<pre><code class="language-cpp">#include &lt;TheThingsNetwork.h&gt;
#include &quot;SoftwareSerial.h&quot;

// RN2483 pins on the LoRaWAN shield
#define RN_RX 2
#define RN_TX 3

//#define lora Serial1
SoftwareSerial lora(RN_RX, RN_TX); // RX, TX

#define debugSerial Serial
#define loraSerial lora

TheThingsNetwork ttn(loraSerial, Serial, TTN_FP_EU868);

void setup()
{
  debugSerial.begin(115200);
  loraSerial.begin(57600);
  delay(1000);
}   

void loop()
{
   debugSerial.println(&quot;Device Information&quot;);
   debugSerial.println();
   ttn.showStatus();
   debugSerial.println();
   debugSerial.println(&quot;Use the EUI to register the device for OTAA&quot;);
   debugSerial.println(&quot;-------------------------------------------&quot;);
   debugSerial.println();
   delay(10000);
}
</code></pre>
<ul>
<li>Make an account on <a href="https://account.thethingsnetwork.org/register">The Things Network</a>,</li>
<li>go to the <a href="https://console.thethingsnetwork.org/">TTN console</a></li>
<li>select <code>applications</code> and <code>+ add application</code></li>
<li>Set
<ul>
<li>Application ID (you'll need to use when you use the application),</li>
<li>Description (up to you)</li>
<li>Handler registration to <code>ttn-handler-eu</code></li>
</ul>
</li>
<li>From your application page, <code>+ register device</code>
<ul>
<li>Device ID (something you can uniquely identify that radio with),</li>
<li>Device EUI (reported from the sketch above),</li>
</ul>
</li>
<li>Then load a basic sketch onto your device to test the data transfer:</li>
</ul>
<pre><code class="language-cpp">#include &lt;TheThingsNetwork.h&gt;
#include &quot;SoftwareSerial.h&quot;

// Set your AppEUI and AppKey
const char *appEui = &quot;0000000000000000&quot;; // replace with your `App EUI`
const char *appKey = &quot;00000000000000000000000000000000&quot;; // replace with your `App Key`

// RN2483 pins on the LoRaWAN shield
#define RN_RX 2
#define RN_TX 3

//#define lora Serial1
SoftwareSerial lora(RN_RX, RN_TX); // RX, TX

#define debugSerial Serial
#define loraSerial lora

TheThingsNetwork ttn(loraSerial, Serial, TTN_FP_EU868);


void setup()
{
   loraSerial.begin(57600);
   debugSerial.begin(115200);

   // Wait a maximum of 10s for Serial Monitor
   while (!debugSerial &amp;&amp; millis() &lt; 10000)
     ;

   debugSerial.println(&quot;-- STATUS&quot;);
   ttn.showStatus();

   debugSerial.println(&quot;-- JOIN&quot;);
   ttn.join(appEui, appKey);
}

void loop()
{
   debugSerial.println(&quot;-- LOOP&quot;);

   // Prepare payload of 1 byte to indicate LED status
   byte payload[1];
   payload[0] = (digitalRead(LED_BUILTIN) == HIGH) ? 1 : 0;

   // Send it off
   ttn.sendBytes(payload, sizeof(payload));

   delay(10000);
}
</code></pre>
<ul>
<li>Load the sketch and watch on the serial monitor</li>
<li>Also watch on the <code>data</code> tab to see the incoming data</li>
</ul>
<h4 id="sendtemperature">Send temperature:</h4>
<ul>
<li>Add the <a href="https://www.pjrc.com/teensy/td_libs_OneWire.html">OneWire</a> and <a href="https://github.com/milesburton/Arduino-Temperature-Control-Library">DallasTemperature</a> libraries to the Arduino IDE,</li>
<li>Connect the <code>DS18B20</code> sensor to power, ground, and the signal wire to pin <code>D6</code> on the arduino (or another of your choice),</li>
<li>connect a <code>4.7k</code> resistor between power and the signal line (this is requred for proper opperation of the sensor, but in a pinch you'll probably get away with two 10k resistors in parallel),</li>
<li>load the following sketch (after changing the <code>appEui</code> and <code>appKey</code>) to match your application:</li>
</ul>
<blockquote>
<p>This example uses the Cayenne LPP format so it can be recreated back into a JSON objects without having to do any custom float to <a href="https://www.thethingsnetwork.org/docs/devices/bytes.html">byte array translation or javascript re-building</a></p>
</blockquote>
<pre><code class="language-cpp">#include &lt;SoftwareSerial.h&gt;
#include &lt;TheThingsNetwork.h&gt;
#include &lt;CayenneLPP.h&gt;
#include &lt;OneWire.h&gt;
#include &lt;DallasTemperature.h&gt;

// Set your AppEUI and AppKey
const char *appEui = &quot;0000000000000000&quot;;
const char *appKey = &quot;00000000000000000000000000000000&quot;;

// RN2483 pins on the sensor dev shield
#define RN_RX 3
#define RN_TX 4

// Data wire is plugged into port 6 on the Arduino
#define ONE_WIRE_BUS 6

SoftwareSerial lora(RN_RX, RN_TX); // RX, TX

#define loraSerial lora
#define debugSerial Serial

TheThingsNetwork ttn(loraSerial, debugSerial, TTN_FP_EU868);
CayenneLPP lpp(51);

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&amp;oneWire);

// arrays to hold device address
DeviceAddress deviceAddress;

void setup()
{
   loraSerial.begin(57600);
   debugSerial.begin(115200);

   // Wait a maximum of 10s for Serial Monitor
   while (!debugSerial &amp;&amp; millis() &lt; 10000)
     ;

   // Get device address
   if (!sensors.getAddress(deviceAddress, 0)) Serial.println(&quot;Unable to find address for Device 0&quot;);

   // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions)
   sensors.setResolution(deviceAddress, 12);

   debugSerial.println(&quot;-- STATUS&quot;);
   ttn.showStatus();

   debugSerial.println(&quot;-- JOIN&quot;);
   ttn.join(appEui, appKey);
}

void loop()
{
   debugSerial.println(&quot;-- LOOP&quot;);

   // get the current temperature
   sensors.requestTemperatures();
   float degC = sensors.getTempC(deviceAddress);
   debugSerial.println(degC, 6);

   lpp.reset();
   lpp.addTemperature(1, degC);

   // Send it off
   ttn.sendBytes(lpp.getBuffer(), lpp.getSize());

   delay(30000);
}
</code></pre>
<ul>
<li>New messages should appear in the application, data on the console with the a <code>&quot;temperature_1: xx.x&quot;</code> visible in the processed payload,</li>
<li>In the <a href="https://console.thethingsnetwork.org/">Things Network Console</a> for your application set the <code>Payload Formats</code> to be <code>Cayenne LPP</code>,</li>
<li>Create an account at <a href="https://mydevices.com/cayenne/signup/">myDevices Cayenne</a></li>
<li><code>Add new</code> → <code>Devices &amp; Wigets</code> → <code>LoRa (beta)</code> → <code>The Things Network</code> → <code>Cayenne LPP</code></li>
<li>Enter the <code>Device EUI</code> from the TTN console,</li>
<li>Back on the TTN console for the application → <code>Applications</code> → <code>+ add integration</code> → choose <code>Cayenne</code>,
<ul>
<li>Enter a <code>Process ID</code> of your choice (anything),</li>
<li>Select an <code>Access Key</code> (one of the allowed MQTT passwords on the application to pass to Cayenne)</li>
</ul>
</li>
<li>New data from this device will automatically propogate to myDevices Cayenne, so entries for <code>temperature</code>, <code>RSSI</code> and <code>SNR</code> for this device will appear when it next sends.</li>
<li>Many attendees found that receiving mesages using  <a href="https://www.thethingsnetwork.org/docs/applications/nodered/quick-start.html">node-red</a> provided more flexibility in pricessing and using messages.</li>
</ul>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Things North Wins the Big Chip IoT Impact Award]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p><a href="http://thingsnorth.org.uk/">Things North</a> is a loose association of <a href="https://www.thethingsnetwork.org/country/united-kingdom/">The Things Network communities</a> spread across the north of England. As an umbrella collective, it is interested in spreading public access to LoRaWAN networks across the wider area (somewhat coinciding with the range of the <a href="http://www.makerbelt.org.uk/">UK Maker Belt</a>), but it also acts as</p>]]></description><link>https://foxtrot.defproc.co.uk/blog/things-north-big-chip/</link><guid isPermaLink="false">5cd3ff41c3e3797874ba2ca7</guid><category><![CDATA[The Things Network]]></category><category><![CDATA[Awards]]></category><category><![CDATA[Update]]></category><dc:creator><![CDATA[Patrick Fenner]]></dc:creator><pubDate>Mon, 19 Jun 2017 16:21:00 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p><a href="http://thingsnorth.org.uk/">Things North</a> is a loose association of <a href="https://www.thethingsnetwork.org/country/united-kingdom/">The Things Network communities</a> spread across the north of England. As an umbrella collective, it is interested in spreading public access to LoRaWAN networks across the wider area (somewhat coinciding with the range of the <a href="http://www.makerbelt.org.uk/">UK Maker Belt</a>), but it also acts as a nice way of including the disparate communities in the area together under a single banner.</p>
<p>Under <a href="https://twitter.com/thingsnorth">Things North</a>, the whole region was entered in to the <a href="http://bigchipawards.com/winners-2017">Big Chip Awards</a> under the <a href="http://bigchipawards.com/big-chip-iot-impact-award">Big Chip IoT Impact Award</a> with <a href="https://twitter.com/ttn_liv">ttn_liv</a> asked to go along to the ceremony. And I'm very pleased to say that Things North won.</p>
<p>While it was nice to represent the Liverpool area at the awards, getting such recognition for the larger Things Network project from members of the digital industry shows and recognises that there is great value in creating and sharing a community owned, public network for Internet of Things use.</p>
<p>Unfortunately, the number of trophies awarded for each winner is only one, and the decentralised nature of the communities means that there is no good way of spreading that one physical item around all the people and areas that are investing in the network and driving it forward.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: embed--><figure class="kg-card kg-embed-card"><blockquote class="twitter-tweet"><p lang="en" dir="ltr">We won. Well done all <a href="https://twitter.com/thethingsntwrk?ref_src=twsrc%5Etfw">@thethingsntwrk</a> communities. We&#39;ll work out a rota. <a href="https://t.co/1M0NZ3rvSu">pic.twitter.com/1M0NZ3rvSu</a></p>&mdash; ThingsNorth (@ThingsNorth) <a href="https://twitter.com/ThingsNorth/status/875468967405649922?ref_src=twsrc%5Etfw">June 15, 2017</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</figure><!--kg-card-end: embed--><!--kg-card-begin: markdown--><p>Fortunately this is a problem that we can solve with lasers!</p>
<p>I've created a replica trophy that can be laser cut from clear acrylic sheet. And — in keeping with the distributed nature of Things North, and The Things Network, — have made he source file available so <em>any</em> TTN community can share the the award.</p>
<p>Presenting: <a href="https://github.com/ttn-liv/small-big-chip-award">The Small Big Chip Award</a>.</p>
<p>Of course, if you can build your own award, you can even scale it to fit the amount of trophy space you have available..</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/micro_award.jpg" class="kg-image"><figcaption><em>Mini awards for supporting mini-figs</em></figcaption></figure><!--kg-card-end: image-->]]></content:encoded></item><item><title><![CDATA[Sensing Nerf Darts]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>If you're going to build a foam dart range, then at some point you're going to have to build a some kind of sensor to be able to register the hits at the target. When we originally started this (with <a href="https://foxtrot.defproc.co.uk/blog/projects/mfuklc">MFUKLC</a>), we started by looking around at what other people</p>]]></description><link>https://foxtrot.defproc.co.uk/blog/sense-foam-dart/</link><guid isPermaLink="false">5cd3ff41c3e3797874ba2ca8</guid><category><![CDATA[Made Invaders]]></category><category><![CDATA[Analysis]]></category><category><![CDATA[Impact Sensor]]></category><category><![CDATA[MFUKLC]]></category><dc:creator><![CDATA[Patrick Fenner]]></dc:creator><pubDate>Wed, 08 Mar 2017 15:23:00 GMT</pubDate><media:content url="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/fet_buffer-1.png" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/fet_buffer-1.png" alt="Sensing Nerf Darts"><p>If you're going to build a foam dart range, then at some point you're going to have to build a some kind of sensor to be able to register the hits at the target. When we originally started this (with <a href="https://foxtrot.defproc.co.uk/blog/projects/mfuklc">MFUKLC</a>), we started by looking around at what other people had already done.</p>
<ul>
<li><a href="http://www.instructables.com/id/Pringle-Can-MIDI-Drums/?ALLSTEPS">Pringle can MIDI drums</a>, which uses raw piezo input to trigger MIDI signals;</li>
<li><a href="http://www.superfunadventurequesttime.com/projects/2013/reactive_targets/">Reactive Targets for 6mm Airsoft and NERF™</a>, which actually uses the sensor from some earlier work on <a href="http://web.archive.org/web/20120718053917/http://leucos.lstilde.org/wp/2009/06/piezo-transducer-signal-conditioning">piezo transducer signal conditioning</a> from Leucos — this has since fallen off the web and was only available via the Internet Archive Wayback Machine — to produce contitioned pulses from piezo input.</li>
</ul>
<p>After seeing his presentation at <a href="http://2016.wutheringbytes.com/">Wuthering Bytes 2016</a>, I found out about a slightly different approach in Seb Lee-Delisle's <a href="http://seb.ly/2014/03/margate-games-lazer-arcade-video-and-photos/">Lazer Arcade</a>, which uses piezo contact microphones and multi-lateration to locate the exact position of a hit on a 2D area.</p>
<p>Since we built <a href="https://foxtrot.defproc.co.uk/blog/projects/made-invaders">Made Invaders</a>, we've also seen other approaches to sensing foam dart impacts:</p>
<ul>
<li><a href="https://hackaday.io/project/8478-star-wars-nerf-targets">Star Wars Nerf targets</a>, which again use raw piezo input,</li>
<li><a href="https://hackaday.io/project/8478-star-wars-nerf-targets">Arduino Nerf target alarm clock</a> — this actually counts the signal pulses and timing to differentiate between a finger press and a weighted impact.</li>
</ul>
<p>While there are newer approaches, we still feel that the one-board analog conditioned signal provides (derived form piezo-transducer-signal-conditioning) the most reliable and robust foam dart impact sensing. Our tests with thousands of impacts in public facing events has shown that the sensor described below registers <em>every</em> valid impact, while rejecting pushes, presses, and even many finger taps.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/circuit-whole.png" class="kg-image" alt="Sensing Nerf Darts"></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><h1 id="piezoimpactsignal">Piezo impact signal</h1>
<p>The first part in all these sensors is using a piezo element that is attached to the impact area. When the target object is hit, this causes the piezo element to vibrate, and this results in a voltage signal across the piezo.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/circuit-piezo.png" class="kg-image" alt="Sensing Nerf Darts"></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>When a voltage is applied across a piezo element, the different charge between the two metal plates either side of the piezo crystal causes the crystal to change shape slightly, making the plates get slightly closer together, or slightly further apart. By changing the voltage at a set frequency, the piezo will induce air pressure changes around it at the same rate, giving out a horrible, square wave sound with that note.</p>
<p>Like many electronic devices though, a piezo element can work as an input as well. If the distance between the two plates changes, this will cause the charges on the plates to change, causing a voltage difference between the two leads. If the piezo is stuck to a surface and then tapped, the output voltage might look something like the image below.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/impact-noise.png" class="kg-image" alt="Sensing Nerf Darts"></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>In this raw form, the main problem that we have with this signal is that it contains both positive and negative voltages. While the energy involved is very small, microcontrollers (as a rule) don't like negative voltages, so before passing this signal into the input pin of a device, it should at least be rectified to be positive voltages only.</p>
<h1 id="rectifiedsignal">Rectified signal</h1>
<p>Making sure there is only positive voltage is the job of diodes D1 and D2.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/circuit-rectify.png" class="kg-image" alt="Sensing Nerf Darts"></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>We could force all the voltage to be positive with by using a full bridge rectifier, but I'm not too worried about efficiency. Here, D2 makes sure that the voltage in the upper line is always higher than the bottom (otherwise D2) conducts to equalise the voltage. And D1 makes sure that the signal goes towards the output signal line, rather than just shorting across the piezo.</p>
<p>The circuit uses Shottky diodes for these as they have a low forward voltage (so they don't reduce the voltage of the signal too much) and they are fast recovery diodes, so they are particularly suited to rapidly inverting voltages.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/impact-rectified.png" class="kg-image" alt="Sensing Nerf Darts"></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><h1 id="voltageclipping">Voltage clipping</h1>
<p>The signal is much better now that there are no negative voltages, but the possibility still remains of having very large voltages as part of the impact signal. While the pulse duration is very short, and therefore the risk of any damage to an attached device is low, we want any sensor output to be safe to go into a microcontroller in <em>all</em> situations, so it would be remiss to leave large voltage inputs as possibility.</p>
<p>In testing, I did see peaks of 30 and 40V from just tapping a piezo with my nail. As the signal is very noisy, the values were not repeatable, but voltages in that range were very common during testing.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/circuit-clipping.png" class="kg-image" alt="Sensing Nerf Darts"></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>A zener diode is specifically designed to allow current to pass in the reverse direction once the voltage passes a set threshold. While this happens with all diodes (the <em>reverse breakdown voltage</em>), zeners are particularly designed so that this happens at a specific, tuned voltage (depending on the specification) and can happen repeatedly, without damage to the diode.</p>
<p>For the circuit I used, I chose a 5.1V zener, to limit the voltage to go directly into a 5V Arduino, but a 3.3V zener would be appropriate for a 3.3V powered device.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/impact-clipped.png" class="kg-image" alt="Sensing Nerf Darts"></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><h1 id="pulsesignal">Pulse signal</h1>
<p>While the noise signal is now safe to pass into a microcontroller; as it is currently, the microcontroller will still need to do an amount of signal processing to determine the characteristics of the hit. In my initial install, I was feeding the result from 16 sensors into a single Arduino Mega, and wanted to be able to scan through each sensor every 10ms to make sure that I didn't miss <em>any</em> impacts.</p>
<p>Rather than using the raw signal, the sensor circuit includes a parallel resistor and capacitor pair. Having the capacitor there gives a &quot;charge bucket&quot; into which electrical energy can be stored. And having a high resitance path across the capacitor means that the capacitor will discharge &quot;slowly&quot; at a known rate.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/circuit-pulse.png" class="kg-image" alt="Sensing Nerf Darts"></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>Having this resitor-capacitor (RC) pair allows the incoming voltage signal to charge up the capacitor, while the resistor will slowly equalise the voltage across the lines. The specific pair here (4.7nF &amp; 1MΩ) will cause the capacitor to have discharged by 90% over 10ms, meaning that any input signal will have mostly decayed over 10ms, ready for another signal to be received.</p>
<p>Using the RC pair like this changes the noisy signal into a charge and decay pulse that can be ready by a high impedance (input mode) microcontroller pin.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/impact-pulse.png" class="kg-image" alt="Sensing Nerf Darts"></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><h1 id="reliability">Reliability</h1>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/pcb_rev2.png" class="kg-image" alt="Sensing Nerf Darts"></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>We actually used this imput directly into the 16 analog inputs of an Arduino Mega for the first version of the <a href="https://foxtrot.defproc.co.uk/blog/projects/mfuklc">foam dart range</a> — although that did require speeding up the analog to digital converter to it's maximum rate to be able to scan <em>all</em> 16 inputs <em>every</em> 10ms. The code then looked for the signal going above a certain threshold, and counting a hit if it hadn't already done so within the last 10ms.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/fet_buffer.png" class="kg-image" alt="Sensing Nerf Darts"></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>This all worked fine for most of the installations, but we were continually re-tuning the threshold level for reliability. For the <a href="https://foxtrot.defproc.co.uk/blog/projects/made-invaders">second version</a> we added a FET buffer on the receiving board, so the signal would be digitally triggered once the voltage reached the on-voltage of the FET (around 0.7V) and fed that into an interrupt pin on the Arduino. As we'd changed to having a controller on each target to run the LED display, and report hits via radio back to the main controller, changing to an interrupt means we always read hits over the impact threshold.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/impact-signal.png" class="kg-image" alt="Sensing Nerf Darts"></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>The FET buffer gives a clear logic low when the sensor pulse goes above 0.7V, which returns to logic high when the sensor pulse drops below 0.7V. And because of this threshold, coupled with the size of the capacitor, it will only trigger from a sharp pulse of a high enough energy. If you hit this sensor with a dart (or flick it <em>very hard</em> with your finger) it will trigger reliably, but if pressed or pushed, the voltage in the capacitor doesn't reach the trigger threshold, and no signal is passed.</p>
<p>The other change for installation that we did make was to add a single M6 nut glued to the back plate of the piezo. While it does work without, the additional mass across the piezo causes larger deflections in it, giving more energy to the signal and increasing the reliability of the input.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[TTN Liverpool is Official]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>With the placement of Liverpool's first permanent LoRaWAN gateway, and the launch announcement of The Things Network Liverpool at <a href="https://www.meetup.com/iotliverpool/events/237699221/">IoT Liverpool</a> just over a week ago, there's been a clear movement forward at the Liverpool outpost of The Things Network. The additional interest from the event, coupled with setting up</p>]]></description><link>https://foxtrot.defproc.co.uk/blog/ttn-liv-official/</link><guid isPermaLink="false">5cd3ff41c3e3797874ba2ca9</guid><category><![CDATA[The Things Network]]></category><category><![CDATA[Update]]></category><dc:creator><![CDATA[Patrick Fenner]]></dc:creator><pubDate>Thu, 02 Mar 2017 12:00:00 GMT</pubDate><media:content url="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/ttn-1.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/ttn-1.jpg" alt="TTN Liverpool is Official"><p>With the placement of Liverpool's first permanent LoRaWAN gateway, and the launch announcement of The Things Network Liverpool at <a href="https://www.meetup.com/iotliverpool/events/237699221/">IoT Liverpool</a> just over a week ago, there's been a clear movement forward at the Liverpool outpost of The Things Network. The additional interest from the event, coupled with setting up a <a href="https://thethingsnetwork.slack.com/messages/liverpool/">dedicated slack channel</a> and announcement <a href="https://www.thethingsnetwork.org/forum/t/ttn-liverpool/5769/2">forum post</a>, the Liverpool community has now passed the thresholds to become registered as an <a href="https://www.thethingsnetwork.org/community/liverpool/post/the-things-network-liverpool-becomes-official">official Things Network community</a>.</p>
<p>This has made us the 5th established community in the UK, out of 35 towns and cities that have set up communities so far around the country. I think that it is a measure of the level of interest in Internet of Things in Liverpool, and particularly the businesses and individuals working out of and around <a href="http://doesliverpool.com">DoES Liverpool</a> that we have a fledgling LoRaWAN network off the ground and in use without any public funding so far.</p>
<p>On to the building the next set of gateways!</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[The Things Network Liverpool]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>“There’s a LoRa LoRA...WAN in Liverpool”</p>
<p>We are the initiator for the <a href="https://www.thethingsnetwork.org/community/liverpool/">Things Network Liverpool community</a> and we shall be launching in February 2017, at the <a href="https://www.meetup.com/iotliverpool/">IoT Liverpool event</a> , our first outdoor LoRaWAN gateway, offering enhanced coverage across Liverpool. We would love to hear from anyone looking to</p>]]></description><link>https://foxtrot.defproc.co.uk/blog/ttn-liverpool/</link><guid isPermaLink="false">5cd3ff41c3e3797874ba2caa</guid><category><![CDATA[The Things Network]]></category><category><![CDATA[LoRaWAN]]></category><dc:creator><![CDATA[Les Pounder]]></dc:creator><pubDate>Fri, 10 Feb 2017 12:00:00 GMT</pubDate><media:content url="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/ttn-2.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/ttn-2.jpg" alt="The Things Network Liverpool"><p>“There’s a LoRa LoRA...WAN in Liverpool”</p>
<p>We are the initiator for the <a href="https://www.thethingsnetwork.org/community/liverpool/">Things Network Liverpool community</a> and we shall be launching in February 2017, at the <a href="https://www.meetup.com/iotliverpool/">IoT Liverpool event</a> , our first outdoor LoRaWAN gateway, offering enhanced coverage across Liverpool. We would love to hear from anyone looking to start their own gateway, especially if they have a high roof offering a greater range for the service.</p>
<p>Connecting a device to the Internet has become easier in recent years. Now we see appliances such as refrigerators and washing machines offering online connectivity to fit into our ever busy lives. Typically these devices need an always on connection to the Internet via WiFi or Ethernet, but one network offers long range connectivity using radio, and can be powered for upto 10 years using a battery!</p>
<p>The Things Network a project that started life in the Dutch city of Amsterdam, was founded to create a community led city wide <a href="http://thethingsnetwork.pr.co/108437-the-things-network-launches-world-s-first-crowdfunded-internet-of-things-data-network-in-amsterdam-and-the-world-is-next">Internet of things network</a> using approximately ten LoRaWAN (Long Range Wireless Area Network) gateways that provide a connection back to the Internet. These gateways offered long distance connections for Internet of Things (IoT) devices, often referred to as &quot;nodes&quot; that can report data from many types of sensors and then transmit the information using a LoRaWAN radio to the nearest gateway. The project then crowdsourced funds to produce lower cost hardware, lowering the barrier of entry for those interested in connecting their devices to the network. By encouraging the public to fund the project, it helped the community take ownership of the gateways, providing a low cost point of entry where the community provide access to other projects using the LoRaWAN platform.</p>
<p>Getting on to the Things Network using LoRaWAN is becoming simpler, and now you just need the right hardware, which can be powered by Arduino or Raspberry Pi, and an account on the <a href="https://www.thethingsnetwork.org/">Things Network website</a> where you can setup a receiving channel, enabling your device to broadcast to the nearest Things Network gateway, which then handles sending the data over the network, via a simple console or something more advanced such as MQTT, to listening devices.</p>
<p>But what if there isn't a gateway near you? Well the cost of the equipment is a one off expense, you can buy a prebuilt unit from The Things Network for around £300, or build your own using a Raspberry Pi and an add on condenser board for around £500, this is for an external unit with a waterproof case and antenna, but you can get the internal version for around £300. A Raspberry Pi based gateway can comfortably handle up to 20000 nodes! Enough capacity for a town or a small city. There are also units available from companies such as Microchip but at a much higher cost.</p>
<p>Liverpool has had their own LoRaWAN gateway for nine months, &quot;soft launched&quot; as part of an IoT Liverpool event in March 2016. For 2017 we see more gateways being added to the Liverpool network, but this time they will mounted outdoors and used by interested parties and as part of making Liverpool “sensor city”. We are helping businesses and interested parties to take their first steps using LoRaWAN in their projects, so that everyone can get their device on the network and benefit from additional gateways.</p>
<p>But why does Liverpool need LoRaWAN? Well LoRaWAN is the easiest option as the hardware does not require a special NDA, and you can deploy your own gateway for easy access to the Internet. Others such as Sigbox, and another solution called <a href="https://en.wikipedia.org/wiki/LPWAN">NarrowBand IOT</a>, offer similar services but can involve proprietary technologies protected by NDA (Non Disclosure Agreements). For Liverpool the LoRaWAN option was the ideal solution, offering low power radio connections between 2km (urban) and 12km (line of sight) and an easy method where the devices connect using a predefined code, without the need for passwords or login, the devices connect by themselves and can be moved from one gateway to another with no changes to their setup, truly remarkable and once again lowering the barrier to entry!</p>
<p>So using LoRaWAN what can you send over the network? Well being a low bandwidth platform, video and voice data are out of the question, but you can easily send up to a maximum of 60 bytes, but ideally 12 bytes of data, plenty of capacity for sensor data to be transmitted to The Things Network where it can be translated into JSON data. Data can also be sent back to devices on the LoRaWAN network, though there is a slight delay.</p>
<p>The need for a large LoRaWAN network in Liverpool exists for businesses looking to use LoRaWAN in their products, and this is something that can be easily addressed with a small amount of investment and it would benefit businesses and interested individuals accordingly. There are services that operate a &quot;paid for&quot; model, but there are also free services available. Currently we are standardising a build process that uses the Raspberry Pi computer housed inside of a waterproof container with an aerial to make it even easier to deploy your own outdoor gateway. If there isn't access near you then we can help you setup access!</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[About Made Invaders]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>In the 1970s and 80s shooting galleries that used simple light detection were everywhere. The rifle would emit a simple pulse of light, and if that light happened to strike a sensor it would trigger a sequence of automated actions, typically involving sound a simple movement of mannequins. This humble</p>]]></description><link>https://foxtrot.defproc.co.uk/blog/about-made-invaders/</link><guid isPermaLink="false">5cd3ff41c3e3797874ba2cab</guid><category><![CDATA[Made Invaders]]></category><category><![CDATA[Arduino]]></category><dc:creator><![CDATA[Les Pounder]]></dc:creator><pubDate>Sun, 15 Jan 2017 08:00:00 GMT</pubDate><media:content url="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/MIicon.png" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/MIicon.png" alt="About Made Invaders"><p>In the 1970s and 80s shooting galleries that used simple light detection were everywhere. The rifle would emit a simple pulse of light, and if that light happened to strike a sensor it would trigger a sequence of automated actions, typically involving sound a simple movement of mannequins. This humble game was brought into the 21st century using microcontrollers, Raspberry Pi and wireless radio communications. But why was it made and what did it take to bring it to life?</p>
<p>Made Invaders was a research and development project that was created to showcase the skills and talents of the makers that make up DoES Liverpool. Costing £1000 this project came to life as we wanted to create a another large project that would accurately show the diverse skills that DoES contains. We worked on electronics, laser cut construction pieces, player registration software, vinyl art decoration. All of this was made possible thanks to the makers, hackers and artists that make up our community at DoES.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/range_in_play.jpg" class="kg-image" alt="About Made Invaders"><figcaption><em>The Made Invaders range in play</em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>Made Invaders is a real life, full size shooting range, a cross between Space Invaders and Time Crisis. Housed inside of a 3㎡ enclosure we have a firing range full of reactive targets designed and built using a laser cutter and housing electronics that react to impacts and display digital explosions. Players receive 30 seconds to hit as many targets as possible using safe foam darts, enabling even young children to play safely.</p>
<p>To control the game there is a main controller, housed inside a custom laser cut frame, which uses the radio module from a Low Power Labs Moteino MEGA microcontroller board. The Arduino IDE was used to program the Moteino and the targets, a widely supported application with an extensive community of makers, artists and hackers. The Arduino platform is used throughout this project to power the controller and targets. We also have a Raspberry Pi running Node-RED, a visual language that uses a flowchart type interface to connect devices across a local or worldwide network. The Raspberry Pi is used to power a registration system, enabling the player to start the game by entering their name and Twitter handle, which is then linked to an RFID tag and used to uniquely identify the player and ensure that their score is recorded correctly. Once ready the player will hit the start button, triggering 15 targets to life and setting the countdown timer to 30 seconds. The countdown timer and the score display each have a Moteino inside and drives a series of 7 segment display to show the game time and player score. To signal the start of the game we play a quick piece of audio and then the players are ready to fire! After 30 seconds of action, involving many foam darts being fired, the player's score is displayed and the player's receive a tweet containing their personal score. We even added the facility for players photographs to be taken, and while this feature was fun, we found that players weren't as interested, so we pulled it from the final version.</p>
<p>The targets themselves are pixelated characters created using a 9 x 9 grid of LED lights. The target characters are created using over 40 bitmap images that are converted for use with the lights. This gives the player multiple targets that change when they are hit. Inside the targets we have a custom printed circuit board (PCB) which replicates some of the Moteino functionality, using a compatible microcontroller and an RFM69 radio module used to send data over packet radio to the main controller. The connection from the controller to the targets is completely wireless enabling easy transportation and storage. The PCB also has an SD card slot and a connection for the grid of LEDs. To register an impact we use a piezo element to detect the impact, generating a slight increase in voltage which is then manipulated to create a pulse so that the player can &quot;see&quot; the impact in much the same manner as a drum sensor operates.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: html--><div style="position: relative; width: 100%; height: 0px; padding-bottom: 56.25%">
  <iframe style="position: absolute; top: 0; left: 0; width: 100%; height: 100%" src="https://www.youtube.com/embed/GgHw0ey21Qk" frameborder="0" allowfullscreen></iframe>
</div><!--kg-card-end: html--><!--kg-card-begin: markdown--><p>This superb project was made possible thanks to the hard work and dedication of those that make up DoES Liverpool. If you would like to know more about DoES then come along and say hi. If you would like to have a go on Made Invaders then keep an eye on our Twitter account <a href="https://twitter.com/madeinvaders">@MadeInvaders</a> to see where it will pop up next.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Cheerlights Tower]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>As is traditional at Christmas here at DefProc, we attempt a small project to build a new fun, festive item. While this is spuriously titled as a <a href="https://foxtrot.defproc.co.uk/blog/tag/5-minute-projects/">5 minute project</a>, they typically take a few days to pull everything together.</p>
<p>We've previously done projects such as the <a href="https://foxtrot.defproc.co.uk/blog/cheertree/">cheertree</a>, using the</p>]]></description><link>https://foxtrot.defproc.co.uk/blog/cheerlights-tower/</link><guid isPermaLink="false">5cd3ff41c3e3797874ba2cac</guid><category><![CDATA[5 Minute Projects]]></category><category><![CDATA[Arduino]]></category><category><![CDATA[Raspberry Pi]]></category><category><![CDATA[IoT Device]]></category><category><![CDATA[DoES Tower]]></category><dc:creator><![CDATA[Patrick Fenner]]></dc:creator><pubDate>Thu, 22 Dec 2016 08:11:00 GMT</pubDate><media:content url="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/image.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/image.jpg" alt="Cheerlights Tower"><p>As is traditional at Christmas here at DefProc, we attempt a small project to build a new fun, festive item. While this is spuriously titled as a <a href="https://foxtrot.defproc.co.uk/blog/tag/5-minute-projects/">5 minute project</a>, they typically take a few days to pull everything together.</p>
<p>We've previously done projects such as the <a href="https://foxtrot.defproc.co.uk/blog/cheertree/">cheertree</a>, using the <a href="http://cheerlights.com/">Cheerlights</a> protocol for globally synchronised Christmas lights, and I still really like this as an easy way to get internet input to something that is also being used by others around the world. But we've already built tree structures, and even run light strings up the centre of a full size tree.</p>
<p>This year, we've taken the <a href="https://foxtrot.defproc.co.uk/blog/projects/does-tower">DoES Tower</a> — normally twitter controlled through its own account <a href="https://twitter.com/doestower">@DoES Tower</a> — and included the cheerlights protocol to make a festive addition to the office in <a href="https://doesliverpool.com">DoES Liverpool</a>.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/cheerbeacon.jpg" class="kg-image" alt="Cheerlights Tower"><figcaption><em>DoES Tower in the DoES Liverpool Office (see also: <a href="https://wiki.nottinghack.org.uk/images/2/28/DoNotBeOnFire.pdf">Rule Zero</a>)</em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><h2 id="control">Control</h2>
<p>The DoES Tower has 3 sets of addressable RGB LED strings inside (actually WS2812b based strip, which is the same as off-brand Neopixels), two sit behind the letter blocks that spell out &quot;DoES Liverpool&quot; around the circumference of the tower cupola and the third that faces downwards through floodlight holes that are present on the full size tower. Inside, an Arduino Uno and WiFi shield cycle through a lovely set of random colour changes for the letters, and read an MQTT stream and set the downlight colours to the retreived hex value.</p>
<p>Having an MQTT stream means that the Arduino gets push messaging, and is much more flexible that reading the Cheerlights page regularly, because any of the 16 million possible colour combinations can be set directly via MQTT, rather that relying on rapid polling of the 9 colours available from Cheerlights.</p>
<p>To perform the actions of checking the twitter stream for messages, setting the MQTT colour, taking pictures of the tower and then replying to incoming tweets is not handled by the Arduino on board. Instead, a Raspberry Pi that is physically nearby runs a <a href="http://nodered.org/">node-red</a> flow. This means the logic is handed by a small computer, rather than being shoehorned into a small microcontroller, and the tower acts as a device that just sets the colour it's instructed to, and the programming logic is handled elsewhere.</p>
<h2 id="makingcheerbeacon">Making Cheerbeacon</h2>
<p>Other that replacing the Arduino WiFi shield with a spare — as the 3.3V regulator on the board had burned out in use(!) — I didn't want to change anything in the tower or tower firmware. The original firmware from <a href="https://github.com/brettlempereur">@brettlempereur</a> is already fantastic, and does everything that's needed from the tower.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: image--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://foxtrot.defproc.co.uk/blog/content/images/2019/04/cheerbeacon-flow-small-1.png" class="kg-image" alt="Cheerlights Tower"><figcaption><em>The Cheerbeacon flow for Node-Red</em></figcaption></figure><!--kg-card-end: image--><!--kg-card-begin: markdown--><p>Instead, I adjusted the <a href="https://github.com/brett-lempereur/beaconbot/blob/master/beaconbot.json">original node-red flow</a> to change the program logic. As we're not at a show, I removed the image code, and added in a regular check of the cheerlights api page to forward any of the cheerlights changes to the same MQTT feed that the Tower normally listens to. And just for testing, added a few inject nodes to be able to locally set the colour to red, green or blue.</p>
<p>Because this is MQTT, the tower gets a push message every time the broker gets an updated message, and this happens immediately. This is unlike the cheerlights, where the lights will only update when the controller next polls the cheerlights api page.</p>
<p>If you'd like to use the same MQTT feed (with no guarantees of uptime), the settings are stored in the <a href="https://github.com/brett-lempereur/beaconbot/blob/master/arduino/src/sketch.ino">Arduino sketch</a> file:</p>
<pre><code>MQTT_ID = &quot;arduino-beaconbot&quot;;
MQTT_SERVER = &quot;m20.cloudmqtt.com&quot;;
MQTT_PORT = 11475;
MQTT_USER = &quot;arduino&quot;;
MQTT_PASSWORD = &quot;arduinopassword&quot;;
MQTT_TOPIC = &quot;beacon/colour&quot;;
</code></pre>
<p>The flow downloads the colour definitions and response messages from github, so I also uploaded messages in the beaconbot repo to make it more #cheerlights related.</p>
<p>The flow is available to import directly from the <a href="https://github.com/brett-lempereur/beaconbot/blob/master/cheerbeacon.json">beaconbot github repo</a>.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item></channel></rss>