Archive for August, 2016

Orange Pi Lite Notes

Tuesday, August 30th, 2016

Hey! It’s more notes!



Orange Pi Lite is, IMO, the only difficult Orange Pi to get working. Primarily, because it has WiFi, and no Network socket.

For an OS, use Armbian.

WARNING: the device will be unlit, no LEDs, until the OS image begins to boot. It could be half a minute before you see anything.

It can sometimes take a few tries to program the SD card correctly (either that or I’m using bad SD cards).

NOTE: Armbian will reboot a few times after first inserting a fresh memory card. You should wait a few minutes before you attempt to log in. When you see the red-light flashing, that means it’s about to reboot.

You’re going to need a way to view the console. Either by plugging in a mouse/keyboard/tv, or via a USB UART cable. UART pins are beside the USB ports. According to the image above, WHITE, GREEN, BLACK (TX, RX, GND). NEVER use the red (doesn’t provide enough power).

root password is 1234

Now for the work.

If you’re like me, you have a WPA2 protected WiFi network. I also hide my SSID, so there’s an extra step needed if you do that.

First, if you’re not already, become root.

It’ll save you a bunch of headaches, so again, become root. Don’t try to do this with sudo.

Generate a wpa_supplicant configuration.

Edit this file.

For security reasons, you may want to remove the line that shows your password.

If you use a hidden network, add a line “scan_ssid=1” to the network section. It should now look something like this:

Save and close the file. You can test the configuration like so.

If you wanted to manually connect to the internet, right now, you could do this.

To make this permanent, open up /etc/network/interfaces

Comment out or delete everything but the loopback. Your file should look something like this:

You can then restart networking.

And you should be on the internet now, and any time you reboot.

You can also now SSH in to it, and stop using your tv/mouse/keyboard. Hooray!


C.H.I.P. (by Next Thing Co) Notes

Monday, August 29th, 2016

Just some notes.


To reinstall (upgrade) the OS, go here:

You’re going to need a USB cable, and a jumper wire/paperclip. Ground the FEL line before plugging it in to your PC. If you’re on Linux, you’ll also have to follow some funny instructions to give your account permission to access the USB port via the Chrome web browser. For me the variable that’s supposed to be your login name wasn’t working, so I just used my login name directly.

The upgrade is all-or-nothing. Kernels can’t be updated with apt-get (yet).

If you go headless, getting WiFi configured can be a pain, especially if you have a hidden SSID. Common instructions are here:

The key thing is the command: nmtui

You can *almost* do everything in it. Manually adding a hidden SSID didn’t want to take for me.

SSID IS CASE SENSITIVE (also no matter how many times you type in an incorrect SSID, it wont work, *cough*).

Much further down in the post is some guy that talks about how to do it entirely from the command line. This is what you need.

nmcli con add con-name your_connection_name ifname wlan0 type wifi autoconnect no save yes ssid your_hidden_ssid

nmcli con modify your_connection_name wifi.hidden true wifi-sec.key-mgmt wpa-psk wifi-sec.psk your_passwd

# To connect
nmcli con up your_connection_name

# If it’s good, permanently make it autoconnect
nmcli con modify your_connection_name autoconnect yes
# or use the GUI (nmtui)

# To disconnect
nmcli con down your_connection_name

SSH comes preinstalled on 4.4. AVAHI (zeroconf) is preconfigured to give it the network name ‘chip’ (and chip.local), so you should be able to connect like so:

Getting the IP address is not ifconfig (though you can do sudo ifconfig).

Instead, use: ip addr

To not drive yourself crazy, make an alias for ll.

Install NodeJS.

Setup a simple web server.

AVAHI (Zeroconf) is also pre-configured. You should be able to connect to the server like so:


1 Wire

According to the “DIP” docs, the 1 Wire bus is located on LCD_D2 on pin header U13.

Arduino Notes

Saturday, August 27th, 2016

Just a bunch of scattered Arduino notes.



  • All data pins can be Digital Inputs or Outputs (i.e. D0-D13, A0-A5). Thus, 20 digital I/O pins
  • Caveat: D0 and D1 are shared by the UART bus used to communicate over USB. So if you want to avoid reading/writing weird values while connected to the PC, you may want to avoid these pins.
  • Pins D3, D5, D6, D9-D11, D13 have PWM’s attached to one of 3 (4) timers.
  • Timer1 (OC1x) on D9-D11 is the ‘fanciest’ timer. 😉
  • Pins A0-A5, as well as D4, D6, D8-10, D12 are all capable of Analog Input (not output)
  • To do analog out, use a PWM with some magic:
  • Each set of pins is a block.
    • PORTD is D0-D7 (8 bits*, DDRD)
    • PORTB is D8-D13 (6 bits, DDRB)
    • PORTC is A0-A5 (6 bits, DDRC)
  • Set the DDRx registers directly to write bytes (i.e. DDRD = B11111100;). You can read them too, and mask-out the data you’re not using
  • B11001010 macros can be used for bitmasks, etc
  • PinMode(pin,mode) – mode can be INPUT, OUTPUT, or INPUT_PULLUP
  • INPUT_PULLUP not available on D0 and D1.
  • D0 and D1 are actually the same pins as SCL and SCA. On the board twice for some reason.
  • Standard 4 pins with support for interrupts D0-D3. Leonardo does actually have one more (D7)
  • Serial.print(), Serial.println() to output to the PC console over UART.



Has 1 channel. Not ‘true’ UART, as true UART runs at 12v.

  • Uses Pins D0 and D1 (because of interrupts?). These pins also lack the optional pull-up resistors found on other Arduino pins.
  • 3 actual wires: TX, RX, GND. TX=Transmit, RX=Receive. Typically White, Green, Black
  • Data rate is typically 112 kHz (115200), but could be double that (230400)
  • Is technically “Full Duplex” because of the separate Transmit and Receive lines
  • Serial UART is an asynchronous protocol, WITHOUT a transmitted clock.
  • Devices must agree upon the data rate ahead of time, and must run their own perfectly sync’d clocks.
  • Primarily limited to communication between 2 devices. In theory multiple is possible, but it’s just not practical.


For that temperature sensor (DS18B20).

  • Uses ??

I2C/TWI (2-Wire)

For a variety of breakout chips. 16bit ADC (ADS1115), DAC (MCP4725), 64k EEPROM (24LC512), 128k SRAM (23LC1024*), 16bit Digital I/O Expander (MCP23017).

Loosely related to SMBus. Some SMBus devices could work over I2C.

  • Uses D2 and D3 (because of interrupts)
  • 3 actual pins: SCL, SDA, GND. SCL=Clock, SDA=Data
  • Open Drain, using 3-state logic (high, low, high-impedance).
  • Master/Slave(s). Technically it can have multiple masters, but the masters can’t directly talk to each-other over the bus (need to negotiate via another way).
  • Either 112 (7 bit w/ reserved) or ~1000 (10 bit) devices can be on the bus. Each needs a unique (often hardwired) ID. Chips often have extra pins you ground to set the unique ID to 1-or-more values, but it means you still have a limit of 2-8 instances of the same device on a bus.
  • Data rate is either 100 kHz, or 400 kHz. Later specs allow 1 MHz, 3.4 MHz and 5 MHz, but we don’t get to use those.
  • SCL and SDA have pull-up resistors, connected to the Master’s power. I.e. the default state is High.
  • Slaves ground the data line, to make the low signals. To go high, you leave it open.

SPI (4-Wire)

For SD Cards, Flash Memory (W25Q80BV), 10bit ADC (MCP3008), …

  • ???