Skip to main content

A Simple Factory BlinkUp Fixture

A Basic imp-based Device For Configuring Devices Under Test

Whether you are testing your Connected Factory Process, or are in production, you use a BlinkUp™ fixture to prepare Devices Under Test (DUTs) to load and run their factory firmware. It does this by sending to the DUT a factory Enrollment Token and, if required, factory WiFi credentials. This data is transmitted optically via an LED attached to the fixture.

  • If you are unfamiliar with the Electric Imp Connected Factory Process, please take a moment to read our brief overview, which includes a full glossary of the terminology you will encounter here.

At its most basic, a BlinkUp fixture is simply an imp and an LED. Adding a button allows an operator to trigger factory BlinkUp. This short guide shows how to use any imp breakout board as a BlinkUp fixture. Fixtures can be constructed from any equivalent hardware based on an imp003 and up, but you may need to change the pin settings in the function configureFactoryFixture() in the code listed below. This example is based on the imp004m Breakout Board.

  • Electric Imp offers a fully assembled BlinkUp fixture, the impFactory™, for customers who choose not to build one of their own.

Hardware

Connect your imp004m Breakout Board to the following circuit:

  • Connect the LED anode (long pin) to the imp004m Breakout Board’s pin A.
  • Connect the LED cathode (short pin) via the 220Ω resistor to GND.
  • Connect the switch between the imp004m Breakout Board’s pin P and GND.

Usage

1. Power The BlinkUp Fixture

Connect the BlinkUp fixture to power via Mini USB.

2. Add The BlinkUp Fixture To Your Electric Imp Account

Use the Electric Imp App to add the BlinkUp fixture to your Electric Imp account. For more information on this part of the process, please see this guide.

3. Assign Your Fixture To A Device Group

If you are making use of impCentral’s factory test environment, the Test Zone, you will need to add the BlinkUp fixture to a Test Fixture Device Group. You can learn how to do so here.

If you are going straight to production, you should instead follow the steps for a Fixture Device Group, outlined here.

4. Develop Your Fixture Firmware

The code listed below is ready to use with the circuit described above. Change the value of the SSID and PASSWORD constants to match the settings of your local (during testing) and factory (during production) WiFi network, or leave them unchanged if your DUTs connect by Ethernet or cellular.

You will require separate code for the DUTs that your fixture will prepare — you can find example code in the Dev Center’s API Cookbook section, here.

Sample Fixture Firmware

// ------------------------------------------------------------------------------
// File: simple.factory.firmware.device.nut
// Version: 2.0.0
//
// Copyright 2015-19 Electric Imp
//
// SPDX-License-Identifier: MIT
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// ------------------------------------------------------------------------------
// ***************************************
// ***** SETUP *****
// ***************************************
// Enter your factory WiFi credentials as the values of these constants
const SSID = "SSID";
const PASSWORD = "PASSWORD";
// Sets how long to wait (seconds) after triggering BlinkUp before allowing another
const BLINKUP_TIME = 10;
// Flag used to prevent new BlinkUp triggers while BlinkUp is running
local sendingBlinkUp = false;
local blinkUpCount = 0;
local button = null;
local blinkUpPin = null;
// ***************************************
// ***** FACTORY FIXTURE FUNCTIONS *****
// ***************************************
function configureFactoryFixture() {
// Assign the pins
button = hardware.pinP;
blinkUpPin = hardware.pinA;
// Set up the BlinkUp trigger button
button.configure(DIGITAL_IN_PULLUP, function() {
// Trigger only on rising edges, when BlinkUp is not already running
if (button.read() == 0 && !sendingBlinkUp) {
sendingBlinkUp = true;
imp.wakeup(BLINKUP_TIME, function() {
sendingBlinkUp = false;
});
// Send factory BlinkUp
server.factoryblinkup(SSID, PASSWORD, blinkUpPin, BLINKUP_FAST | BLINKUP_ACTIVEHIGH);
blinkUpCount++;
server.log("BlinkUp number " + blinkUpCount + " performed");
}
});
}
// ***************************************
// ***** RUNTIME START *****
// ***************************************
// Wait for idle before proceeding in order to ensure imp.configparams
// has been populated on the device (in case it wakes from deep sleep)
imp.onidle(function() {
// Check that we are running in the factory
if ("factoryfirmware" in imp.configparams) {
// The fixture is running factory firmware, ie. it's in a factory
// (or factory test environment) so configure the fixture for BlinkUp
configureFactoryFixture();
} else {
server.error("This fixture (ID: " + hardware.getdeviceid() + ") is not operating in the factory.");
}
}.bindenv(this));

5. Send Factory BlinkUp

Align the DUT’s photosensor with the fixture’s LED, and press the button to initiate factory BlinkUp. The DUT receives the BlinkUp data, then uses it to connect to the factory network, then to the Electric Imp impCloud™, from which it will fetch its assigned firmware.