Tech in the tent
Tags: micropython, travel, iot
Published: 2023-09-25 21:15:07

---
title: Tech in the tent
published: true
date: 2023-09-25 20:12:16 UTC
tags: micropython,travel,iot
canonical_url: https://andypiper.co.uk/2023/09/25/tech-in-the-tent/
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2xnl5prmy5eui78t3gws.jpg
series: esp32c2-bling
---

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](https://dev.to/andypiper/what-ive-been-doing-in-2022-so-far-4o76-temp-slug-6906714)… [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](https://macaw.social/@andypiper/111059272892732378) – 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!"](http://andypiper.files.wordpress.com/2023/09/xnapper-2023-09-25-19.28.55.png?resize=514%2C600)

First off, let’s briefly mention the power. I take a large [Jackery Explorer 500 battery](https://amzn.to/48sQeOk) with us, along with [the same brand’s solar panel](https://amzn.to/3PokgtK) for recharging (when it doesn’t rain…!). This trip, I also added an [Anker 548 Power Bank](https://amzn.to/3PxZxnl) 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](https://amzn.to/456Ejmx), 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](https://shop.pimoroni.com/products/plasma-2040?variant=39410354847827) – 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.

```python
# 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))
```

![Plasma 2040 board connected to LED strip, showing the heat shrink.](http://andypiper.files.wordpress.com/2023/09/img_0361.jpg?resize=429%2C600 "IMG\_0361.JPG") ![Plasma 2040 board attached to a white USB-C cable, with an LED indicating power, hanging inside a tent with blue and black canvas.](http://andypiper.files.wordpress.com/2023/09/img_0269-2.jpg?resize=429%2C600 "IMG\_0269 2.JPG") ![LED strip arching through a blue tent, lit dimly.](http://andypiper.files.wordpress.com/2023/09/img_0268-2.jpg?resize=599%2C337 "IMG\_0268 2.JPG")
 
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](https://hackaday.com/2023/08/19/chaos-and-camping/) one year!