Tech in the tent

Andy Piper - Sep 25 '23 - - Dev Community

We’re just back from a week or so camping, in the wilds of mid-Hampshire.

It’s more-or-less the end of the season – the youngsters are back to school, the summer has wound down, so the sites are nice and quiet; although the weather is at risk of being more mixed than usual. As it happened, we were pretty fortunate on that front, and managed to get set up and broken down in the dry.

As a maker and techie, I sometimes get a bit antsy when we’re away like this (and when it isn’t EMFCamp… [1]). Fortunately, this time, I had a task that needed solving using technology – in this case, an RP2040 and some MicroPython.

Our tent is a very nice size, and we have space to sit and relax inside, but particularly in the evenings as the days get shorter at this time of year, the lighting situation leaves a lot to be desired. We’ve got a couple of battery-operated / rechargable camping lanterns, but wanted something more adjustable and that would cover more of the space, more evenly.

Like any good maker, I went camping prepared – with a soldering iron, massive power supply, and a roll of LEDs…!

Embedded Mastodon post with the text: "Just spent a bit of time setting up lighting for the tent. Fortunately, like any prepared #maker, I happened to bring soldering iron, solder mat, trimmers, #pimoroni Plasma 2040 #rp2040, and a lot of LEDs along on the camping trip. /cc @Raspberry_Pi TODO: a nice case for the Plasma 2040; I did not bring a #3dprinter with me to this field in Hampshire!"

First off, let’s briefly mention the power. I take a large Jackery Explorer 500 battery with us, along with the same brand’s solar panel for recharging (when it doesn’t rain…!). This trip, I also added an Anker 548 Power Bank as an extra power source; however, the solar panel uses a different connector than the newer battery expects, so I also picked up an XT60 adapter, which allows us to use the panel with the Anker as well, when needed. Works nicely, and we got the sunshine needed to stay topped up! ☀️

The lighting arrangement is simple. I cut the strip of WS2812B LEDs to length to fit the arch of the tent (this was the primary reason that I waited until we were actually on-site, to do this piece of work). The strip is inside a rubberised sleeve, which is handy for weather. At the “business end” of the LED strip, I’m running a Pimoroni Plasma2040 board – essentially, a Raspberry Pi Pico (RP2040) board specialised for driving lights, with a 4-way screw terminal, some extra push buttons, and a (as-yet-unused) StemmaQT/Qwiic connector, all with a USB-C connector. I’ve soldered the required wires to the LED strip and protected the connections with heat-shrink.

Code is (of course, if you’ve followed any of my IoT/embedded interests in the past few years) in MicroPython. I flashed the board with the latest Pimoroni MicroPython build, and – for now – trivially adapted some example Neopixel code to enable us to switch between two lighting formats, and also to switch the lights off again.

# TODO:
# - improve colour/brightness (currently a "dumb" division)
# - save/reload state
# - I2C sensor / input
# - (hardware) case for board

import plasma
from plasma import plasma2040
from pimoroni import RGBLED, Button

NUM_LEDS = 156

led = RGBLED(plasma2040.LED_R, plasma2040.LED_G, plasma2040.LED_B)
led.set_rgb(0,0,0)

button_a = Button(plasma2040.BUTTON_A)
button_b = Button(plasma2040.BUTTON_B)
button_boot = Button(plasma2040.USER_SW)

led_strip = plasma.WS2812(NUM_LEDS, 0, 0, plasma2040.DAT)

led_strip.start()

while True:
    if button_a.read():
        # dim white
        for i in range(NUM_LEDS):
            led_strip.set_rgb(i, round(253/3),round(244/3),round(220/3))
        led.set_rgb(round(253/3),round(244/3),round(220/3))
    if button_b.read():
        # bright white
        for i in range(NUM_LEDS):
            led_strip.set_rgb(i, round(253/1.2),round(244/1.2),round(220/1.2))
        led.set_rgb(round(253/1.2),round(244/1.2),round(220/1.2))
    if button_boot.read():
        # off / black
        for i in range(NUM_LEDS):
            led_strip.set_rgb(i, 0, 0, 0)
        led.set_rgb(0, 0, 0)

# for i in range(NUM_LEDS):
# led_strip.set_rgb(i, round(253/3),round(244/3),round(220/3))
Enter fullscreen mode Exit fullscreen mode

Plasma 2040 board connected to LED strip, showing the heat shrink. Plasma 2040 board attached to a white USB-C cable, with an LED indicating power, hanging inside a tent with blue and black canvas. LED strip arching through a blue tent, lit dimly.

Before you shout at me – yes, I know that having a bare board hanging there like that is “sub-optimal”, so next steps are to wrap it in some nice 3D printed case, as well as considering how or whether to use the Qwiic port… I’m thinking a rotary control for dimming would be more flexible than button presses. As noted in the code comments, it would also be very handy to have the state saved internally when the board is disconnected from the battery.

So anyway, that was a fun camping trip (with added making). Back to regular living situations, now.

How about you, how’ve you been?

--

[1] I am also now convinced that I need to get to CCC one year!

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .