Because the speaker is still slow, so if it got to it, there should be audio, but maybe the circuit filters out the PWM signal outright?
If the PIO pin could drive a fair amount of current at 3.3v into a long enough wire at that frequency you'd start to get into milliwatts, and AM radio is NOT a band that even amateur license operators can broadcast over a a certain power on. FCC part 15 dictates no more than a 3 meter antenna for personal devices at AM frequencies which is what does the power limiting essentially.
The harmonics fall off quick enough on such a setup that it wouldn't really be a problem - but the only way to really KNOW that is to have a real solid understanding of how this 'radio' you've just made is working, meaning how that square carrier wave is really being driven off the PIO pin, and thus you need the requisite EE knowledge and/or ham radio test equipment and experience.
I've seen more and more of these 'ChatGPT coded up a radio transmitter' posts and it kinda rubs me the wrong way. I'd like to see more calculations and disclaimers for people showing some responsibility with radio, and if it drives people to studying and taking an amateur radio license test that would be for the better...
"A rose by any other name would smell as sweet" -- BillTEMLEST-LoRa (2025) 87.5m with LoRa over display cables
LoPHY (2024) 700m with LoRA
MAGNETO (2021) CPU-generated magnetic fields
"Rowhammer for qubits" describes hypothetically using electron tunneling and magnetically biased bit flips in standard RAM to simulate quantum operators.
I've heard stories of ham radio clubs teaching how to make a coaxial antenna out of coaxial cable (cable TV copper cable)
"Can you hotwire this computer to transmit a tone through the radio?" — Transformers (2007)
Also a reasonably even bet that you already own a low-quality wall power supply that will produce more interference than anything you're going to be doing with a Pico and a 4" jumper wire (I've found a couple of offending devices in my house), but I'm certainly in no position to tell you if you should or shouldn't do something.
Without the proper knowledge or measurement equipment, I observed that the audio would fade out after a 30 cm distance. Combined with running it for mere seconds to test and record a demo, I assumed to be in the clear with the spirit of the regulations. Appreciate the reminder to be responsible with RF.
What the fuck, that's crazy. For those similarly bewildered, look here [1].
[1] https://www.usenix.org/conference/usenixsecurity15/technical...
That's Teleco 101, basically the first lessons from a Teleco trade/vocational degree. And OFC known at any electrician degree.
The PWM-based modulation is interesting, but as an amateur, I couldn't fully understand it or trust that the radio receiver reliably picks up the duty cycle as amplitude.
Obligatory legalese: emitting radio waves, even low-powered and/or short-lived may not be permitted in your jurisdiction.
Years ago, people figured out Raspberry Pi’s can accidentally double as FM radio transmitters without a need for any radio front-end (if we don’t count a single jumper wire working as an antenna). They achieved this by tying a GPIO pin to a software-controlled clock around 100 MHz to modulate audio. This created a low-powered FM radio transmitter. Due to the pin producing a square wave instead of a neat sine wave, it also emitted weaker harmonics at 300MHz, 500MHz, etc., but any basic FM radio could pick up the audio. I wondered if a similar feat could be achieved by much less powerful Raspberry Pi Pico microcontrollers.
While a Pico board doesn’t have the same architecture that allows FM transmission on regular Pi boards, it has a unique feature: PIO. This allows running programs based on a minimal instruction set independent of the CPU at the system clock rate. A simple program (“turn the pin ON, turn the pin OFF”) can then produce a square wave at half the system clock rate. Pico boards could be overclocked at ~200 MHz, allowing a similar carrier frequency, but the exact frequency cannot be controlled by software in any practical way. This rules out clean FM.
A Pico board can however allow better control at lower frequencies within the typical AM radio station (~1000 KHz). While square waves are well-suited for frequency-modulating any PCM audio file (ignoring the unwanted harmonics), they cannot be used well for amplitude modulation. They can only encode ON or OFF instead of different audio amplitudes (think 1-bit envelope). Alright, no emitting arbitrary “.wav” files. We can at least emit a single audio frequency at a time using On-Off Keying. Let’s make some retro game sounds!
With assistance from LLMs, I wrote this code that emits the Shave and A Haircut melody on a 1000 KHz carrier. Here’s a basic AM radio picking up the audio:
Your browser does not support the video tag.
One of the pins is programmed to produce a constant 1000 KHz square wave using PIO. The main program then turns the PIO on and off at the intended frequency. e.g. to emit an A4 pitch (440 Hz), it turns the 1000 KHz square wave on and off 440 times a second. To the radio receiver, this means a 440 Hz square wave audio. Using this technique, it emits the well-known Shave and A Haircut melody on a loop.