Week 12: Networking and Communication

I played around with the nRF24L01 modules, and managed to send a piezo vibration sensor's signal from one unit to another unit.

Setup

I designed two boards using the atmega328 microcontroller. Since I was going to use the RF24 library, I made pins 9 and 10 traced out on my board. Both boards use a 3.3V regulator for the nrF24L01 power requirement.

circuit

The setup consists of a vibration sensor connected to one module that will act as the transmitter. There's a receiver module with another nRF24L01 that receives the vibration data (on/off data) and displays it on the serial port.

How it works

The transmitter module reads the vibration sensor data, and if it crosses the 0 value, sends a radio signal containing an unsigned long value of 1 to the other module using some RF24 library functions. Otherwise, it keeps sending the value 0 to the other module. I modified the GettingStarted.ino code that comes with the library to read the sensor and send the sensor data over to the receiver module.

if (role == role_ping_out)
{
// First, stop listening so we can talk.
radio.stopListening();
// read sensor
sensor = analogRead(A5);
unsigned long val = 0;
if (sensor > 0) val = 1;
else val = 0;
printf("Now sending %lu...",val);
bool ok = radio.write( &val, sizeof(unsigned long) );
if (ok)
printf("ok...");
else
printf("failed.\n\r");
// Now, continue listening
radio.startListening();
.... (other code)
}

Demonstration Video

Here's a video of the two units in action. Click on the link if the video doesn't show.

Link to nRF24L01 communication test video

Back to Index