Category Archives: computers

Not bad at all for under $15

The vertical lines in the screen, while present, aren’t as obvious as they are in the photo. The time is off because it’s not on my home network right now and can’t retrieve the correct time.

I’ve been playing around a bit with ESPHome and Home Assistant lately…started with a couple of Sonoff smart outlets, one to replace a Kill-A-Watt monitoring my mining rig and another to switch a light on at sunset.

What’s up above is part of this weather station kit. The metal can on the small board in the center is a BME280 environmental sensor that picks up temperature, humidity, and barometric pressure and makes that information available over I2C. The NodeMCU on the right reads the sensor, publishes its readings over WiFi to a Home Assistant server, and displays the readings (and current time) on the I2C-connected OLED on the left. You could probably use an ESP-01S with a 4-MB flash upgrade since I2C only needs two pins to work, but the kit came with a NodeMCU, so that’s how I brought it up initially.

Wiring is simple: connect ground together on all three boards, connect the power inputs on the OLED and sensor to a 3.3V pin on the NodeMCU, connect the data pins (SDA) to pin D2, and connect the clock pins (SCK) to pin D1.

The ESPHome config file (not really a program as such) looks something like this:

esphome:
  name: bme280
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "your_wifi_ssid"
  password: "your_wifi_password"

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

i2c:

sensor:
  - platform: bme280
    address: 0x76
    temperature:
      name: "BME280 Temperature"
      id: temp
      oversampling: 16x
    pressure:
      name: "BME280 Pressure"
      id: baro
    humidity:
      name: "BME280 Humidity"
      id: humid
    update_interval: 60s

display:
  - platform: ssd1306_i2c
    model: "SH1106 128x64"
    lambda: |-
      it.strftime(127, 60, id(arial14), TextAlign::BASELINE_RIGHT, "%H:%M", id(esptime).now());      
      it.printf(0, 0, id(arial14), TextAlign::TOP_LEFT, "%.1f°", id(temp).state*1.8+32.0);
      it.printf(0, 20, id(arial14), TextAlign::TOP_LEFT, "%.1f%%", id(humid).state);
      it.printf(0, 40, id(arial14), TextAlign::TOP_LEFT, "%.2f\" Hg", id(baro).state*0.0295);
      
time:
  - platform: homeassistant
    id: esptime
    
font:
  - file: "/usr/share/fonts/corefonts/arial.ttf"
    id: arial14
    size: 14
    

The sensor returns temperature in °C and barometric pressure in hPa; the code above converts those to more sensible units for display. Also, you’ll probably need to update the font file location to whatever is correct for your system. (I have ESPHome installed on Gentoo Linux and have the corefonts package installed.)

Something like this would be useful to have indoors. For an outdoors weather sensor, leave off the screen and the related sections (display, time, and font) from the config file. Next task is to fab up an enclosure of some sort.

Who knew? The Google Play Books Chrome app has an offline mode.

IMG_20151104_130132A new tablet arrived yesterday: an HP Stream 7, which set me back a whopping $60 at Woot.  After letting it update itself from Windows 8.1 to Windows 10 (yes, it runs Windows, not Android or iOS) and putting Chrome and a few other apps on it, I set out to find a decent ebook reader.  Ideally, it’d support ePub and would sync bookmarks between existing devices.

I have been using Google Play Books to share my collection between Android and iOS devices.  Apps are available for both to download part or all of your collection for offline reading; bookmarks are synced when online.  Unfortunately, there’s no dedicated Windows app…but it turns out that’s not a problem.

After trying several ebook apps for Windows and finding them wanting in one measure or another, I ran across references to a couple of things I didn’t know about:

  • Google Play Books is available as a Chrome app
  • The Chrome app can use HTML5 local storage to hold selected ebooks for offline reading

Sweet!  The only tricky part now was selecting books for offline reading.  You’re supposed to hover the mouse pointer over the title you want to download, then click a “make available offline” checkbox that pops up.  Without a mouse, though, you can’t hover over anything.

That’s where a program called TouchMousePointer comes into play.  It converts part of the screen area into a touchpad, and puts up a mouse pointer that you can hover over the books you want to download.  It’s easily toggled off most of the time, but is there if you need more precise positioning than your fingers can deliver (as apps written with a mouse in mind might need).

IMG_20151104_130807Here’s the end result…note that the tablet’s in airplane mode.  The screen doesn’t really look like that; it’s some weird interaction between it and the camera in my phone that you’re seeing.

So this is why new files weren’t showing up

Nothing like changing the default behavior of a program in a point release so that users then wonder why it’s not behaving as it should:

ownCloud 8.2 Release Notes

Changes in 8.2

filesystem_check_changes in config.php is set to 0 by default. This prevents unnecessary update checks and improves performance. If you are using external storage mounts such as NFS on a remote storage server, set this to 1 so that ownCloud will detect remote file changes.

Nearly all of the files on my ownCloud server are accessed from Samba shares on the same server; ownCloud is basically how I access my files away from home.  If it’s not monitoring filesystem changes, it will rapidly fall behind on which files have been created and deleted.

Until v8.1, it monitored filesystem changes in the default configuration.  I upgraded to v8.2 over the weekend, which no longer does that unless you add an option to the config file to reenable it.  Grr.

Password requirements FAIL

pwfail

I went to sign up with the DMV website to put in a change of address.  After providing some info off my license and some other bits, they sent a link to the page shown above.

Only eight characters?  Not case-sensitive?  Really?

It also barfed on some of the non-alphanumeric characters KeePass wanted to use…an unstated requirement, apparently, is that only the three non-alphanumeric characters given are acceptable.  I’m used to giving websites passwords that are 20 or more characters of random gibberish to provide plenty of entropy; the limits imposed by the DMV website only allow about 50 bits of entropy, which is fairly weak security.

The length limit suggests that perhaps they’re storing raw passwords in their database, as that’s the only reason to have a length limit.  Even Ashley Madison probably didn’t make that kind of rookie mistake.

(Of course, no post on password strength issues is complete without this: https://xkcd.com/936/)

Backing up your ownCloud contacts & calendars

I’ve had most of my stuff either backed up to Tarsnap or archived to BD-R for a while now, with two exceptions: the contacts and calendars I have stored in ownCloud.  It’s not much information sizewise, but losing everyone’s phone numbers would be a royal pain in the ass.

Backing up contacts is relatively simple; ownCloud provides a URL that grabs them in one shot. Calendars are a bit more problematic, as you probably have more than one. HTTrack is used to grab all of the calendars, which are then concatenated and compressed (except for the contact birthdays calendar, which is auto-generated from your contacts). In my case, the backup is stored in a directory that gets sent to Tarsnap by another script; you could do whatever you want with your backup files.

Set this up as a cronjob; set it to run maybe a half-hour before your backup job. (12345 isn’t really my ownCloud password; I only use that on my luggage. :-) )

#!/bin/bash

source /etc/profile
cd $HOME

# script settings: ownCloud server address, username, password, 
# backup destination

OWNCLOUD=https://home.alfter.us/owncloud
USERNAME=salfter
PASSWORD=12345
DEST=/mnt/files/documents

PREFIX=`echo $OWNCLOUD | sed "s/\/\//\/\/$USERNAME:$PASSWORD@/"`

# retrieve all contacts from ownCloud and concatenate them into one
# compressed file, which then gets sent to Tarsnap with the rest of
# our documents

rm /mnt/files/documents/contacts.vcf* 
wget $PREFIX/remote.php/carddav/addressbooks/$USERNAME/contacts\?export -O "$DEST"/contacts.vcf && \
xz -z9 "$DEST"/contacts.vcf

# do the same with calendars...use httrack instead of wget as there's no
# way AFAICT to enumerate calendars so we can export them

httrack $PREFIX/remote.php/caldav/calendars/$USERNAME -O calendars && \
for i in `find calendars -mindepth 7 -type d | grep -v contact_birthdays`
do
  cat `find $i -name \*.ics` | xz -9 >"$DEST"/calendar-`basename $i`.ics.xz
done
rm -r calendars

The latest firmware for the Asus RT-AC56U doesn’t work right. Avoid it.

33-320-167-TSI just got done getting my settings restored to my router after letting it try to update to the latest version. Version 3.0.0.4.378.4585 killed the web interface, making it unconfigurable.  Restoring the previous version from a TFTP client running on Linux wouldn’t work to set it right, either.  Good thing I had recently added Windows 7 to the empty space on my main computer’s SSD, as a Windows-based unfsck-my-router utility provided by Asus (only downloaded after I had swapped in my trusty old WRT54GL temporarily) was the only thing that would get the router running right again.

I even tried using the aforementioned unfsck-my-router utility to try installing the newer firmware, instead of letting the router update itself again.  That didn’t work either.  The only conclusion I can come to is that something is pretty badly broken in this latest release.  It won’t damage your router (it’s harder to brick than most devices), but rolling it back to working firmware is a bit of a hassle.  I’d recommend skipping this update and hold off for the next release.

How stupid does she think we are?

Yesterday, the excuse that Hillary Clinton gave for conducting official business through a private email server was that she had two phones to access multiple email servers. There are multiple problems with that “explanation, but since when do you need multiple phones to manage multiple email accounts? I have access to my personal email server (like the Clintons’, but more secure because mine runs Linux instead of Windows) and a Gmail account through my phone. It’s lame email software (Outlook comes to mind) that can’t handle multiple accounts.

Linux 3.17 is out, and some of my code is in it

It’s not the first time that happened…submitted a couple of drivers for a video-capture card we built at my previous job back around ’05 or ’06.

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/w1/slaves/w1_ds2406.c?id=refs/tags/v3.17

I submitted this a few months ago for my Raspberry Pi beer-fridge controller. I picked the parts and put it together without checking to see first if the necessary driver support was already in place…derp! Fortunately, it’s relatively easy to correct such deficiencies when you have source-code access to the whole system.