Playing with my bag of C.H.I.P.s …

I finally found some time to play with my four C.H.I.P.s…

The Next Thing Co. …

Remember the $9 dollar single board computer ? NTC C.H.I.P.  was the cool thing to play with a few years ago, but now it seems that the project is unfortunately dead… 🙁

That’s too bad, because their ideas, products and design was very cool and refreshing…

The C.H.I.P. was packed with great features, with enough onboard storage, WIFI, BT4, a client USB interface, lots of GPIO, a Debian OS, and a minimal price!

Flashing the beast

The product documentation is still available, but some features are now missing, and among them the webflasher, whose chrome app wouldn’t even install on recent chrome or chromium versions.

If you want to flash your CHIPS, I suggest you use an Ubuntu base, and follow the guide. At one point, the flashing tool will put up some error message redirecting you to the CHIP-SDK github project. Don’t worry, you just have to run the provided ubuntu 14.04 setup script, it should run fine, even on the latest 18.04 LTS ubuntu.

You then just have to connect your C.H.I.P. in FEL mode, and flash it with the headless debian firmware, then connect them in USB using the virtual COM port, to finally enable the wifi to use the bonjour services for easy ssh access from your remote computer.

Here are a few notes to help preparing your C.H.I.P. …

Enable WIFI access

  • list the wifi access points: nmcli device wifi list
  • connect to an access point: sudo nmcli device wifi connect '(your wifi network name/SSID)' password '(your wifi password)' ifname wlan0
  • check current connection: nmcli connection show --active
  • deconnect manually with: sudo nmcli dev disconnect wlan0
  • forget the access point: sudo nmcli connection delete id "<NAME>"
  • boost the WIFI power: sudo iw dev wlan0 set power_save off
  • turn it off: sudo nmcli radio wifi off

Remote SSH

  • Once the WIFI connection has been set: ssh chip@chip.local
  • you can then modify your C.H.I.P.’s hostname in /etc/hostname and /etc/hosts (reboot required)

Python

  • install python2: sudo apt-get install git build-essential python-dev python-pip
  • install python3: sudo apt-get install git build-essential python3-dev python3-pip
  • install xtacocorex’s CHIP GPIO python module: see https://github.com/xtacocorex/CHIP_IO for more info.

UART

  • first, remove Getty:
    • sudo systemctl stop serial-getty@ttyS0.service
    • sudo systemctl mask serial-getty@ttyS0.service
  • /dev/ttyS0 is then available for UART with RX/TX on pins 3/5 (U14L header).
  • python example of using the UART:
    • sudo pip install pyserial
    • import serial
      import time
      with serial.Serial('/dev/ttyS0') as ser:
        for i in range(10):
            ser.write([i])
            print(bytearray(ser.read())[0])
            time.sleep(1)

Bluetooth

  • switch to CLI mode: bluetoothctl
  • get some help: help
  • turn BT on: power on
  • make your device discoverable: discoverable on
  • make it discoverable by default: sudo nano /var/lib/bluetooth/XX:XX:XX:XX:XX:XX/settings (insert your BT MAC address)
  • to easily automate stuff: bluetoothctl <<< $'power off\nexit\n'
  • pair a device:
    • make it discoverable
    • trust <addr>
  • python example to list discoverable devices:
    • sudo apt-get install python-bluez
    • import bluetooth
      
      nearby_devices = bluetooth.discover_devices(lookup_names=True)
      print("found %d devices" % len(nearby_devices))
      
      for addr, name in nearby_devices:
          print("  %s - %s" % (addr, name))

Various stuff

  • set the timezone: sudo dpkg-reconfigure tzdata
  • disable the led heartbeat pattern: echo none | sudo tee /sys/class/leds/chip\:white\:status/trigger > /dev/null
  • use an HD-like pattern for the activity led: echo nand-disk | sudo tee /sys/class/leds/chip\:white\:status/trigger > /dev/null
  • to make it persistent, append that to /etc/crontab: @reboot root echo none | sudo tee "/sys/class/leds/chip:white:status/trigger" >/dev/null
  • configure locales: sudo apt-get install locales and sudo dpkg-reconfigure locales

Home automation

Now that my four C.H.I.P. are ready, I can use them for my home automation system, for example along with my 3.3V bistable relay circuit, to command devices and lights… more on that later… 🙂

Leave a Comment