Sunday, 6 November 2016

Safety-First IoT Part 1 - Getting started with the Nano Pi NEO Air

Nano Pi NEO Air

On my Technology Policy Blog I've written about the challenges of The Internet Of Things, and how
to address them. Here on Make The Future I'm beginning this series of more technical articles on how
to put my recommendations into practice.

Meet the Nano Pi


The Nano Pi NEO Air is one of a number of low-cost boards inspired by the Raspberry Pi, many of which are
suitable for managing your own Internet of Things collection in the workplace or home.

The Raspberry Pi is a highly versatile single-board computer aimed at hobbyists, students
and Internet Of Things products. The Raspberry Pi occupies the "top of the line" position in this niche, with
WiFi, HDMI, Four USB-A ports, audio output, a gigabyte of RAM and top-notch software support.

An ecosystem of lower-cost alternatives have grown up, which aim at more specialised
subsets of the Raspberry Pi's market, typically by reducing features to save either size or cost.

The Nano Pi NEO AIR is the latest in a of a family of very small single board computers from FriendlyARM. The Air has the following notable features:

  • Tiny 40x40mm size
  • 8MB on-board flash pre-loaded with Ubuntu Linux
  • External WiFi antenna
  • Idle power consumption around 1 Watt (200mA @ 5V)
  • Weighs less than ten grams
  • No video output (but a dedicated 4-pin serial console connector)
  • No USB-A ports but (but headers for two external ports)

This board, which costs under US$20, is extremely well placed for mobile battery powered applications, or for IoT sensor applications that need the power offered. (My position is that if you don't need a Linux runtime in an IoT device, you should use a less complicated embedded platform with a smaller vulnerability surface instead).

One immediate application of the Nano Pi NEO Air is as a bridge for Apple's HomeKit, allowing you to control existing home-automation appliances via your iPhone (more on this in a future post).

Unboxing and Assembly

The Neo AIR is available from FriendlyARM with a number of optional extras. I recommend you order the following in addition to the board itself:

  • A case, either 3D printed PLA or laser-cut Acrylic
  • A heatsink (my board has run fine without a heatsink so far)
  • An external WiFi antenna

IMG_7593

If you don't already have a USB-to-TTL-serial converter, you will need one for initial setup. (See also my post on using a HC-06 Bluetooth module instead.)

The Neo Air comes disassembled, you will need to solder on the input-output header pins.

The Acrylic case screws together easily, and well done FriendlyArm for including five of each of the screws and posts, even though only four are needed. Losing an important screw can be very frustrating.

Setting up the Operating System

Once your Air is assembled, you need to connect a serial adapter for first boot setup. The only text editor installed out of the box is 'vi' so it's time to either learn vi, or edit your files elsewhere and paste the contents in.

You can use either a USB-to-serial cable or a Bluetooth-to-serial module.

Here's what you need to do.

  1. Connect to the serial console from another computer over USB or Bluetooth
    • On Mac do cu -l /dev/tty.HC-06-DevB (or whatever name your interface device is given)
    • On Linux do cu -l /dev/ttyUSB0 (Press the RETURN TILDE and PERIOD keys in sequence to exit cu)
    • On windows use Hyperterminal or other terminal software
  2. Log in as root (password 'fa') and change the passwords for 'root' and 'fa' accounts immediately.
    • # passwd root
    • # passwd fa
  3. Edit the system hostname (vi /etc/hostname)
  4. Configure the wifi
    • Get the example configuration file from the FriendlyARM Wiki
    • Edit the file on your Air: vi /etc/wpa_supplicant/wpa_supplicant.conf
  5. Reboot
  6. Login as root with your new password
  7. Update software and add some essentials
    • apt-get update
    • apt-get upgrade
    • apt-get install avahi-daemon avahi-utils man-db nano
  8. Reboot again
  9. Now you should be able to ssh to your Air using the name you gave it, eg ssh scampi.local
For those who can't use vi: If you don't know how to use the vi editor, you can paste in your files using cat, for example
  1. cat > /etc/wpa_supplicant/wpa_supplicant.conf
  2. Paste in your complete file
  3. Press CTRL-D to signify end-of-file
  4. Type cat /etc/wpa_supplicant/wpa_supplicant.conf to confirm correct content

Customising the hardware

I customised my Air like so:

  • I drilled a 6.35mm mounting hole for the antenna in the acrylic cover
  • I added a USB-A socket from my junk box (such as this component)

FullSizeRender 2

First impressions in use

The pre-installed Ubuntu installation looks a little strange (including only busybox's vi emulator as an editor is fine for an old hand like me, but a little rude to newcomers), I will be looking at switching to Armbian soon. The Armbian distribution for this board has just reached beta-test stage in the last few days; I previously booted the Armbian alpha-test version from SD card and it worked well, though I didn't yet test WiFi.

Power consumption is good, the board has been running from a single lithium battery throughout all the testing I have done.

The lack of on-board type A ports means I wouldn't recommend this board for use as a security camera hub, I would look at the Orange Pi Zero as an alternative here.

Looks ideal for robotic applications, especially connecting one or more Arduinos running Firmata via one or more of the three serial ports.

Next Steps

In upcoming articles I'll be looking at how to manage your IoT devices in a way that reduces risk to you and others in case of vulnerable or rogue devices. Rather than relying on the manufacturer's poorly supported cloud services to control to devices, I'll show how to use Node-RED and other tools to create a secure IoT installation.


5 comments:

Anonymous said...

Well if the use case is a security camera one of the Air's advantages is the 24 pin camera port. With most Allwinner SoCs (H3 included) we can make use of HW accelerated video encoding (h.264) so all that's needed is just a camera module. I lost track somehow but it might even be possible to connect Xunlong's cheap 2MP camera module for Orange Pis (there's a large thread in Armbian H3 forum).

It should also be noted that Armbian's legacy kernel is at 3.4.113 already (containing a bunch of security relevant fixes) while FA's offer is still at 3.4.39. Using mainline kernel on the Air should be possible already if camera connector isn't important.

unixbigot said...

Good point, anonymous. I'm so used to using USB cameras I neglected to mention the DVP port. I have an IR DVP camera in the mail so will try this out when I receive it.

I also plan to re-test the latest armbian beta image soon, will report how that goes.

Krishnendu Janardhanan said...

I want to work nano pi neo air using usb to ttl converter without using wifi. Could you please tell me a solution for this.

Thank you

unixbigot said...

Krishnendu the nanopi has a dedicated 4-pin header labelled DBG_UART. You can attach a USB-to-TTL converter to this.
You can also attach a bluetooth-to-serial if you prefer (see another post on my blog about this).

Connect like this

pi GND->Serial GND

pi rx -> Serial tx

Pi tx -> Serial rx

pi vcc -> serial vcc


You should leave vcc unconnected for USB converters, but connect it for bluetooth.



Image here: https://flic.kr/p/RGn78c

Krishnendu Janardhanan said...

sir,
I have tried what you said, but i did not get Internet connection via that converter. Help me to solve out this problem.

Thank you,

Krishnendu J