Scaling an IoT deployment? Join our webinar on May 28th where we dive into real-world scaling pain points and how to overcome them.

Blues Developers
What’s New
Resources
Blog
Technical articles for developers
Newsletter
The monthly Blues developer newsletter
Terminal
Connect to a Notecard in your browser
Developer Certification
Get certified on wireless connectivity with Blues
Webinars
Listing of Blues technical webinars
Blues.comNotehub.io
Shop
Docs
Button IconHelp
Notehub StatusVisit our Forum
Button IconSign In
Sign In
Sign In
What’s New
Resources
Blog
Technical articles for developers
Newsletter
The monthly Blues developer newsletter
Terminal
Connect to a Notecard in your browser
Developer Certification
Get certified on wireless connectivity with Blues
Webinars
Listing of Blues technical webinars
Blues.comNotehub.io
Shop
Docs
homechevron_rightExample Appschevron_rightAcceleratorschevron_rightPower Outage Detection

Power Outage Detection

  • Hostless
  • Mains-Powered

Use Notecard with a mains-powered USB power brick and LiPo battery to build a globally available power outage detector.

You will need

  • LiPo battery with JST cable
  • AC to USB Adapter (power brick)
  • USB A to Micro USB cable
  • Notecarrier-A or Notecarrier-B
  • Cellular Notecard

Hardware Setup

  1. Assemble Notecard, Notecarrier and LiPo battery as described in our tutorial.

  2. Keep the Notecard connected to the computer with the in-browser terminal active until you have completed Notecard Setup.

Notecard Firmware

Your notecard should be running firmware version 4.2.1 or higher. The simplest way to update firmware is to do an over-the-air update

Cloud Setup

  • Sign up for a free account on Notehub.io , and create a new project.

Notecard Setup

In these steps, you will use the in-browser terminal to configure your notecard to report power outage events to your Notehub project.

Configure Notehub Project and Connection Mode

First, we will set the serial number (name) of your notecard and the ProductUID. The ProductUID is the one corresponding to the project you created in Cloud Setup. Replace the sn and product values with your own and paste the resulting command into the in-browser terminal.

{
  "req": "hub.set",
  "mode": "periodic",
  "inbound": 1440,
  "outbound": 60,
  "product": "com.your-company:your-product-name",
  "sn": "your-serial-number",
  "body": { "app": "nf16" }
}

This app uses periodic mode to minimize power use so that the solution can remain online for longer when mains power fails. For more details, see hub.set requests.

Configure Power Outage Alerts

Paste this command into the in-browser terminal

{ "req": "card.voltage", "mode": "lipo", "usb": true, "alert": true, "sync": true }

This instructs the Notecard to assume LiPo battery characteristics, monitor USB power and send an alert immediately when a power outage occurs and when power is restored. For more details, see the Notecard API reference and the Enable USB Power Alerting example.

Notecard CLI

If you want to issue all of the above requests in one shot, you can do so with the Notecard CLI and the config.json configuration script. You will need to change the ProductUID in the hub.set command to match your ProductUID. Once you've done that, you can configure the Notecard with:

notecard -setup config.json

System Test

In this section, you will power the Notecard via the power brick and simulate a power failure.

Setup

  1. Insert the power brick into a suitable electrical outlet and provide power to the Notecarrier via the micro USB cable.

  2. Plug the JST connector from the LiPo battery into the port labeled LIPO on the Notecarrier.

  3. Wait for the Notecard to connect to the cloud. When connected, there will be a new session event in Notehub. (look for recent _session.qo events.)

  4. Wait for the battery to fully charge.

Simulating a Power Outage

  1. Remove the power brick from the electrical outlet to simulate a power outage. The Notecard is now being powered by the battery.

  2. After a short time, you will see a _health.qo event in Notehub with the body

{"text":"USB power OFF {usb-disabled}"}

This event indicates that the Notecard is no longer powered from the power brick.

  1. Reinsert the power brick into a suitable electrical outlet to simulate power being restored.

  2. After a short time, you will see a _health.qo event in Notehub with the body

{"text":"USB power ON {usb-enabled}"}

This event indicates that the Notecard is again powered by the power brick.

Routing Data out of Notehub

Notehub supports forwarding data to a wide range of API endpoints by using the Route feature. This can be used to forward your power monitoring events to external dashboards and alerts to a realtime notification service. Here, we will use Twilio SMS API to send a notification of an alert to a phone number.

For an introduction to Twilio SMS routes, please see our Twilio SMS Guide.

  1. Fill out the required fields for the Twilio SMS route, including "from" and "to" phone numbers, where "from" is your virtual Twilio number, and "to" is the number of the phone that receives the power outage alerts. We will not be using placeholders for these numbers, but will use a placeholder for the message, so set the message field to [.body.customMessage].

  2. Under the "Filters" section, set "Notefiles" to "Selected Notefiles" and type _health.qo in the text input area below the list of notefiles.

  3. Under "Data", select "JSONata Expression" and copy and paste the contents of jsonata/route.jsonata into the text field "Insert your JSONata expression here".

  4. Click "Save Changes".

Testing the Route

The ideal test is to use the app Notecard to generate alerts.

Testing Power Failure

With the Notecard connected to USB power, and the LiPo connected, simulate a power outage by unplugging the USB power supply. Within a few seconds, an SMS will be sent to the to number you configured in the route above.

The message looks like this:

ALERT! Power has failed to device Refrigerator.

This indicates a mains power failure on the Notecard with serial number "Refrigerator".

Testing Power Restored

Using the same setup as above, reconnect the USB power supply to the Notecard. Another SMS message is sent that looks like this:

Power restored to device Refrigerator.

Testing Power Restored after the LiPo battery has discharged

Should power be out for long enough, the LiPo battery will discharge and will be unable to power the Notecard. When this happens, the Notecard will power off and resume when utility power is restored.

To test this:

  1. Disconnect the USB power supply. This will generate a power failure alert as before.
  2. Disconnect the LiPo battery. No events are sent at this point.
  3. Reconnect the USB power supply, simulating mains power being restored.
  4. Reconnect the LiPo battery.

You will see a message that looks like this:

Power restored (LiPo battery discharged) to device Refrigerator.

Blues Community

We’d love to hear about you and your project on the Blues Community Forum .

On This Page

  • You will need
  • Hardware Setup
  • Notecard Firmware
  • Cloud Setup
  • Notecard Setup
    • Configure Notehub Project and Connection Mode
    • Configure Power Outage Alerts
    • Notecard CLI
  • System Test
    • Setup
    • Simulating a Power Outage
  • Routing Data out of Notehub
    • Testing the Route
  • Blues Community

Resources

  • GitHub
  • Request More Info
© 2025 Blues Inc.
© 2025 Blues Inc.
TermsPrivacy
Notecard Disconnected
Having trouble connecting?

Try changing your USB cable as some cables do not support transferring data. If that does not solve your problem, contact us at support@blues.com and we will get you set up with another tool to communicate with the Notecard.

Advanced Usage

The help command gives more info.

Connect a Notecard
Use USB to connect and start issuing requests from the browser.
Try Notecard Simulator
Experiment with Notecard's latest firmware on a Simulator assigned to your free Notehub account.

Don't have an account? Sign up