Thursday, October 29, 2026

0000 0001 0001 0100

Mosfet gives µC joy (and maybe a new µC?) 

In a previous video we looked at retiring the QX5252 workhorse of the candle project in favour of a boost converter (a modified BL8530)

The problem with measuring the light (and hence determining if it is day or night) using a comparator on the PFS154 is that the solar panel voltage dips alarmingly when the BL8530 is drawing current.

Net result? The PFS154 keeps making the wrong decision re nightfall - it mistakes a drop in voltage due to the hungry supercap/boost converter duo for a drop in voltage due to the sun disappearing for the day.

What to do?

Well I went up to the ideas factory with my furry partners, and drew the following possible solution...

...then we went to the lab and tested some switching code...

/*
  MOSFET Bench Test / Blink Example for PFS154
  Drives PA7 HIGH/LOW to switch a low-side N-Channel MOSFET (BS170 or AO3400).

  Connections:
  - PFS154 Pin 2 (PA7) -> MOSFET Gate (Pin 2)
  - MOSFET Drain      -> LED Cathode (-) (LED Anode + goes through 330R to VCC)
  - MOSFET Source     -> System GND
  - 100k Resistor     -> Between PA7 (Gate) and System GND
*/

#include <pdk/device.h>
#include "auto_sysclock.h"
#include "startup.h"
#include "delay.h"

// Hardware bitmask for PA7 (Bit 7 / Pin 2)
#define MOSFET_GATE_BIT 0b10000000

// Helper macros for N-Channel MOSFET control
#define turnMosfetOn()   PA |=  MOSFET_GATE_BIT  // Drive PA7 HIGH -> MOSFET ON
#define turnMosfetOff()  PA &= ~MOSFET_GATE_BIT  // Drive PA7 LOW  -> MOSFET OFF

void mydelay(uint16_t ms) {
    while (ms > 0) {
        _delay_ms(1);
        ms--;
    }
}

void main(void) {
    // Set PA7 as Output Mode
    PAC  |=  MOSFET_GATE_BIT;  
    PAPH &= ~MOSFET_GATE_BIT; // Disable internal pull-up
    turnMosfetOff();          // Ensure MOSFET starts OFF

    while (1) {
        turnMosfetOn();   // PA7 HIGH -> MOSFET ON -> LED ON
        mydelay(4500);

        turnMosfetOff();  // PA7 LOW  -> MOSFET OFF -> LED OFF
        mydelay(4500);
    }
}

unsigned char STARTUP_FUNCTION(void) {
    AUTO_INIT_SYSCLOCK();
    AUTO_CALIBRATE_SYSCLOCK(TARGET_VDD_MV);
    return 0;
}

...and finally we made the following video to explain the possible update to the candle project.

Also, please stay to the end of the video for an announcement of what might be the next iteration in this project.



Wednesday, October 7, 2026

0000 0001 0001 0011

The death of the QX5252?

For years I have been working on the candle project - the idea of an environmentally friendly perpetual "candle", solar powered, that does justice to the gentle flickering of a real candle, including sputtering, has driven a lot of content on this channel!

The only unease I have felt is in using NiMH batteries for solar power storage. Heavy and having a fairly low power cycle count, the main issue was environmental - some nasty chemicals and a not particularly long life meant too many would end up in landfill.

Then in the super capacitor realm we had 120F and 250F LIC capacitors that charged to 3.8V, has a cycle count between 100000 and 1000000 charge/discharge cycles, was light weight and seemed to contain a number of problematic barriers:

1. Making the code so efficient that a super capacitor could drive the project

2. Make the PFS154 better at monitoring the day/night interface to optimise power usage

3. Boost/control the output of the solar panel to charge a 3.8V super capacitor safely

This third hurdle bothered me A LOT because the QX5252 was 80% efficient on a good day and I was using a 3.9V zener clamp on the output which further wasted power.

I needed a good DC-DC boost converter that could step into it's shoes (after all there must be tens of videos on this channel that feature this little soldier).

And so the search began - with some parameters to help me weed out contenders. AI was not much help (a bit too "chicken Little" for my taste)

I am really happy with the TPS6102X family (featured before on this channel), but it is too expensive at the moment, and so with cost in mind I compromised to the BL8530/1N5817 combo.

Please take a look at the video and let me know what you think - especially if you have another contender!




Monday, September 21, 2026

0000 0001 0001 0010

The final candle code(?)

Those who have been with this channel for awhile would know that this fake candle obsession of mine dates back at least to 2017!

Over the years this one project has driven my understanding of code, both C and ASM, as well as some deep dives into microprocessors such as the PFS154 and the ATTiny13A. I've learned about "randomness" and even written a book on Assembler.

Now I feel like it's time to release all the code into the wild (well as wild as github gets) and also pose a question for you - if you could download working candle code for an ATTiny13, or ATTiny85, or a CH32V003 - would you be interested?

The code is pretty mature now and the latest version (just 1.8kB compiled) contains such elements as:

  • 32 bit PRNG Xorshift code
  • Noise seeding the random generator using the timer and the comparator
  • Dusk/Dawn Hysteresis
  • Code efficiencies including array dimension
  • Super capacitor over discharge protection

Enjoy the video, and the repository, and please comment if you'd like to see the project extend to other micro-controllers, and name your favourite!

Links:



Friday, September 18, 2026

0000 0001 0001 0001

Cheap Bluetooth Speaker Set

Forever I've wanted to build a Bluetooth Speaker - they seem hideously expensive IRL (and recently I've had one fail on me) but the components seem fairly cheap, so I wanted to see if we are being ripped off by the retailers (spoiler alert: holy hell yes!)

It all started when I spied a TSA3110 module on AliExpress for about $2, and a similarly priced HW425 Bluetooth module/decoder.


I also had a few old (free) computers lying around so I grabbed an ATX breakout module which gives me the slightly underpowered +12V for the amplifier board and +5V for the Bluetooth board.


Also, you don't really need to buy speakers if you frequent (as I do) local recycling depots - what people throw out is scandalous, but also great for you and me! But I did splurge on two speakers which had great reviews and more than doubled the cost of the project. Good speakers are worth the search!

Anyhoo - this project resulted in a lovely sounding Bluetooth speaker which is a little butt ugly due to my complete lack of carpentry skills (see building montage), but I'm sure it will be a great addition to the lab for those long days/nights of soldering.




Sunday, September 6, 2026

0000 0001 0001 0000

Success! (...and failure)

This video and post is a quick follow up on the last one where I thought it was remiss of me not to actually test the TPS61023 to see if it could actually charge the 3.8V LIC SuperCap. Spoiler alert - it can!


Also I talked briefly last time about the nonsense PCB I made which featured a "fake battery" to fool the QX5252 into output - as it turns out the fool was me! Lesson learned...



Tuesday, September 1, 2026

0000 0001 0000 1111

Back from the edge

Hi all! It's been awhile (last blog Wednesday, April 22, 2026:  132 days)

In that time I've had  ̶m̶y̶ ̶b̶r̶a̶i̶n̶ ̶r̶e̶m̶o̶v̶e̶d̶  a tumour in my brain removed, and have been slowly recovering from what has been a ludicrously intense few weeks.


I have also been working on a few things:

  1. The supercap candle (video)
  2. An RPi NAS via Tailscale and Nextcloud
  3. Some writings

I have also been thinking about how on earth I re-introduce myself to you all after such a long break - and it seemed easiest to just dive in and do what I've done in the past - take a deep dive into an IC and then wreck it by soldering some silly nonsense to it.

Enjoy and thank you for waiting...




Wednesday, April 22, 2026

0000 0001 0000 1110

A little ripper!

In the middle of weeks of rabbit holes regarding the sleeping PFS154, a ray of light arrived in the form of the XIAO ESP-32 C5.

I'd ordered it for projects where a strong 5GHz connection was more preferable to the crowded 2.4GHz band in my house where "smart" lights jostled for attention on my horrible router (another video sometime perhaps).

All I wanted to do was to test if it really was dual band, so the following code emerged after a brief session with Gemini - and yes - the little guy came through.

Here is the code you will need...


/*
  OneCircuit ESP32-C5 Dual-Band Discovery Demo
  Target: Espressif ESP32-C5 (Dual-Band Wi-Fi 6)

  YouTube: https://www.youtube.com/@onecircuit-as
  Blog: https://onecircuit.blogspot.com/
  Github: https://github.com/bovineck/
  
  IMPORTANT: This code requires ESP32 Arduino Core v3.0.0 or higher.
  The ESP32-C5 is a dual-band SoC (2.4GHz and 5GHz). 
  1. This demo scans each band separately using setBandMode().
  2. To protect privacy, SSIDs are NOT printed to the Serial Monitor.
  3. Signal strength (RSSI) is used to verify the discovery of local bands.
  4. An external antenna is required for optimal 5GHz performance.

  Wed 22 Apr 2026 18:45:00 AEST

  DEVICE = XIAO ESP32-C5
       __________
      /  FRONT   |
  1--|D0       5V|--14
  2--|D1      GND|--13
  3--|D2     3.3V|--12
  4--|D3      D10|--11
  5--|D4       D9|--10
  6--|D5       D8|--9
  7--|D6       D7|--8
     |___________| 

*/

#include "WiFi.h"

void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA); // Set to station mode
  WiFi.disconnect();
  delay(100);
  Serial.println("--- ESP32-C5 Privacy Dual-Band Scan ---");
}

void scanBand(const char* bandLabel, wifi_band_mode_t bandMode) {
  // Set the hardware to the specific band
  WiFi.setBandMode(bandMode);
  
  Serial.printf("Scanning %s band... ", bandLabel);
  int n = WiFi.scanNetworks();
  
  if (n <= 0) {
    Serial.printf("No %s SSIDs discovered.\n", bandLabel);
  } else {
    int strongestRSSI = -100; // Start low
    
    // Find the strongest signal without storing or printing SSIDs
    for (int i = 0; i < n; ++i) {
      if (WiFi.RSSI(i) > strongestRSSI) {
        strongestRSSI = WiFi.RSSI(i);
      }
    }
    
    Serial.printf("A %s SSID has been discovered with the following strength: %d dBm\n", 
                  bandLabel, strongestRSSI);
  }
  
  WiFi.scanDelete(); // Clear results from memory
}

void loop() {
  // 1. Scan 2.4 GHz
  scanBand("2.4GHz", WIFI_BAND_MODE_2G_ONLY);
  delay(1000);

  // 2. Scan 5 GHz
  scanBand("5GHz", WIFI_BAND_MODE_5G_ONLY);
  
  Serial.println("------------------------------------------");
  delay(5000); // Wait 5 seconds before the next update
}

One caveat - there is no onboard antenna, you will need to plug in the provided external antenna to ensure a strong connection - the difference is remarkable, see results below.

Before external antenna:

------------------------------------------
Scanning 2.4GHz band... A 2.4GHz SSID has been discovered with the following strength: -86 dBm
Scanning 5GHz band... A 5GHz SSID has been discovered with the following strength: -56 dBm
------------------------------------------

After external antenna:

------------------------------------------
Scanning 2.4GHz band... A 2.4GHz SSID has been discovered with the following strength: -17 dBm
Scanning 5GHz band... A 5GHz SSID has been discovered with the following strength: -26 dBm
------------------------------------------

Here's the (brief and interrupted) video below - enjoy!