in a previous post I briefly showed how to read the sum signal of a receiver that is able to output the signal. Although the code works quite well there are several issues with the code:

  1. calling pulseIn(SignalPin, HIGH) blocks until the corresponding pin is set to HIGH, which is a major waste of time, because no other calculations can be performed in the meantime

  2. I noticed that every now and then the readings start to glitch causing unwanted noise

To cope with the first issue I used  Arduino’s external interrupt feature that calls a callback function for every rising edge. In addition I wrapped it in a class and defined it as a library for easy usage.

[update: 2013-07-28][update: 2013-08-02]

However, the glitches persisted. Figuring out this issues caused a lot of headaches. To come straight to the point, the signal voltage level is not 5V but 3.3V! This caused the signal detection to occasionally misinterpret a 3V signal as LOW.

In the end the solution is rather simple. I used a p-channel MOSFET I had in my spare-part box and used it as a switch to drive 5V with the signal as input at the gate pin. This way the MOSFET acts as an inverter for the incoming signal while translating it to the 5V level. As I currently lack the time to draw a nice circuit please have a look at the following image I found via image search: circuit

I will probably switch to a RX/TX or bi-directional level converter that I have left over. They are smaller in size and I do not need the capability of switching 10A that the MOSFET currently supports.

I removed the MOSFET and used a level converter designed by Adafruit and distributed by Watterott. (alternative)

I haven’t published the code to one of my repositories, since I need to review and clean it up a bit. I promise I will do that in the near future though :-)

You can find the definition of the Receiver class in my repository