Friday, 18 April 2025

I kept going so here's a reminder for next time I've been away from the project for 2 years

🦄 Project Log: Upgrading My Unicorn Text Project (April 2025)

🚀 Overview

This project connects a Pimoroni Galactic Unicorn Pico W to a Google Cloud Platform (GCP) serverless API that controls the scrolling text remotely.

  • Backend: Node.js, Express.js, Firestore (GCP)
  • Frontend: Simple HTML/JS (eventually!)
  • Deployment: Cloud Run with Cloud Build
  • Security: Bearer Token Authorization + Secret Manager
  • Storage: Firestore Database

🛠️ Main Changes and Improvements

1. Local Pico W Development Setup

  • Installed mpremote for flashing and file management.
  • Created a deploy.sh script to easily push code to the Pico.
  • Setup .env secrets for WiFi credentials and server URLs.
  • Used Micropython firmware.
  • Created a pretty console output when deploying.
  • MicroPython Docs

2. Backend (Cloud Run API) Improvements

  • Split project into app.js (Express app) and server.js (listener).
  • Why split app.js and server.js?
  • Proper CORS setup to allow frontend to talk to backend.
  • Centralized Firebase Admin SDK initialization (utils/firebase.js).

3. Firestore Data Improvements

  • Structured Firestore documents to include:
    • text (display text)
    • updatedAt (server-side timestamp)
    • updatedBy (who set the text)
  • Logged every update into a Firestore subcollection history.

4. Secrets Management (Security)

  • Switched from environment variables to GCP Secret Manager.
  • Fixed service account permissions for secrets access.
  • GCP Secret Manager Docs

5. Frontend Changes (WIP)

  • Created a basic frontend for text updates.
  • Handled CORS properly.
  • Added Bearer Token headers to secure API requests.

📋 Final Tech Stack Overview

  • Hardware: Pico W (Galactic Unicorn)
  • Firmware: MicroPython
  • Local Dev Tools: mpremote, VS Code
  • Backend: Node.js, Express, Firestore
  • Authentication: Bearer Tokens
  • Secrets: GCP Secret Manager
  • Hosting: Cloud Run (serverless)
  • Database: Firestore (NoSQL)
  • Frontend: Basic HTML/JS

📚 Key Links for Future Reference


🧠 Lessons Learned

  • CORS must be handled before mounting routes.
  • Always explicitly initialize Firebase Admin SDK.
  • Structured Firestore data makes future features easier.
  • Logging to console and audit trails are essential for debugging.

🚀 Future Ideas

  • Add /history API endpoint to view full update logs.
  • Prettify the frontend to show timestamps and usernames.
  • Setup OAuth login instead of bearer token for future users.
  • Deploy frontend separately (Netlify, Firebase Hosting).
  • GitHub Actions for auto-deploy on commit.

🦄 Final Thoughts

This is no longer just a toy project — it's a scalable, secure, audit-logged cloud-connected Unicorn 🦄 system! With a real API, real secret management, history tracking, and easy extensibility — Ready for next steps whenever I pick it back up again!

Returning to the Unicorn

Building a Smooth Workflow for Raspberry Pi Pico W Projects with VS Code and mpremote

This morning I decided to tackle a nagging issue: my Raspberry Pi Pico W development workflow felt clunky. Uploading code manually, dealing with VS Code IntelliSense errors, and fiddling with board resets slowed me down.

I wanted a press one button, everything works experience.
Here’s exactly what I did to streamline my setup — and where I’m heading next.

Tuesday, 9 October 2018

And slowly we get worse...

So this timelog project started as a simple zsh script:

function timelog() {
if [ "$1" != "" ]
then
echo $(date +%H:%M) "$1" >> ~/timelogger/$(date +%Y-%m-%d).txt
fi
}

This created a new file if one didn't exist called <<date>>.txt (for example 2018-10-09.txt) that would then put whatever details were passed to it into it.
This had several advantages over what I've got to now, mostly it was nice and easy to edit.

With the changes I'm now making it does appear that I'm getting further away from where I was.

I've now got just about a graphql server running that just about works to retrieve whatever has been written, but I'm not yet using that to write to, soon, but not yet.

Adding more interesting and fun technology has been it's own reward, but it's not made what I'm working on much more useful (yet).

The git repos for the more confusing bits are here:

Tuesday, 25 September 2018

Adding a pile of issues...

This evening I added a pile of issues to GitHub, and in a shocking turn of events I've managed to fix one of them. By fix one of them I of course mean I found that things already worked that way.

I've also done some tidying up.

Next I want to start getting some unit tests in and then start some unit tests in a TDD style manner.

After that it's to the fun world of Graphql with go. I've found some fun filled exciting blogs about this.

I'm really quite enjoying go.

Monday, 24 September 2018

Keeping going with go

Well another evening of GO, which has been really quite good fun...

I've started moving some things about so that the code has separated a bit better. I had started with some testing, but that wasn't going so well, so that's a plan for next time!

Things that I've got going so far:

  • Working and compiling!
  • Reading config file
  • Connecting to a remote mongo db
  • Writing to a reading from mongo db
  • Reading the passed in parameter
I've also got a whole lot of VS code plugins working.

Go seems to encourage multiple repo's which is a little odd, but I suppose it's nice for encouraging code reuse and other bits, sure I'll get used to it (or start with one and then slowly move things out).

Repo's

Tuesday, 18 September 2018

Trying out a new language.

So about a year ago, my then (and now no longer) boss handed me a book saying you might be interested in this.
That's sat on my desk unopened for almost a year.

The Go Programming Language I've still not opened the book, but I put together a small command line app that could be used to record what I'm doing, while I'm doing it. I'll keep playing I quite like it (so far). If you're interested the repo is here: https://github.com/benjimouse/timelog I'll update with more details later.

Wednesday, 13 September 2017

Tortoise cam has arrived!

In exciting news tortoise cam has arrived!
I've put it together and followed a pile of instructions using a raspberry pi I had sat round not doing very much and now we have the capability to live stream the tortoises!
The instructions I followed are here:
http://www.makeuseof.com/tag/live-stream-youtube-raspberry-pi/
And they were remarkably easy to follow.

Now without further ado you should be able to see tortoise cam, obviously this is running off of my home wifi, so it could well stop working at any point (and that's without interruptions from a 3 and 6 year old).
The live stream should be able to be found at:
https://www.youtube.com/c/BenBest/live

If you follow that link in the next few minutes you should see my wife and I attempting to put together a "tortoise table"!