Category Archives: Drivel

Hateful gate controller

By   March 19, 2023

I’m essentially lazy. After installing a gate on the end of the driveway, we quickly tired of getting out of the car to open and then close the gate behind us. I bought a gate actuator which came with a couple of linear actuators and a controller. Since we don’t have wired power out there, I also needed a battery and solar panel plus charge controller.

The charge controller it came with was shit and the panel was too small, so I bought a new panel and charge controller. That solved that problem. No longer getting ‘Low Voltage’ warnings from the gate controller.

The next problem was access for friends. See the article https://www.beer.org/blog/index.php/2022/07/03/playing-with-fiducials/

Another annoyance was that if we were expecting a friend or courier or other, we had to walk down the driveway with a remote, and after getting close enough to the gate, press a combination of buttons in order for the gate to open and stay open.  Then before bedtime, we had to remember to walk down the driveway to close the gate which is particularly disquieting in the dark where a hundred reflective eyeballs are looking at you from the surrounding forest.  There was also no way to know whether the gate was actually open or closed without also going for a walk.

To help address this last annoyance, I added a VHF radio module connected to a BLE dongle and a relay module with a set of ADCs to read the limit switches.  A bit of Micropython and I could send queries to the dongle to get the state of the limit switches, and press buttons remotely.  Add in some MQTT handling and I have a link to HomeAssistant.

 

Unfortunately, now I have 2 boxes mounted out by the gate, one with the clunky COTS gate controller+battery, and another with the barnacles that I added to the system:

There must be a better way.  The heart of the system is the COTS controller board which is really just a couple of H bridges, some current sensing, limit switch inputs and push button inputs.  Time to start experimenting.

Playing with Fiducials.

By   July 3, 2022

As part of some tinkering I was doing with my robotics team, I was learning about AprilTags.  Coincidentally, I had also recently installed a gate opener at the front gate and was struggling with how to organize guest access.

I grabbed my OpenMV camera, a spare buck/boost converter, and an old Axis surveillance camera housing.  Put it all together and mounted it to a post in front of the gate:

 
Google Photos Refresh Token invalid. Please authenticate from Photonic → Authentication.
Error encountered during authentication:
{
  "error": "deleted_client",
  "error_description": "The OAuth client was deleted."
}
See here for documentation.

I played with the QR Code recognition and various families of AprilTag. While the QR Code recognition worked fine and allowed me some nice flexibility in terms of content, it was more fallible under varying light conditions. AprilTags are more robust and recognized pretty quickly from a few feet away.

The code is simple:

import sensor, image, time, math, omv, utime
import pyb
import machine


thresholds = ( 150,255 )
sensor.reset()                      # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QQVGA)
sensor.set_auto_gain(False)
sensor.set_auto_whitebal(False)
sensor.skip_frames(time = 2000)     # Wait for settings take effect.
clock = time.clock()                # Create a clock object to track the FPS.

tag_families = image.TAG36H11|image.TAG36H11

last_tag = 0
tag_repeat_cnt = 0
tag_repeat_threshold = 5
rtc = pyb.RTC()

def set_rtc(epoch):
    dt=time.localtime(int(epoch))
    rtc.datetime(tuple(dt))


P1_PIN="P4"
P2_PIN="P5"
p1 = 0
p2 = 0

STATE_NORMAL=0
STATE_STAY_OPEN=1
STATE_STAY_CLOSED=2

state = 0
rtc_valid = 0

red_led = pyb.LED(1)
green_led = pyb.LED(2)
blue_led = pyb.LED(3)
ir_leds = pyb.LED(4)

# micropython Epoch is 2000-01-01.  My timezone is UTC+8.
epoch_fixup=946728000


def set_p1(dur=0):
    p1.low()
    red_led.on()
    time.sleep_ms(dur)
    p1.high()
    red_led.off()


def set_p2(dur=0):
    p2.low()
    green_led.on()
    red_led.on()
    if (dur == 0):
        return
    time.sleep_ms(dur)
    p2.high()
    green_led.off()
    red_led.off()

def init_gpios():
    p1=pyb.Pin(P1_PIN, pyb.Pin.OUT_PP, pyb.Pin.PULL_DOWN)
    p2=pyb.Pin(P2_PIN, pyb.Pin.OUT_PP, pyb.Pin.PULL_DOWN)
    p1.high()
    p2.high()

    return p1,p2

p1,p2 = init_gpios()
blue_led.on()

i=0
while True:
    if i > 10:
        sensor.sleep(True)
        time.sleep_ms(500)
        sensor.sleep(False)
        i = 0
    i = i+1

    img = sensor.snapshot()         # Take a picture and return the image.
                                    # to the IDE. The FPS should increase once disconnected.
    tag_list = []

    try:
        tag_list.extend(img.find_apriltags(families=tag_families))
    except (MemoryError, OSError):
        pass

    for tag in tag_list:
        if tag.id() == last_tag:
            tag_repeat_cnt = tag_repeat_cnt + 1
        else:
            tag_repeat_cnt = 0
            last_tag = tag.id()

        if tag_repeat_cnt > tag_repeat_threshold:
            if tag.id() > 1 and tag.id() < 100 and state==STATE_NORMAL:
                print("Access granted (FRIEND): {}".format(tag.id()))
                set_p1(1000)

Obviously this isn’t super secure but most people who are breaking into houses aren’t sophisticated enough to know about Fiducials. Most people will assume the camera is for someone in the house to remotely activate a switch. I am actually using somewhat different code.

Because the only power I have out there is the deep cycle battery running the gate controller, I put the OpenMV to sleep for 1/2 second at a time. Seems to do ok and has gotten through an entire winter with temps that fell to -40C.

New lab!

By   August 28, 2020

The whole Covid-pocalypse thing has expedited our move to DebtRidge.  It was a temporary move and we’re mulling whether to make it more permanent, or at least, invert the weighting on where our possessions are located.

This created a new problem; not enough room for me to do my ‘lab’ type stuff.  The 28’x36′ shop is great for big dirty work (welding, grinding, sawing, transmission rebuilds, etc) but not so good for hot air rework, 3D printing, etc.

Here’s what I had to do for 3D printing in the meantime:

Oddly enough, one of the companies I work for had a portable building previously used by CATSA as a Portable Screening Unit (xray, walkthrough metal detectors, preflight security) and it was just sitting there doing nothing.  This portable building was able to collapse to a size barely legal for road transport, was able to lift itself up high enough for a truck to back a trailer under it, and has a 20kW generator!

After a couple of years of sporadic but persistent querying on my part, finally I was given approval to buy this building from my customer.  Now I had a new problem:  Where to put it.

A bit of excavation and compacting later and here we have it:

The next problem was transport.  It took 2 months of research until I arrived at something cost effective and reasonably possible. To spare the details, the end result is I paid to have it trucked to the road in front of the driveway, and then had 2 friends come over to back it down the driveway on a trailer I rented in Sundre.

Loaded and on the way to DebtRidge

In front of the driveway.

Ready to lower onto the rental trailer

Not much room to spare

On the pad just after removing trailer. Standing on 3 legs.

Powered up and expanded

20kW diesel generator!

Initial layout.

I have lots more stuff to put in and set up but at least it’s functional now.

Anyone have a use for Yak fur?

By   September 15, 2018

This morning, I find myself with a small corral of naked Yaks. I’m guessing most people know about Yak Shaving Here’s how it went this morning.

Actually, it started yesterday.  I wanted to change the thermostat setting at the Cabin so it’d be nice and toasty when we got there.  Can’t for some reason.  Dig into the HomeAssistant console and discover the reason is that the component for my Venstar ColorTouch thermostat isn’t disabling the schedule so changing the temperature fails and generates an error from the thermostat.  I should fix it.

I figure out how to fix the bug but in order to submit a patch, I need to upgrade my HomeAssistant installation.

So do all the requisite ‘git fetch; git merge upstream/….’ stuff, and then upgrade everything in the virtual environment.

Unfortunately, I can’t upgrade the virtual environment because my Python is too old.

Can’t ‘apt install’ a new Python because I’m on an old Ubuntu 16.04.  Don’t want to go down that path right now.

Download a new Python, build, install.

Create a new virtual environment and reinstall all of the packages.

Installing packages fails (Twisted) because libbz2-dev wasn’t installed.

Install libbz2-dev.

Rebuild Python and reinstall.

Create a new virtual environment with the new python and reinstall all of the packages.

Installing packages fails due to a build problem with libopenzwave.

Looks like I need to upgrade my toolchain (g++ specifically).

I don’t like the look of that particular Yak. Lets try upgrading to Ubuntu 18.04.

My current version of ProxMox doesn’t support Ubuntu 18.04.

I need to upgrade ProxMox first.  Oh, that’s the greasiest Yak yet. It’s a major version upgrade.

I should really just build a new ProxMox from scratch, while running the old one.

I don’t have enough hardware to build a new ProxMox server, even temporarily.

I think I’m on the last Yak. So in order to submit a patch against HomeAssistant, I need to go to the Hardware Store.

Radon in our basement

By   November 27, 2016

Some folks at work were talking about their radon detectors the other day. Since I’m a sucker for gathering data, I was curious and did some reading. I’m usually not one for crackpot science and ‘radon’ just sounds like it would fit right in.

The first link I get when I type “radon” into Google is the Health Canada website and the second is Wikipedia.  Ok, maybe this isn’t so crackpot after all.

In short, radon is a colorless odorless gas.  Why is it that everything that wants to kill us is either colorless and odorless or furry and brown?   Radon is produced as a result of the decay of uranium which is in soil, rock and water. Normally it seeps out of the ground and dissipates in the air where it does us no real harm with a half-life of only 3.8 days (unlike furry brown things which don’t dissipate and have much longer half-lives).  It can cause problems when it seeps out of the ground and is trapped, say, under the concrete slab in your basement looking for a way in.  Once inside the living space of your home, when radon is inhaled, it breaks down further and emits an alpha particle, which I’ve read can strike a lung cell and cause cell death or worse, damage.  If a cell is damaged in a particular way, it can cause cancer.  As I am not a “nukular scientist” I won’t go into any more detail at the risk of confirming that I am a fool to those readers who already suspect it.    Statistically, however, the data is clear:  16% of lung cancers in Canada are caused by radon, as compared with 83% caused by smoking (Health Canada).

If the radon is under the floor of your basement, how does it get into the house? Unfortunately, it’s a very sneaky gas.  It can seep right through concrete but usually prefers to enter through cracks or the seams between your basement walls and floor; or any openings like those left for plumbing cleanouts.  As many of you know,  we spent about five years renovating our Bergen home which included sealing it from top to bottom and adding a heat exchanger to keep the air fresh while reducing the amount of lost energy.  Normally when it’s cold outside and your furnace comes on to heat your cold toes, that warm air rises and looks to escape through your ceiling (stack effect)…  Even the wind blowing on one side of your home can create a lower pressure area on the other side of your home pulling valuable warm air from inside the house.   All of that escaping air creates a slight negative pressure in your home and must be replaced by air from elsewhere.  Since most of our homes are relatively well sealed, that makeup air has to come from somewhere so it gets pulled from the under slab in your basement through the cracks and openings I mentioned above.

At first I thought I would measure the radon in our home.  We have a heat recovery ventilator and  I figured that since the air is being exchanged quite frequently, it would not be an issue.  So I bought an electronic radon detector for about $250 and put it in the basement.  There are a few different varieties of detectors.  The less expensive ones are the type you put in your basement for three to six months and then mail away to a lab where they are analyzed and the results mailed back to you.  These can be had for approximately $20 but I wanted something a little more interactive so I went with the electronic version that can give a very approximate number within 24 hours and more accurate data as time goes on.

In Canada, radon is measured using “becquerels per cubic meter”.  The World Health Organization recommends a national guideline of 100 bq/m3.  Health Canada has set our guideline at 200 bq/m3.

Within 24 hours, the first reading that came back from our detector was 446 bq/m3.  Since this is a very rough number as a first reading, I decided to give it a week to get something closer to accurate.  Well, seven days later, the reading was substantially higher:  1031 bq/m3.

1031

More than five times what Health Canada recommends as the upper limit, and more than ten times what the World Health Organization recommends.

I decided then that it was time to do something.  My goal was to get our readings below 100 bq/m3.  I read up on mitigation methods and it looked promising.  The best way to mitigate the problem is before the house is built but obviously that’s not an option for us, so I had to look at a retrofit solution.   It turns out the way this is done is by installing a fan outside the home (or in the attic) to suck air through a hole in the concrete slab and blow it up and away from the home.  The theory is that the gravel underneath your basement floor is fairly porous, so even creating a negative pressure zone in one corner will eventually suck the radon from all over the slab.   Normally a radon contractor will be happy to come into your home and install such a thing for $3000 or so.  In our case, a plumber already left a convenient hole in our floor exposing the gravel at the bottom through which  we were mining for radon.

img_20161113_093509

I knew that I could probably seal the hole and maybe reduce the radon levels a bit but I also suspect that it wouldn’t be significant enough given the various effects of air pressure during the heating months or windy months.  I like to think I’m a fairly handy guy (how did Red Green put it?  “If the women don’t find you handsome, at least let them find you handy!”), I decided the right thing to do was to follow the recommended mitigation method and install the fan.  The fan itself was $300 plus another $100 in PVC pipes and fittings.   The fan needs to be mounted outside of the living space.  You don’t want it inside the living space because the other side of the fan is pushing high concentrations of radon gas and a small leak will have you back to mining for radon again.   It took about 6 hours of work but I finally had the fan hooked up outside the house and powered it up for the first time.  I reset the detector and waited.

24 hours later, the first reading came in.  38 bq/m3.  I was cautiously optimistic.  A week later, it read 2 bq/m3.

2

Now the drawbacks.  The fan is fairly loud when it’s running; especially at the top of the 4″ PVC pipe that’s sticking up the side of the house.  It’s also fairly ugly.  While the fan is fairly energy efficient, it does consume 82 watts which is about $50/year in electricity.

Over the next year, I’m going to experiment by running the fan periodically.  I’ll start with a 50% duty cycle and adjust up or down depending on the readings.  Since the fan noise isn’t significant inside the house, I’ll start by running it primarily at night and less during the day.   Ideally, I would have one of the very expensive detectors that can hook to a computer so I can add some more intelligent automation behind the process as is my nature.  I suspect I’ll be able to get by with running the fan far less during the summer ‘window open’ months.   Only the data will tell me.

Now back to figuring out what piece of technology will let me address the furry brown things.

 

 

Delightful find!

By   January 21, 2016

Friend Mike sent along this Hackaday link on reverse engineering of some cheap chinese digital radio.  Since I dabble in digital radios at work it was of particular interest.  That article led me to downloading an issue of PoCk||GTFO which I had never encountered before.  A publication dedicated to reverse engineering or a glimpse into what the infinite monkeys are up to.  The writing is curiously delightful, most especially in the article on hacking a digital pregnancy test, e.g,

You can either look up the battery type to confirm it’s 3V, or just read the CE-mark label on the outside of the DPT that lists the part number, lot data, confirmation that this test is made by SPD GmbH out of Geneva, Switzerland (made in China), and that the test runs on 3V DC. Safety first, kids.

I spent my ‘hack time’ this morning reading this. [Aside: Usually I don’t allow myself the pleasure of ‘reading the internets’ in the mornings since I am smartest at 5AM and then become progressively more stupid as the day goes on.  By 21:30, I’m a drooling sack of meat barely capable of walking up the stairs to bed.   So I want to use my smart time for haxx0ring before I have to put it all down and head to work.]

San Juan 21 #2453

By   May 16, 2010

Dad and I – 1981

015

Jakob and I – 2010

IMG_7192

 

In the summer of 1979, dad and I took our 16′ Matilda on a road trip… We didn’t know where we’d end up if I remember correctly. We had some adventures like running out of wind on Kootenay Lake and then pouring rain… So we paddled for hours to get to Nelson, where we were headed… Just before we got to Nelson, the wind picked up and started howling just as we try to pull into the dock. Inexperienced sailors that we were, we ended up coming in on a run, then having to jibe to make the dock. Come up head to wind but still too much momentum and smack the mast/forestay into the ramp. Did some damage to the coach roof but it was all good. Rather than have to possibly paddle all the way back to the campground, dad bought a used 4hp Evinrude. Our travels eventually took us to Vancouver and we spent a couple of days walking the docks looking at all the boats. We ended up at a San Juan 21 dealer and after a quick phone call to mom, we ordered a brand new SJ-21. With pin stripes to match our Ford Econoline 150; which I guess is something you did back in the 80s.

Next spring, our boat was ready for delivery. We drove out to Vancouver to pick it up. SJ-21, #2453. It was our first brand new boat. That summer, we added lots of stuff; a VHF marine radio, spinnaker, auto-helm, cooking aparatus, lots of storage a genoa, etc etc. We had a lot of adventures in that boat. Pictured here is us launching the boat again that summer under the Burrard Street Bridge. That’s a 14 year old me standing in the hatch, and my dad grabbing the bow line and telling me how to start the motor (this is all from hazy memory).

We sold the boat a few years later and bought a C&C-25. I don’t know who we sold the SJ-21 to but my dad recalls it was a family in the kootenays.

I’m 43 now, and have a family of my own. I’d been through a Laser and then a Fireball; each of which being boats that I had in my youth. As a 43 year old I realized I wasn’t too into sitting in a wet cockpit or hanging my ass out on a trapeze anymore. My son Jakob enjoys sailing immensely so I figured something in a 20 foot cabin cruiser was a good size to transition to. A SJ-21 was high up on the list but I’d consider a 23 or a Santana 23 or something in that range that I could afford. I looked at a SJ-21 up at Sylvan lake in the spring of 2009 but the guy selling it was a scam artist. The ad read “awesome boat, recently faired keel and hull. Great condition. Overbuilt trailer – $4000” but upon arriving, the boat was half full of water, due to the many holes on the deck, cockpit floor, and transom no doubt; it was on flat tires (due to the water I’m sure), and one of the trailer bunk supports had rusted and broken leaving a rusty shard of steel poking into the hull. I gave up on my search after that realizing that if that’s what $4000 buys, I couldn’t afford a SJ-21.

Fast forward to spring 2010; I’m looking for SJ-21’s again. Missed out on one up in Lacombe (sold before I arrived), looked at another one out at Ghost Lake (deck rot), and then an immaculate specimen that was sold to someone over the phone while I was sitting inside of it… Mightily discouraged, I resigned to give up for another year. After an aborted camping trip, I found myself hitting reload on Kijiji and lo-behold, was a for-sale ad for a 1980 SJ-21 with the same pin-stripes as our old one. I drove up to Caroline AB to take a look. It was our old boat! It had aged not too badly over the years. Still had our original sails and there was evidence a plenty that it had had lots of adventures in the intervening 30 years; but the deck was solid and the rest was stuff I can fix. I made an offer; the offer was accepted; and the next day after procuring a bank draft I met the seller in Red Deer to exchange boat for bank draft.

I went through the boat, found a few fiberglass repairs, a few new additions, and began itemizing all the things that needed repair:

  • rudder seperating
  • port bulkhead is rotted
  • windows leaking
  • wiring is a mess
  • extra useless or inappropriate fittings, some installed with steel bolts
  • broken cheek blocks
  • an owie on the starboard bow
  • too much silicon
  • broken instruments
  • trailer guides
  • new halyards
  • re-rig spinnaker
  • replace steel mast step
  • remove anti-fouling
  • new motor mount plate
  • some sort ‘wow’ in the pulpit

So now the adventure begins.

While sorting through untold numbers of previous owners worth of stuff, I found some interesting things:

  • some child’s rock collection
  • a broken gooseneck fitting that I remember breaking at a regatta in 1981 or 1982.
  • bundles of department store wire with generic crimp fittings with thimbles. I wonder if someone replaced the stays at one point using home depot grade crap?

I forgot about these awards but Dad kept them. Looks like we got 1st place in the 1983 GYC Frostbite regatta.. There used to be a good 6 or 8 SJ21’s in the fleet at that time.