Skip to main content

Debugging Disconnected Applications

How To Test Your Hardware And Software When Your imp Is Not Online

Battery operated devices commonly disable WiFi to save power. Mains-powered devices may be configured to continue operating even when WiFi connectivity has been lost due to circumstances beyond the device’s control. However, with no network connectivity, logging is a challenge.

In order to add visibility to the state of your product during power saving modes or periods of unexpected connectivity loss, you can employ one of the many digital communication protocols available on an imp. One of particular value is UART. This standard bus is a great choice for its ease of use and availability on each imp.

By using a UART for offline debugging you can send the same messages you would via server.log() to a serial port with just a few simple hardware modifications. We’ll describe below how you can take advantage of this technique.

Tools

You’ll need a few tools in order to use UART for debugging. These tools comprise both software and hardware but are either low cost or free. In addition to these tools, you will have to modify your device under test (DUT) hardware and software to output debug messages.

We recommend using a TTL UART-to-USB (COM port emulator) cable to view debug messages on your workstation. In order to connect this cable to your DUT you will have to solder two wires (imp TX and GND) directly to pins (or test points) on the DUT. In addition, you will need terminal software and to modify the DUT code to output debug messages over serial. We have collected the information you need to source components and software, and we have written a class you can add to the DUT code to output debug messages easily.


A USB-to-serial adaptor useful for testing UART links
 

FTDI Cables

We recommend FTDI cables because they are highly available and relatively inexpensive. They are available with either a female 0.1-inch socket or bare wire termination, so select on one the basis of your application. They are also available in 3.3V and 5V signal levels, but it is important that you always use the 3.3V version to avoid damaging the imp’s IO pins.

Terminal Software

There are many options available depending on your OS. Linux and macOS both come with Terminal utilities; these can be used run a command-line utility called screen which lets you send and receive information via UART. Windows users should download Simon Tatham’s PuTTY, which combines the role of Terminal and screen.

Drivers

You will need to install the FTDI drivers for your OS. Note that macOS 10.9 and above come with FTDI drivers built in.

Setup

Hardware

In order to send data out over the UART you will need an available UART TX pin. This pin can share functionality with other devices on your board but you will have to evaluate if the sending TX data to the other device will cause damage to it or the system.

Please review the pin mux for your chosen imp module to determine which TXs pins are available for use.

Once you have found a viable TX pin, you need to connect it the RX pin (yellow) on the FTDI cable or header. The only other connection required is a link between the GND of the imp to the FTDI GND pin:

Software

Be sure to set the serial terminal connection to use the FTDI cable and match the following settings:

  • Baud Rate User Choice
  • Data Bits 8
  • Parity None
  • Stop Bit 1

For guidance on setting up the serial software, please see UART Explained.

Example Code

Please see the imp API Cookbook recipe Serial Logging for sample code.