EMG sensor wireless transmission nRF24l01

I am new to arduino field. I am trying to construct an EMG sensor which transmits signals wirelessly. I am using nRF24l01 module for wireless transmission. Below code which is used for transmitter is not working fast.

//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include “EMGFilters.h”

#if defined(ARDUINO) && ARDUINO >= 100
#include “Arduino.h”
#else
#include “WProgram.h”
#endif

#define TIMING_DEBUG 1
#define SensorInputPin A0

EMGFilters myFilter;
SAMPLE_FREQUENCY sampleRate = SAMPLE_FREQ_500HZ;
NOTCH_FREQUENCY humFreq = NOTCH_FREQ_50HZ;

//create an RF24 object
RF24 radio(9, 8); // CE, CSN

static int Threshold = 1000;
unsigned long timeStamp;
unsigned long timeBudget;

//address through which two modules communicate.
const byte address[6] = “00001”;

void setup()
{ myFilter.init(sampleRate, humFreq, true, true, true);
Serial.begin(9600);
pinMode(SensorInputPin,INPUT);
radio.begin();
timeBudget = 1e6 / sampleRate;

//set the address
radio.openWritingPipe(address);

//Set module as transmitter
radio.stopListening();
}
void loop()
{ timeStamp = micros();

int Value = analogRead(SensorInputPin);

// filter processing
int DataAfterFilter = myFilter.update(Value);

int envlope = sq(DataAfterFilter);
// any value under threshold will be set to zero
envlope = (envlope > Threshold) ? envlope : 0;

timeStamp = micros() - timeStamp;
if (TIMING_DEBUG) {
    radio.write(&envlope, sizeof(envlope)); 
    Serial.println(envlope); }
    
   delayMicroseconds(500);

}

This is the code for receiving side

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

//create an RF24 object
RF24 radio(9, 8); // CE, CSN

//address through which two modules communicate.
const byte address[6] = “00001”;

void setup()
{
while (!Serial);
Serial.begin(9600);

radio.begin();

//set the address
radio.openReadingPipe(0, address);

//Set module as receiver
radio.startListening();
}

void loop()
{
radio.startListening();
//Read the data if available in buffer
if (radio.available())
{
int rx_data = 0 ;
radio.read(&rx_data, sizeof(rx_data)); // read the input pin
Serial.println(rx_data); // debug value
delay(1);
}

}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.