ATtiny85 RF Remote Control

As I mentioned in a previous Instructable I recently started playing with some ATtiny85 chips. The initial project I had in mind was to make an RF remote control that could operate on a coin battery. I needed to go with a raw chip because none of the Arduinos I have can meet both the need for very low power and relatively small size. A modified LilyPad came close but the chip is a better answer. The idea was not so much to duplicate an existing remote but to demonstrate how you can make up your own transmitter and receiver set. Besides being a fun learning project, it also allows you to create your own “secret” code combination. I put “secret” in quotes because it’s pretty easy to crack these simple codes.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: RF Message Format

For this project I chose to replicate the signals for one of my Etekcity RF wireless switches (refer to my Instructable on those modules). I did that because I was able to verify that my transmitter works with the Etekcity receiver and that my receiver works with the Etekcity remote. I also happen to know exactly what the correct codes and format are for those devices because I captured them previously. Refer to my “Arduino RF Sensor Decoder” Instructable for the code capture sketch.

The codes and formats for the Etekcity outlets are very typical of inexpensive RF devices. I have cheap security devices that use very similar formats with just some timing variations. The message length is a convenient 24 bits with a long start bit and a short stop bit. You can easily modify the code to add more bytes of data and to change the timing of the sync and data bits. Again, this sketch is just a starting template.

Step 2: Hardware

The transmitter runs on a coin battery (2032) so low power consumption is key. Most of that is accomplished in the software but it is helped by the fact that the ATtiny85 normally runs on the 1-MHz internal clock. The rule is that lower clock frequencies require less power and 1-MHz is perfect for the transmitter logic.

The actual RF transmitter module I like to use is an FS1000A that is commonly available. It comes in both 433-MHz and 315-MHz versions. The software doesn’t care which one you use, but you need to make sure that the receiver board operates at the same frequency. Most of my projects use 433-MHz devices because that is what is used by the various inexpensive wireless devices I have accumulated. The transmitter board layout shown in the picture fits nicely into an old pill bottle. It’s not pretty but good enough for a proof-of-concept.

The receiver is on a solderless breadboard because its only purpose is to show how to receive signals and how to turn something on/off based on the codes received. It uses an LED to indicate on/off status but you could replace that with a relay driver, etc. Any Arduino can be used for the receiver because it doesn’t need to run off of a battery. If size is still a consideration you can use another ATtiny85 chip. The key is that the ATtiny85 needs to run at 8-MHz in the receiver. Refer to my earlier ATtiny85 Instructable for a simple sketch that verifies that you have successfully changed the internal clock to 8-MHz. At the end of my Instructable on sensor decoding I include an Arduino Nano version of the receiver software. It’s identical to the ATtiny85 version included here except for a couple of chip register differences.

As I detailed in my earlier RF Instructables, I prefer to use a receiver like the common RXB6. It’s a super-heterodyne receiver which works much better than the super-regenerative receivers commonly bundled with the FS1000A transmitters.

Both the transmitter and receiver modules work better with the proper antennas but they are often not supplied. You can buy them (get the correct frequency) or you can make your own. At 433-MHz, the right length is about 16 cm for a straight wire antenna. To make a coiled one, take about 16 cm of insulated, solid core wire and wrap it around something like a 5/32-inch drill bit shank in a single layer. Strip the insulation off of a short straight section at one end and connect it to your transmitter/receiver board. I’ve found that the wire from a scrap Ethernet cable works well for antennas. The transmitter board usually has a place to solder the antenna but the receiver board may only have pins (like the RXB6). Just make sure that the connection is secure if you don’t solder it.

Step 3: Software

The transmitter software uses common techniques to put the chip into sleep mode. In that mode it draws less than 0.2ua of current. The switch inputs (D1-D4) have the internal pull-up resistors turned on but they don’t draw any current until a switch is pressed. The inputs are configured for interrupt-on-change (IOC). When a switch is pressed, an interrupt is generated and it forces the chip to wake up. The interrupt handler performs about 48msec of delay to allow the switch to debounce. A check is then made to determine which switch was pressed and the appropriate routine is called. The transmitted message is repeated several times (I chose 5 times). This is typical of commercial transmitters because there is so much RF traffic on 433-MHz and 315-MHz out there. The repeated messages help to ensure that at least one gets through to the receiver.

The sync and bit times are defined at the front of the transmitter software but the data bytes are embedded in each of the four button routines. They are obvious and easy to change and adding bytes to make a longer message is also easy. All of the same defines are included in the receiver software as well as the data byte definitions. If you add data bytes to your message, you will need to change the define for “Msg_Length” and add bytes to the variable “RF_Message”. You will also need to add code to the “RF_Message” check in “loop” to verify the proper receipt of the extra bytes and define those bytes.

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    3 Discussions

    0
    None
    tytower

    26 days ago

    Thats pretty good stuff . Need one for night LED's switch on and off on movement. Can you show me the reverse of the constructed board please. I like the way you have constructed that.

    2 replies
    0
    None
    Boomer48tytower

    Reply 19 days ago

    Sorry for the late response. I never saw a notification that I had a comment. Nothing special for the wiring. Hope the pictures help. After soldering I added some clear glue (like GOOP brand) to the RF transmitter module and to the front switches board to make them sturdy.

    20190927_154310.jpg20190927_154329.jpg