8 votes

What programming/technical projects have you been working on?

This is a recurring post to discuss programming or other technical projects that we've been working on. Tell us about one of your recent projects, either at work or personal projects. What's interesting about it? Are you having trouble with anything?

5 comments

  1. pseudolobster
    (edited )
    Link
    This will be second in a series of "Spending several days bashing my head against the wall trying to accomplish something using the wrong tools, punctuated by moments of severe idiocy." (Here's...

    This will be second in a series of "Spending several days bashing my head against the wall trying to accomplish something using the wrong tools, punctuated by moments of severe idiocy." (Here's part 1.)

    So for the past year or two I've been pursuing a weird off-grid lifestyle being self-employed mostly picking wild mushrooms in the middle of the wilderness (long story), and with that has come a world of challenges, both strictly technical as well as logistical. There's only so many spare parts I can carry in a 17ft camper trailer, and it's pretty hard to divine which will be most useful.

    Forseeing the need for a wifi booster at some point, I grabbed a Ubiquity Uni-Fi AP AC Pro I had in storage. I knew the stock firmware wouldn't be suitable since this thing is an access point, not a repeater. I did know though, it has more than one radio, and some pretty decent antennas built in. In my experience, as an access point, it always had amazing range. I also knew in advance that people have been able to port OpenWRT to it, and I assumed that means I'd be able to jailbreak the thing and turn it into a wifi booster, or maybe a NAS, perhaps a LTE bridge if I get some kind of USB cellphone modem, that sort of thing. So as a result, I brought it with me in the limited space available.

    Two months ago while picking morel mushrooms deep in the forest, 100km from civilization of any kind, 40km from the nearest major road, I suffered a serious injury. I was climbing over a fallen log, say a metre above the ground, started to lose my balance, jumped off backwards while doing a 180° rotation, landed on one foot really hard at a weird angle, still rotating, somehow managed to dislocate my motherfucking hip and break it in two places. Since then I've been trying frantically to return to the IT world and set up some kind of remote work so I can feed myself. Solid wifi is important to this, and I've been camping just a little too far from a wifi connection to get any actual work done. So that was my motivation for dusting off the Ubiquiti.

    Now, I've flashed OpenWRT to a lot of things in the past. I was pretty confident I can do this, even with limited electricity, flaky internet connection, and not much in the way of adapters, connectors, or other spare parts. I've flashed things using unmarked JTAG pins using USB-RS232 adapters having their voltage stepped down using random diodes twisted together since I didn't have a soldering iron at the time. Looking at the documentation it seemed this would be a cake walk. Just SSH in, downgrade to a specific firmware, use that to flash OpenWRT. If it bricks, it can be recovered via TFTP. No worries. This still somehow ended up taking almost a week of frustrating non-starts.

    First problem I had was a simple one. I simply miscalculated the number of ethernet cables I'd need to pack on my journey. I figured the most I could ever need is one, but being that this is a Power-Over-Ethernet device, I'll need at least two: one for power, the other for the LAN connection. I think I did actually think about this beforehand and I was under the assumptions A: you can splice power into an existing ethernet cable, B: POE devices use 12v. My camper's solar setup uses 12v. That's great! Well no, this thing requires an active 48v connection where it's able to talk to the power supply. No way to feed it dumb power, certainly not 12v.

    Getting another ethernet cable was a bigger problem than I anticipated. I'm 50km from the nearest town with stores in it. It took several days to organize a ride. During that time my mind came up with all sorts of terrible ideas involving my soldering iron. Maybe I can cut the ethernet cable in half and hardwire the two male ends to the POE injector, things like that. I even thought about soldering directly to the pads in my laptop going to the ethernet port. Eventually though, I managed to get a ride. The only electronics store in town was selling 1m ethernet cables for $29.95, and I immediately started asking about their return policies. Thirty bucks is a non-trivial amount of money for me right now, but luckily I managed to find a dilapidated little dollar store that by all accounts shouldn't carry ethernet cables, yet had them for $2. Score!

    So I finally go to plug in my access point, only to realize I'm a fucking idiot and both of the laptops I have in the trailer don't have an ethernet port. I'm so used to my last two laptops having them despite being super thin and ports being out of fashion that I totally neglected to even check. So for the second time in two days I tore apart my trailer looking through every storage compartment I could, trying to find something with an ethernet port. Luckily I was smart enough to bring a raspberry pi, which should work. Too bad I couldn't find an SD card. Another 3 hours of searching later, and I managed to find an 8gb card which turned out to be dead, another 4 hours lost.. Eventually found my girlfriend's spare cellphone, which had a working 16gb card in it, so I was able to get my raspberry pi up and running (after spending all night downloading a SD image at 10kbps)

    Now, I know Ubiquiti access points have a really annoying quirk, where they don't broadcast their SSID until they are plugged in via ethernet to a working internet connection, where they can presumably ping ubiquiti's servers. So, at this point when I plug the thing in, I get nothing visible over wifi. This is no cause for alarm at this point. But once I do a factory reset and plug my raspberry pi in via ethernet, it should be running a DCHP server and I should be able to SSH into the access point. This did not happen. As far as I could tell the device was bricked. Nevertheless I persisted. There's supposed to be another factory recovery mode where you hold the reset button for a long time, the light is supposed to blink blue and white, and you can use TFTP to upload a firmware image. This did not happen. No matter how long I held the reset button, I could not get the light to flash blue at all.

    So, knowing that ubiquiti devices hate not having internet, and refuse to do things until they have it, I tried setting up a wireless bridge on the raspi, trying to connect to the spotty internet I had, and feed it to the access point. Long story short this went nowhere. I'm also leaving out the part where the only usb wifi adapter I had was an ASUS AC56, which needs to have its kernel modules manually compiled, which is in fact broken on the current kernel release, but long story short this went nowhere.

    What did end up working, you ask? I woke up from a dream one morning with a half-remembered scenario where I was on the bridge of a TNG-era starship and I was arguing with my network engineer (???) and the phrase "auto negotiation isn't working!" stuck in my head. It suddenly came to me that I'd need to construct a crossover cable. Nowhere in any of the documentation does it mention this, it just says:

    "Directly connect Linux-PC and Unifi-device. If your device is powered through PoE insert just this PoE injector in between and keep the setup very simple."
    There's no way I ever would have tried this if I wasn't at my wit's end already. It's just too random. I thought all ethernet PHY chips automatically negotiated this for the past decade or more. I know I've personally never needed a crossover cable in the past 20 years. But I tried it anyway. I stripped my $2 ethernet cable with a swiss army knife, cut the green, orange, green-white, and orange-white wires and switched them, so that orange goes to green, green goes to orange, and so on, biting off the insulation with my teeth and twisting the wires together like some sort of neanderthal network engineer.

    Plugged it in and wouldn't you know, the raspi gets a DHCP address. I was able to TFTP the fimware just fine, my LED just never blinks blue for some reason. After a week of trying everything I could think of, thinking the thing was bricked, thinking I was going crazy, I tried something that came to me in a dream, and it worked.

    Wifi booster works great. Went from 0 bars to 5. These Ubiquiti devices are great hardware. I just kinda hate their software. OpenWRT is infinitely more flexible for the kinds of things I need this device to do.

    10 votes
  2. [3]
    skybrian
    Link
    My accordion MIDI controller thing is working! Video here. I have ideas on how to improve just about every part of it, but I think it might be time to declare victory and take a break from it. :-)

    My accordion MIDI controller thing is working! Video here.

    I have ideas on how to improve just about every part of it, but I think it might be time to declare victory and take a break from it. :-)

    3 votes
    1. [2]
      sleepydave
      Link Parent
      I love this, thank you for sharing! I'm not an accordion player but it sounds great and I'm sure the Pianobook community would love to see your work if you're feeling generous enough to share your...

      I love this, thank you for sharing! I'm not an accordion player but it sounds great and I'm sure the Pianobook community would love to see your work if you're feeling generous enough to share your sample library - just keep in mind they are true instrumental/sound nerds so they would be just as willing to dish out constructive criticism as they are willing to praise high-quality libraries haha :)

      1 vote
      1. skybrian
        Link Parent
        Glad you liked it! I hadn’t heard of Pianobook before, so thanks for mentioning it. A quick search found a few accordion samples that I will be checking out. (And I don’t mind constructive...

        Glad you liked it!

        I hadn’t heard of Pianobook before, so thanks for mentioning it. A quick search found a few accordion samples that I will be checking out.

        (And I don’t mind constructive criticism; this is the first time I’ve sampled an instrument and I don’t really know what I’m doing.)

        1 vote
  3. JRandomHacker
    Link
    Finally gotten some serious time to work on the web interface for my DIY smart thermostat. Our house was obviously built in multiple pieces at multiple times, so it has a wall-thermostat for each...

    Finally gotten some serious time to work on the web interface for my DIY smart thermostat.

    Our house was obviously built in multiple pieces at multiple times, so it has a wall-thermostat for each heat zone on the boiler, and two of those thermostats control different AC zones as well. I'm replacing all of them with a single Raspberry Pi mounted in the basement near the boiler and connected to a relay board to drive the actual heat/cool zones.

    The web interface isn't anything super crazy, but it's been satisfying to see the pieces come together on a from-scratch design. I'm now pulling temperature data from Z-Wave sensors around the house via MQTT, and have a basic REST API for polling the current temperature of a zone and setting the requested target temp. Next step is to actually figure out the HVAC control algorithm part (or maybe I don't need to get any fancier than "if temp is more than X degrees outside the acceptable range, enable heat/cool").

    1 vote