Turn your Arduino into an AM radio transmitter!

I'm not a ham operator (or FCC narc), but both of those would love to string you up by the short & curliest if this was ever released in the wild! Let's extend the range with a power amplifier ;)

1 Like

HAM operator gets upset over extremely short range AM transmitter....

I think that my PC with the box side panel removed makes more radio noise and I've not had any trouble in over 30 years of running that way.

terryking228, did you ever listen to Waltzing Matilda on a portable radio set on top of an IBM 1401/1440?

No, but I heard about it! I worked with guys at IBM who would happily spend hours coding something that would produce the coveted response from peers: "What the Hell is THAT??"

Dave Millman would talk to you while nonchalantly twirling the front panel hex switch knobs on an idle System 7 and stabbing buttons. Then he would hit reset and the panel lights would do a cool pattern. He'd walk away, saying:

"A Busy Computer is a Happy Computer!"

I have that ditty posted here on a placard I wrote in 1975...

ArduinoUser: Hello, can anyone post receiver circuit? I need it just to turn led on/off on signal received. Thanks.

Just google, "am receiver circuit" :)

I picked one for you.

http://www2.eng.cam.ac.uk/~dmh/ptialcd/trf/trf.htm

Hi everyone,

I realize this is somewhat of an older thread. I tried this project with my Uno and it worked really well! After all, with only one component to plug in, it was hard to mess up the wiring.

I was trying to port this project over to the ATtiny85 chip, and I got lost when it came to setting the clock. For the Uno, the code to set up the 1MHz square wave signal is:

// set up Timer 1 TCCR1A = _BV (COM1A0); // toggle OC1A on Compare Match TCCR1B = _BV(WGM12) | _BV(CS10); // CTC, no prescaler OCR1A = 7; //(From frequency Table Above ( compare A register value to 10 (zero relative))

What would the analogous set of commands be on the ATtiny85 architecture?

Many thanks in advance, Dave

You need the ATtiny85 full datasheet (I don't have here, ATMEL does.) PDF and the one for ATmega328P. Each covers a whole line of similar AVRs with memory differences but same pins and ports.

Funny, I don't find the full family sheet for 328P. It's compatible with even less than the 168P, http://www.microchip.com/wwwproducts/en/ATmega328P

http://ww1.microchip.com/downloads/en/devicedoc/atmel-2586-avr-8-bit-microcontroller-attiny25-attiny45-attiny85

You want a window or tab for each PDF and open the Arduino IDE.

ATtiny serial ports are not as featured as ATmega serial ports. Read the 328 timer section overview and then the 85's, the differences will show right away,

Thank you GoForSmoke.

I did wade through the datasheet for the attiny85, and the section on setting the clock is unfortunately over my head. I tried various approaches based on what I found in newsgroups. I had good results using code here:

I could set the frequency based on the following code:

// Timer/Counter0 Compare Match A interrupt handler 
ISR (TIMER0_COMPA_vect) {
   PORTB ^= 1 << PINB4;        // Invert pin PB4
}
 
void setup() {
    OSCCAL += 3;                // User calibration
    pinMode(4,OUTPUT);          // Set PB4 to output
    TCNT0 = 0;                  // Count up from 0
    TCCR0A = 2 << WGM00;        // CTC mode
    if (CLKPR == 3)             // If clock set to 1MHz
        TCCR0B = (1<<CS00);     // Set prescaler to /1 (1uS at 1Mhz)
    else                        // Otherwise clock set to 8MHz
        TCCR0B = (2<<CS00);     // Set prescaler to /8 (1uS at 8Mhz)
    GTCCR |= 1 << PSR0;         // Reset prescaler
    OCR0A = 49;                 // 49 + 1 = 50 microseconds (10KHz)
    TIFR = 1 << OCF0A;          // Clear output compare interrupt flag
    TIMSK |= 1 << OCIE0A;       // Enable output compare interrupt
}
 
void loop()

I found that shrinking the delay (OCR0A) increased the frequency, but I hit a ceiling at about 200 kHz no matter how hard I tried - and that’s with setting the ATtiny’s internal oscillator to 16 MHz.

So as it turns out, I lack the basic understanding necessary to set the clock on my own without following other people’s code. I was looking for a good online tutorial. There were various sites, but the knowledge seems to be finely dispersed in staggered message threads. The whole experience made me REALLY appreciate the Arduino IDE taking care of all these commands for you with the Uno.

To make a long story short, I ended up using a CMOS 555 timer today for the carrier signal, which did the job quite nicely, and broadcast morse code all over my lab at 1 MHz. Since the range is quite limited and I doubt people listen to AM in my building, I don’t think anyone heard “scott rocks” repeatedly, the message that was embedded in the example code from here:

http://www.swharden.com/wp/2011-08-06-ridiculously-simple-avr-mcu-am-radio-transmitter/

I really like the 555 solution because I can fine-tune the frequency with a 10K trimmer, rather than perhaps be constrained to multiples of a clock divider. Still, if anyone knows offhand how to elicit a 1MHz signal from an ATtiny85, or would be patient enough to tell me the secrets of setting the clock beyond 200 kHz, it will be useful for this and other projects.

Kind regards,
Dave

Here is the secret to what you are doing, from my pulse and digital circuits class from many years ago. A square wave, like from your NE555 circuit contains a fundamental frequency, plus an infinite number of third and higher harmonics of your fundamental frequency. The squareness of the corners of the square wave, seen on an oscilloscope depends on the power in those odd harmonics. More power, the sharper the corners.

What you are listening to is a harmonic of your fundamental square wave frequency. You don't need to get the square wave to be the frequency you want to listen to, but can be 1/2, 1/3, or any other division. The power goes down as you divide down, but can still be heard on your receiver.

If the code signal, CW, you heard was a pure sine wave, you would not hear it on an AM receiver, no AM modulation. So, it is really a really bad square wave that makes it audible on an AM receiver.

Paul

Thanks for that, Paul. It's fascinating, isn't it? How a series of sin curves can add up to (and eventually approximate) a square wave, and although we see it as square on the scope, it's really the sum of a bunch of harmonics. My instinct after looking at the waveform today was that if I were to use a more sinusoidal-shaped carrier wave, I would get a clearer signal, but I can see from your response that those harmonics can actually help you catch the signal close by, and indeed I heard that while tuning the radio to find my signal. There was more than one sweet spot on the dial where it came through. What amazes me the most is how many signals must be in the air in downtown Toronto (where I live). It's a wonder to me that so many cellphones can operate simultaneously. It would be fun to harness that power somehow, at the expense of course of people sending selfies to each other.

All the RF power you are referring to amounts to microwatts per square meter. Some researches have developed equipment that can power themselves with the power floating around. Not very practical, yet, but will be.

All the cell signals operate in narrow bands with various coding schemes from the cell towers, so many cell phones can receive on the same frequency. Technology changes from time to time. One connection does not effect the other, even adjacent devices.

Paul

Thanks for this thread - this is a really fun project starter.

I've been hoping to do some proper amplitude modulation of the carrier, but it seems as though whatever the carrier level is set to once the code is flashed is a constant value (on or off), rather than one that can be varying with the modulating signal.

So I was wondering...is it possible to vary our carrier (if the project is set up as in the original post) to achieve proper amplitude modulation?

Would varying the carrier by an arbitrary amplitude envelope ( e.g a song from an mp3 player or smartphone) result in successful modulation for radio transmission? And if so, how many ways are there to do that with a basic arduino kit?

Sorry if these seem like daft questions - I normally work with AM/FM signals in the audio domain, not radio.

Get a DAC module or buy a Due or similar (has stereo DAC outputs) and get proper analog out.

As a licensed radio ham I found this interesting and immediately built it. And trying to find a quick and easy way to slightly tune it I tried setting the OCR1A value from 1 to 0.1 and was stunned with the result.

  1. The frequency remained on 8khz
  2. Output power increased by 18db WOW!

(tested on proper rig and results are repeatable)

Interesting

Could someone explain

You set an 8 bit register to a 32 bit float what could possibly happen?