Category Archives: Wireless

Upgrade complete

So it turns out getting the nRF24L01 code that I copied into my last post was pretty good, just minor amendments to the code to get it passing the full character array containing all the race information.

A couple of hours spent amending the circuits and the code and the project is now running very happily using the nRF24L01 transceivers. Very happy with that, the range is impressive and I haven’t even tweaked the power or bandwidth settings yet!

Upgrading to 2.4Ghz

One part of the project that’s bothered me is the use of the 433Mhz equipment I originally bought for it. Don’t get me wrong, it’s pretty good – with 12V to the transmitter module, you can achieve respectable range – however, to do that you need a boost convertor to get the 12V from your 5V power supply, plus you’ll also need tuned lengths of cable for the transmitter and receiver. It’s all a bit……….tedious.

So after watching some videos on Arduino communications on Julian Ilett’s excellent Youtube channel, I decided I’d see how I got on with the Nordic Semiconductor’s nRF24L01 communications equipment. I’ve used the information in this excellent guide at the Arduino-Info site (link to be added).

Anyway, borrowing from a couple of sources (the code in the guide as well as the example code in the TMRh20 library mentioned in the guide), I hacked together this working code to test communications between a transmitter and receiver. FYI, I’m using the high-power tranceivers (with PA+LNA) at both TX & RX complete with the base modules mentioned in the guide.

Transmitter:

#include <SPI.h> // Comes with Arduino IDE
#include <RF24.h> // Download and Install (See above)
#include <nRF24L01.h>

RF24 myRadio (7, 8);

byte addresses[6] = {“1Node”};
int tx_data;
int hilo[1];

void setup(){
hilo[0] = 0;
myRadio.begin();
myRadio.setChannel(108);
myRadio.openWritingPipe(addresses[0]);
delay(50);
}

void loop(){
if (hilo[0] == 0){
myRadio.write(&hilo, sizeof(hilo));
hilo[0] = 1;
}
else {
myRadio.write(&hilo, sizeof(hilo));
hilo[0] = 0;
}
delay(1000);
}

The TX code just continually switches the state of the variable ‘hilo’ between 0 and 1 and back with a 1 second delay between transmissions. Any other nRF24L01 receiver using the same RF24 library, channel and ‘pipe’ address will pick this data up.

My receiver code:

#include <SPI.h> // Comes with Arduino IDE
#include <RF24.h> // Download and Install (See above)
#include <nRF24L01.h>

RF24 myRadio (7, 8);

byte addresses[6] = {“1Node”};
int rx_data;
int hilo[1];

void setup(){

pinMode(3, OUTPUT);
hilo[0] = 0;
myRadio.begin();
myRadio.setChannel(108);
myRadio.openReadingPipe(1, addresses[0]);
myRadio.startListening();
delay(50);
}

void loop(){
recvlstate();
if (hilo[0] == 0){
digitalWrite(3, LOW);
}
if (hilo[0] == 1){
digitalWrite(3, HIGH);
}
}

void recvlstate(){
if (myRadio.available()) // While there is data ready
{
myRadio.read( &hilo, sizeof(hilo) ); // Get the data payload (You must have defined that already!)
}
}

The receiver code just takes in the transmitted variable and sends an output pin (Arduino pin 3 in this case) high or low depending on the 0 or 1 state of the ‘hilo’ variable. I’ve had this code working between a transmitter & 2 receivers, so the next step is to integrate the use of these devices into the main project.

Making the project wireless

Soon after getting the Start/Gantry lights prototype working, I wondered where I’d be able to place the start lights for best effect. Would I place it so the drivers could see it or where the pitmen could see it in the pitlane? Also would I be able to get a USB cable long enough to put it in the right place? At this point I realised I needed to make the project wireless.

For reasons of cost and simplicity of coding, I chose the MX-FS-03V 433Mhz transmitter & receiver combination. The transmitter allows an input voltage of between 5V and 12V meaning it is possible to extend the range of the system by increasing the input voltage. The other reason I chose the 433Mhz Tx/Rx combo is due to the fact that the VirtualWire library supports it. I realised fairly quickly that there is a lot of experience in the Arduino community about VirtualWire/433Mhz so I figured that I would go for this system so I had advice to draw on if necessary.