Using VirtualWire without Arduino IDE/Bootloader

746 views
Skip to first unread message

James Minihane

unread,
Oct 3, 2013, 12:24:40 PM10/3/13
to virtu...@googlegroups.com
I want to use VirtualWire on a Tiny45 chip to transmit only. I'll also be building a receiver using a Mega168/328 or a Tiny84 for testing. But back to the Tiny45

I'm having trouble getting the code ported to compile using gcc without Arduino AND function.
I do not need a boot loader or the _timer_calc() bloat (Tons of floating point math with longs). I can calculate the pre-scale and ticks values myself.
If I chop out all of the receive code and calculate the pre-scale and ticks myself I can get the C code down to ~944 bytes. (This could probably fit on the Tiny24)

But, before I start posting a ton of code and details here before trying everything else.

Has anyone used/adapted the VirtualWire library (C++) to run on an AVR (C, GCC) without using the Arduino IDE?

James Hamilton

unread,
Oct 3, 2013, 12:45:44 PM10/3/13
to virtu...@googlegroups.com

I haven't tried to do so, but looking at the code, I only see a few functions being called from the Arduino libraries. It should be fairly straightforward to replace those, although I'm not sure about platform independence with other ways of doing, e.g. digitalWrite().

I'm also not sure why virtualwire.cpp is a .cpp file. The only C++ I see in it is the extern "C" wrapper. Had anyone tried removing the extern line and compiling it as straight C?

~James

--
You received this message because you are subscribed to the Google Groups "virtualwire" group.
To unsubscribe from this group and stop receiving emails from it, send an email to virtualwire...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

James Minihane

unread,
Oct 3, 2013, 1:23:20 PM10/3/13
to virtu...@googlegroups.com
I didn't have to make a lot of changes to the code. You're right. digitalWrite digitalRead, and setting up the IO pins was another. But that was pretty straight forward. PORTB |= (1<<PORTB0) etc.
The code compiles and it does produce output (36 preamble bits followed by a bunch of other stuff). The receiver interrupt is firing 8 times for every input bit.
I just can't be sure that it's fully accurate output.

I may buy an Arduino to act as a sanity check transmitter and receiver.

But before I did any of that I wanted to see if anyone has already done what I'm trying to do.

Thanks, for responding James.

James Minihane

unread,
Oct 4, 2013, 9:50:58 PM10/4/13
to virtu...@googlegroups.com
Everything is working now. 974 bytes on a ATTiny45 (will try a tiny24 for final) for transmitter and 1050 bytes on a ATTiny84 for the receiver.
Now to create a library for tx and rx that I can re-use more easily. More suited to straight AVR programming without Arduino.

Andreas Steinel

unread,
Mar 12, 2014, 12:41:44 PM3/12/14
to virtu...@googlegroups.com


On Saturday, October 5, 2013 3:50:58 AM UTC+2, James Minihane wrote:
Everything is working now. 974 bytes on a ATTiny45 (will try a tiny24 for final) for transmitter and 1050 bytes on a ATTiny84 for the receiver.
Now to create a library for tx and rx that I can re-use more easily. More suited to straight AVR programming without Arduino.

Are you willing to share your changes? I'm also looking for a plain C version of this library to embedd it into vusb.

James Minihane

unread,
Mar 12, 2014, 6:30:10 PM3/12/14
to virtu...@googlegroups.com

Sure. I'm away from my shop right now. But I'll email them to you.

--
You received this message because you are subscribed to the Google Groups "virtualwire" group.
To unsubscribe from this group and stop receiving emails from it, send an email to virtualwire...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James Minihane

unread,
Mar 13, 2014, 8:55:21 AM3/13/14
to virtu...@googlegroups.com
Andreas,
Attached are a few files I've created to reduce the code size. You need to know what you're doing to use this code since it is not an Arduino library. You need to know C programming for AVRs. 
Transmitter_Tiny45.zip
Receiver_Tiny84.zip

Andreas Steinel

unread,
Mar 13, 2014, 8:58:14 AM3/13/14
to virtu...@googlegroups.com
Hi James,

On Thu, Mar 13, 2014 at 1:55 PM, James Minihane <jim.mi...@gmail.com> wrote:
> Attached are a few files I've created to reduce the code size. You need to
> know what you're doing to use this code since it is not an Arduino library.
> You need to know C programming for AVRs.

I know and I'll use it outside the arduino environment.
Thanks for sharing.

Best,
Andreas

James Minihane

unread,
Mar 13, 2014, 10:59:25 AM3/13/14
to virtu...@googlegroups.com
Alright then. Happy coding.



--
You received this message because you are subscribed to a topic in the Google Groups "virtualwire" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/virtualwire/XZmWJB9TNXg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to virtualwire...@googlegroups.com.

Ralf Steinhaeusser

unread,
Sep 29, 2017, 12:56:03 PM9/29/17
to virtualwire
Hey!
Just 2 short questions:
1.) Is your port compatible with the "original" VirtualWire? So will a board programmed using Arduino (eg the ArduinoUNO with the ATmega328P) and VirtualWire be able to read what "your" board is sending?
2.) What are the requirements for the AtTiny. Does it work with 1MHz or does it need 8MHz?

Thanks in advance for your answer and THANKS a lot for sharing your code!

Ralf
Reply all
Reply to author
Forward
0 new messages