Networking and Communications

Assignments Goals

  • Design and build a wired &/or wireless network connecting at least two processors
Week's Lectures

Remote Door Opener based on 2.4GHz transceivers

Since I plan on using some kind of wireless communication to build a remote controller for my final project I decided for this week assignment, to practice on wireless modules building a simple remote actuator.

Because in our FabLab we have an electronic door controlled by a solenoid and because every time I sit at the desk, someone arrives and ring the bell, I thought to build a transmitter to place on the desk, and a receiver to attach to the solenoid so to open the door remotely every time the button is pushed.

After a bit of research, I found this small and easy to use wireless module, based on Nordic nRF24L01 Transceiver. It uses the 2.4GHz band, so it's safe to use without any frequency license (it falls in the ISM Band), and uses the SPI bus to communicate with a microcontroller.


Designing the GF_RemoteDoorOpener

As mentioned before, the RF module uses the SPI Bus as interface toward the microcontroller, and a couple of additional control signals. Since the SPI bus protocol is really simple to implement in software, I decided to use the well-known ATTiny44/ATTiny24 microcontroller because it's small and low-cost, ideal for a project like this.

The circuit schematic is very simple and self-explainatory: a connector for the battery holder, a connector for the button (that in this case is used as a circuit breaker), the microcontroller, a couple of leds (including the lamp inside the buttons itself) and the RF module.

There's no need for an external crystal, because the microcontroller speed is not a concern for this kind of application.

The circuit schematic for the receiver is almost identical, but lacks the button connector and has a couple of connectors for the actuators, for example the solenoid that opens the door electromechanically.

Work files links

Full Eagle Cad schematic and board layout of the GF_RemoteDoorOpener
GF_RemoteDoorOpener.zip

Developing the firmware

The nRF24L01 is a complete transceiver solution, and its datasheet even if it is really well written and comprehensive, is quite difficult and complex. So I started to look on the web for a library to use the module. There are a lot of C++ Arduino libraries for it, but very few bare C AVR library for it. Finally I found THIS simple library.

As the author states, the library is simple, and doesn't contain all the features provided by the transceiver, but you can send and receive custom radio packets reliably with it, with autoretransmission too. So I decided to give it a try. Unfortunately after a lot of tinkering and trying, I couldn't manage to get the two modules work reliably: only the first packet upon powering up was correctly received. I tried to debug the library even with an oscilloscope to find the cause of errors (SPI bus is not so simple to debug without the proper tools), but with no luck...


Finally I decided to stop wasting time on that library and thought it could be a nice exercise, to try and use/port a C++ Arduino library in my project. My choice ended up on THIS library. I choose this one because it seemed simple and well structured, and because the SPI driver source code has a generic interface, so that you can add your implementation of it without much effort.

To keep the code well organized, I created an Atmel Studio Solution, with two separate projects: one for the TX and one for the RX. Both have their separate config.h files (according to the physical pin connections) but share the same Mirf library.

Since I want to keep the project more general purpose as possible, and less hardware dependent, I decided to implement the SPI bus communication protocol as a software layer, so that the RF module can be used with every available pin on the microcontroller, and not just the ones of the hardware SPI port.

To add shared files in both projects you have to add them as link, as shown in the image below.

After a bit of reverse engineering of the Arduino library and a quick and easy port, to use it in a generic AVR project With I had almost no problems making the two modules talk to each other as I wanted.

The code I used to implement the door opener for the transmitter, is the following:


                        
                        

The code I used to implement the door opener for the receiver, is the following:


                        
                    

Work files links

Firmware for GF_RemoteDoorOpener, with Atmel Studio Solution and TX / RX projects
Firmware.zip

Enclosure 3D Printing

As an additional work I wanted to create a custom enclosure to hold everything in place, so I bought this huge button and a battery holder, and started to design a can-like enclosure in SketchUp!

After almost 7 hours of print (I wanted to try a new filament, with high precision settings...), the result was really good! Everything fitted perfectly, and the overall effect is nice.

Work files links

3D model of the enclosure for the GF_RemoteDoorOpener Transmitter in SketchUp format
Pulsantone.zip

Assignments Outcomes

  • Demonstrate workflows used in network design and construction
  • Implement and interpret networking protocols

Have you:

described your design and fabrication process using words/images/screenshots
explained the programming process/es you used
outlined problems and how you fixed them
included original design files and code