nRF24l01, RC reciever, robot dog issue

I'm having an issue with error detection in a project.

There are two Arduino megas, one in a robot and one in a relay box powered externally.

Robot code:

#include <Wire.h>

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

const int pinCE = 48;
const int pinCSN = 49;
int gotArray[32];

RF24 wirelessSPI(pinCE, pinCSN);
byte pAddress[][6] = {"2Node", "1Node"};

/*

  OPEN-SOURCE ROBOT DOG CODE
  Used for robot dogs and other quadrupedal robots using hobby servos


  OpenSpot v1.0

  Created by Liam Timpane


*/





// =====================================
// ==========  CONFIGURATION  ==========
// =====================================

// ------------ UNIT MM



double upperLength = 108.13; // Length from the center of the shoulder motor's axis to the center of the knee motor's axis

double lowerLength = 116.50; // Length from the center of the knee motor's axis to the tip of the foot

double bodyLength = 244.50; // Distance between the centers of two shoulder joint axes

double bodyWidth = 78.12; // Distance between the centers of two hip joint axes

double footOffset = 57.25; // Distance from center of the foot to center of the hip joint



// ------------ Pin numbers for servos

int FLH = 3; // Front-Left hip, shoulder, knee
int FLS = 7;
int FLK = 9;

int FRH = 2; // Front-Right hip, shoulder, knee
int FRS = 6;
int FRK = 10;

int BLH = 1; // Back-Left hip, shoulder, knee
int BLS = 5;
int BLK = 11;

int BRH = 0; // Back-Right hip, shoulder, knee
int BRS = 4;
int BRK = 8;


// ----------- SERVO OFFSETS

// -----     K / S / H    =    Knee / Shoulder / Hip

double K1O = 0;
double S1O = 15;
double H1O = 10;

double K2O = 5;
double S2O = 15;
double H2O = 15;

double K3O = 15;
double S3O = 5;
double H3O = 20;

double K4O = -5;
double S4O = 15;
double H4O = 10;


// ---------- SERVO SETUP



// Override the default minimum and maximum pulse values with ones set below, HIGHLY RECOMMENDED!

#define OVERRIDE_MINIMUM_PULSE
#define OVERRIDE_MAXIMUM_PULSE

// Tune these values for maximum and minimum servo pulse widths.

int CUSTOM_MINIMUM_PULSE = 90;
int CUSTOM_MAXIMUM_PULSE = 470;


double SERVO_FREQ = 50;   // Servo operating frequency, in hertz. Unless your servos specify otherwise, use 50.

// =====================================
// ==========  END OF CONFIG  ==========
// =====================================





// Variable definitions
double cycletime = (1 / SERVO_FREQ) * 1000000; // Length of a full cycle, in microseconds. If frequency is 50, this will be 20000.

double ticktime = cycletime / 4096; // Length of an individual tick. If frequency is 50, this will be 4.883.

double microsecondsToTicks(int microseconds) {
  return microseconds / ticktime;
}

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40);


int SERVOMIN = CUSTOM_MINIMUM_PULSE;

int SERVOMAX = CUSTOM_MAXIMUM_PULSE;


void writeServo(int servoNum, float degree) {

  pwm.setPWM(servoNum, 0, map(degree, 0, 180, SERVOMIN, SERVOMAX));
}

double vt1;
double vt2;
double vt3;
double vt4;

double degreesToTicks(int deg) {
  while (deg < 0) {
    deg += 180;
  }
  while (deg > 180) {
    deg -= 180;
  }
  return map(deg, 0, 180, SERVOMIN, SERVOMAX);
}

double pi = 3.1415926;

double vl1 = 145;
double vl2 = 145;
double vl3 = 145;
double vl4 = 145;

double height;

double sd1;
double hd1;
double kd1;
double px1 = 0;
double py1 = 80;
double pz1;

double sd2;
double hd2;
double kd2;
double px2 = 0;
double py2 = 80;
double pz2;

double sd3;
double hd3;
double kd3;
double px3 = 0;
double py3 = 80;
double pz3;

double sd4;
double hd4;
double kd4;
double px4 = 0;
double py4 = 80;
double pz4;




double rad2deg(double rad) {
  return (rad * 180) / pi;
}

double deg2rad(double deg) {
  return (deg * pi) / 180;
}
bool cncted = false;
int t;
void setup() {
  Serial.begin(9600);
  pwm.begin();
  Serial.println("Cycle time: " + String(cycletime) + "uS");
  Serial.println("Tick time: " + String(ticktime) + "uS");
  Serial.println("Servo minimum: " + String(SERVOMIN) + " ticks");
  Serial.println("Servo maximum: " + String(SERVOMAX) + " ticks");

  pwm.setPWMFreq(SERVO_FREQ);  // Analog servos run at ~50 Hz updates
  tone(23, 125, 10);
  delay(100);
  tone(23, 125, 10);
  delay(100);
  tone(23, 125, 10);
  delay(100);
  tone(23, 125, 10);
  delay(100);
  tone(23, 125, 10);
  delay(100);
  tone(23, 125, 10);
  delay(100);
  tone(23, 125, 10);
  delay(100);
  tone(23, 125, 10);
  delay(100);
  tone(23, 125, 10);
  delay(100);
  tone(23, 125, 10);
  delay(100);
  tone(23, 125, 10);
  delay(100);
  delay(10);
  delay(1000);
  pinMode(2, OUTPUT);

  pwm.setPWM(FLK, 0, degreesToTicks(90 + K1O));
  pwm.setPWM(FLS, 0, degreesToTicks(90 + S1O));
  pwm.setPWM(FLH, 0, degreesToTicks(90 + H1O));
  pwm.setPWM(FRK, 0, degreesToTicks(90 + K2O));
  pwm.setPWM(FRS, 0, degreesToTicks(90 + S2O));
  pwm.setPWM(FRH, 0, degreesToTicks(90 + H2O));
  pwm.setPWM(BLK, 0, degreesToTicks(90 + K3O));
  pwm.setPWM(BLS, 0, degreesToTicks(90 + S3O));
  pwm.setPWM(BLH, 0, degreesToTicks(90 + H3O));
  pwm.setPWM(BRK, 0, degreesToTicks(90 + K4O));
  pwm.setPWM(BRS, 0, degreesToTicks(90 + S4O));
  pwm.setPWM(BRH, 0, degreesToTicks(90 + H4O));
  digitalWrite(2, LOW);
  tone(23, 125, 250);
  delay(250);
  tone(23, 250, 250);
  delay(250);
  tone(23, 335, 250);
  delay(250);
  tone(23, 375, 250);
  delay(2000);
  Serial.begin(9600);

  wirelessSPI.begin();
  printf_begin();
  wirelessSPI.setAutoAck(1);
  wirelessSPI.enableAckPayload();
  wirelessSPI.setRetries(5, 15);
  wirelessSPI.openReadingPipe(1, pAddress[0]);
  wirelessSPI.openWritingPipe(pAddress[1]);
  wirelessSPI.startListening();
  wirelessSPI.printDetails();

  while (!wirelessSPI.available()) {
    tone(23, 500, 100);
    delay(100);
    tone(23, 360, 400);
    delay(900);
  }
  cncted = true;
  tone(23, 250, 50);
  delay(50);
  tone(23, 500, 50);
  delay(50);
  tone(23, 750, 50);
  delay(50);
  tone(23, 1000, 50);
  delay(50);
  t = millis();
}

// KINEMATIC STUFF

void leg2pos(int leg, float x, float y, float z) {


  if (leg == 1) {
    vl1 = sqrt((y * y) + (x * x)) - sqrt((footOffset * footOffset) + (y * y)) + sqrt(((z + footOffset) * (z + footOffset)) + (y * y));
    kd1 = rad2deg(-acos(((vl1 * vl1) + (upperLength * upperLength) - (lowerLength * lowerLength)) / (2 * vl1 * upperLength))) + 45 - rad2deg(atan(x / y));
    sd1 = rad2deg(-acos(((upperLength * upperLength) + (lowerLength * lowerLength) - (vl1 * vl1)) / (2 * lowerLength * upperLength))) + 90;
    hd1 = rad2deg(asin((z + footOffset) / (sqrt(((z + footOffset) * (z + footOffset)) + (y * y)))) - (pi / 2 - atan(vl1 / footOffset)));
    pwm.setPWM(FLK, 0, degreesToTicks(90 - sd1 + K1O));
    pwm.setPWM(FLS, 0, degreesToTicks(90 - kd1 + S1O));
    pwm.setPWM(FLH, 0, degreesToTicks(90 - hd1 + H1O));
  } else if (leg == 2) {
    vl2 = sqrt((y * y) + (x * x)) - sqrt((-footOffset * -footOffset) + (y * y)) + sqrt(((z + -footOffset) * (z + -footOffset)) + (y * y));
    kd2 = rad2deg(-acos(((vl2 * vl2) + (upperLength * upperLength) - (lowerLength * lowerLength)) / (2 * vl2 * upperLength))) + 45 - rad2deg(atan(x / y));
    sd2 = rad2deg(-acos(((upperLength * upperLength) + (lowerLength * lowerLength) - (vl2 * vl2)) / (2 * lowerLength * upperLength))) + 90;
    hd2 = pi + rad2deg(asin((z + -footOffset) / (sqrt(((z + -footOffset) * (z + -footOffset)) + (y * y)))) - (pi / 2 - atan(vl2 / -footOffset)));
    pwm.setPWM(FRK, 0, degreesToTicks(90 + sd2 + K2O));
    pwm.setPWM(FRS, 0, degreesToTicks(90 + kd2 + S2O));
    pwm.setPWM(FRH, 0, degreesToTicks(90 - hd2 + H2O));
  } else if (leg == 3) {
    vl3 = sqrt((y * y) + (x * x)) - sqrt((footOffset * footOffset) + (y * y)) + sqrt(((z + footOffset) * (z + footOffset)) + (y * y));
    kd3 = rad2deg(-acos(((vl3 * vl3) + (upperLength * upperLength) - (lowerLength * lowerLength)) / (2 * vl3 * upperLength))) + 45 - rad2deg(atan(x / y));
    sd3 = rad2deg(-acos(((upperLength * upperLength) + (lowerLength * lowerLength) - (vl3 * vl3)) / (2 * lowerLength * upperLength))) + 90;
    hd3 = rad2deg(asin((z + footOffset) / (sqrt(((z + footOffset) * (z + footOffset)) + (y * y)))) - (pi / 2 - atan(vl3 / footOffset)));
    pwm.setPWM(BLK, 0, degreesToTicks(90 - sd3 + K3O));
    pwm.setPWM(BLS, 0, degreesToTicks(90 - kd3 + S3O));
    pwm.setPWM(BLH, 0, degreesToTicks(90 - hd3 + H3O));
  } else if (leg == 4) {
    vl4 = sqrt((y * y) + (x * x)) - sqrt((-footOffset * -footOffset) + (y * y)) + sqrt(((z + -footOffset) * (z + -footOffset)) + (y * y));
    kd4 = rad2deg(-acos(((vl4 * vl4) + (upperLength * upperLength) - (lowerLength * lowerLength)) / (2 * vl4 * upperLength))) + 45 - rad2deg(atan(x / y));
    sd4 = rad2deg(-acos(((upperLength * upperLength) + (lowerLength * lowerLength) - (vl4 * vl4)) / (2 * lowerLength * upperLength))) + 90;
    hd4 = pi + rad2deg(asin((z + -footOffset) / (sqrt(((z + -footOffset) * (z + -footOffset)) + (y * y)))) - (pi / 2 - atan(vl4 / -footOffset)));
    pwm.setPWM(BRK, 0, degreesToTicks(90 + sd4 + K4O));
    pwm.setPWM(BRS, 0, degreesToTicks(90 + kd4 + S4O));
    pwm.setPWM(BRH, 0, degreesToTicks(90 - hd4 + H4O));
  }
}

double fpx;
double fpy;
double fpz;
double frr;
double frp;
double fry;
double refangle;
double yawRadius;
double vbw;

void body2pos(float x, float y, float z, float roll, float pitch, float yaw) {
  vbw = bodyWidth + footOffset + footOffset;
  yawRadius = sqrt((((bodyWidth + footOffset + footOffset) / 2) * ((bodyWidth + footOffset + footOffset) / 2)) + ((bodyLength / 2) * (bodyLength / 2)));
  refangle = atan(((bodyWidth + footOffset + footOffset) / 2) / (bodyLength / 2));
  leg2pos(1, x - (vbw / 2)*cos(deg2rad(pitch)) + (vbw / 2) + yawRadius * (sin(0 - refangle)) - yawRadius * (sin(deg2rad(yaw) - refangle)), y + (vbw / 2)*sin(deg2rad(pitch)) + (vbw / 2)*sin(deg2rad(roll)), z + (vbw / 2)*cos(deg2rad(roll)) - (vbw / 2) + yawRadius * (cos(0 - refangle)) - yawRadius * (cos(deg2rad(yaw) - refangle)));
  leg2pos(2, x - (vbw / 2)*cos(deg2rad(pitch)) + (vbw / 2) - yawRadius * (sin(0 + refangle)) + yawRadius * (sin(deg2rad(yaw) + refangle)), y + (vbw / 2)*sin(deg2rad(pitch)) - (vbw / 2)*sin(deg2rad(roll)), z - (vbw / 2)*cos(deg2rad(roll)) + (vbw / 2) - yawRadius * (cos(0 + refangle)) + yawRadius * (cos(deg2rad(yaw) + refangle)));
  leg2pos(3, x + (vbw / 2)*cos(deg2rad(pitch)) - (vbw / 2) + yawRadius * (sin(0 + refangle)) - yawRadius * (sin(deg2rad(yaw) + refangle)), y - (vbw / 2)*sin(deg2rad(pitch)) + (vbw / 2)*sin(deg2rad(roll)), z + (vbw / 2)*cos(deg2rad(roll)) - (vbw / 2) + yawRadius * (cos(0 + refangle)) - yawRadius * (cos(deg2rad(yaw) + refangle)));
  leg2pos(4, x + (vbw / 2)*cos(deg2rad(pitch)) - (vbw / 2) - yawRadius * (sin(0 - refangle)) + yawRadius * (sin(deg2rad(yaw) - refangle)), y - (vbw / 2)*sin(deg2rad(pitch)) - (vbw / 2)*sin(deg2rad(roll)), z - (vbw / 2)*cos(deg2rad(roll)) + (vbw / 2) - yawRadius * (cos(0 - refangle)) + yawRadius * (cos(deg2rad(yaw) - refangle)));

  /*
    leg2pos(1,x + yawRadius*(sin(0 - refangle)) - yawRadius*(sin(deg2rad(yaw) - refangle)),y, z + yawRadius*(cos(0 - refangle)) - yawRadius*(cos(deg2rad(yaw) - refangle)));
    leg2pos(2,x - yawRadius*(sin(0 + refangle)) + yawRadius*(sin(deg2rad(yaw) + refangle)),y, z - yawRadius*(cos(0 + refangle)) + yawRadius*(cos(deg2rad(yaw) + refangle)));
    leg2pos(3,x + yawRadius*(sin(0 + refangle)) - yawRadius*(sin(deg2rad(yaw) + refangle)),y, z + yawRadius*(cos(0 + refangle)) - yawRadius*(cos(deg2rad(yaw) + refangle)));
    leg2pos(4,x - yawRadius*(sin(0 - refangle)) + yawRadius*(sin(deg2rad(yaw) - refangle)),y, z - yawRadius*(cos(0 - refangle)) + yawRadius*(cos(deg2rad(yaw) - refangle)));
  */
}

double filterRatio = 0.95;
double px;
double py;
double pz;


void bodyKine(double x, double y, double z, double roll, double pitch, double yaw) {
  fpx = (fpx * filterRatio) + (x * (1 - filterRatio));
  fpy = (fpy * filterRatio) + (y * (1 - filterRatio));
  fpz = (fpz * filterRatio) + (z * (1 - filterRatio));
  frr = (frr * filterRatio) + (roll * (1 - filterRatio));
  frp = (frp * filterRatio) + (pitch * (1 - filterRatio));
  fry = (fry * filterRatio) + (yaw * (1 - filterRatio));
  body2pos(fpx, fpy, fpz, frr, frp, fry);
}

double posx;
double posy;
double posz;

double roll;
double pitch;
double yaw;

double xIn = 0;
double yIn = 160;
double zIn = 0;

double rIn = 0;
double pIn = 0;
double yawIn = 0;

int val;
int code;



int prev_t;


void loop() {
  if (cncted == false) {
    tone(23, 500, 100);
    delay(100);
    tone(23, 360, 100);
    delay(250);
     pwm.setPWM(FLK, 0, degreesToTicks(90 + K1O));
  pwm.setPWM(FLS, 0, degreesToTicks(90 + S1O));
  pwm.setPWM(FLH, 0, degreesToTicks(90 + H1O));
  pwm.setPWM(FRK, 0, degreesToTicks(90 + K2O));
  pwm.setPWM(FRS, 0, degreesToTicks(90 + S2O));
  pwm.setPWM(FRH, 0, degreesToTicks(90 + H2O));
  pwm.setPWM(BLK, 0, degreesToTicks(90 + K3O));
  pwm.setPWM(BLS, 0, degreesToTicks(90 + S3O));
  pwm.setPWM(BLH, 0, degreesToTicks(90 + H3O));
  pwm.setPWM(BRK, 0, degreesToTicks(90 + K4O));
  pwm.setPWM(BRS, 0, degreesToTicks(90 + S4O));
  pwm.setPWM(BRH, 0, degreesToTicks(90 + H4O));
    t = millis();
  }
  if (cncted == true and millis() - t >= 5000) {
    cncted = false;
    Serial.println("Relay disconnected");
    tone(23, 1000, 50);
    delay(50);
    tone(23, 750, 50);
    delay(50);
    tone(23, 500, 50);
    delay(50);
    tone(23, 250, 50);
    delay(250);
    t = millis();
  }
  while (wirelessSPI.available()) {
    Serial.println(String(gotArray[0]) + ", " + String(gotArray[1]) + ", " + String(gotArray[2]) + ", " + String(gotArray[3]) + ", " + String(gotArray[4]) + ", " + String(gotArray[5]));
    wirelessSPI.read( &gotArray, sizeof(gotArray) );
    t = millis();
    if (cncted == false) {
      Serial.println("Relay connected");
      tone(23, 250, 50);
      delay(50);
      tone(23, 500, 50);
      delay(50);
      tone(23, 750, 50);
      delay(50);
      tone(23, 1000, 50);
      
    }
    cncted = true;
    
    
    if (String(gotArray[0]) = "-145") {
      Serial.println("RC transmitter not connected!");
      pwm.setPWM(FLK, 0, degreesToTicks(90 + K1O));
      t = millis();
    } else {


      yawIn = constrain(map(gotArray[2].toInt(), 0, 255, -40, 40), -40, 40);

      yIn = constrain(map(gotArray[3].toInt(), 0, 255, 40, 220), 40, 220);

      xIn = constrain(map(gotArray[1].toInt(), 0, 255, -40, 40), -40, 40);

      zIn = constrain(map(gotArray[0].toInt(), 0, 255, -80, 80), -80, 80);
    }





    t = millis();

  }

  bodyKine(xIn, yIn, zIn, rIn, pIn, yawIn);

}

Relay code:

#include <SPI.h> 
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
const int pinCE = 7; 
const int pinCSN = 8; 
int Array[32];
int counter = 0;
uint16_t md1;
uint16_t md2;
uint8_t mode = 1;
RF24 wirelessSPI(pinCE, pinCSN); 
byte pAddress[][6] = {"1Node", "2Node"};       
int flag = 0;
void setup()  
{
  pinMode(2,INPUT);
  pinMode(3,INPUT);
  pinMode(4,INPUT);
  pinMode(5,INPUT);
  pinMode(6,INPUT);
  pinMode(9,INPUT);
 Serial.begin(9600);
 printf_begin();       
 wirelessSPI.begin();          
 wirelessSPI.setAutoAck(1);                
 wirelessSPI.enableAckPayload();
 wirelessSPI.setPALevel(RF24_PA_LOW);         
 wirelessSPI.setRetries(5,15);            
 wirelessSPI.openWritingPipe(pAddress[1]);   
 wirelessSPI.stopListening();
 wirelessSPI.printDetails();  
}

void loop()  
{
   Array[0] = map(pulseIn(9,HIGH),800,2200,0,255);
   Array[1] = map(pulseIn(6,HIGH),800,2200,0,255);
   Array[2] = map(pulseIn(5,HIGH),800,2200,0,255);
   Array[3] = map(pulseIn(4,HIGH),800,2200,0,255);
   Array[4] = map(pulseIn(3,HIGH),800,2200,0,255);
   Array[5] = map(pulseIn(2,HIGH),800,2200,0,255);
   
   Serial.println("Now sending data... "); 
   
   if (!wirelessSPI.write( &Array, sizeof(Array))){ 
      Serial.println("Error 0x04 - Error sending data"); 
      Serial.println();     
  }
  else { 
      Serial.println("Send successful.");
      Serial.println();
  }
}

The robot begins as normal on startup, although it seems to only be getting about half of the data I want it to. Still, this isnt a big issue, as I have a smoother in the code to eliminate any sort of jitter.

Serial monitor output from first minute or so:

16, 33, 125, 35, 124, 110
RC transmitter not connected!
15, 35, 124, 35, 126, 110
RC transmitter not connected!
15, 35, 124, 35, 126, 111
RC transmitter not connected!
15, 35, 125, 35, 124, 111
RC transmitter not connected!
18, 33, 125, 35, 126, 111
RC transmitter not connected!
15, 33, 125, 35, 125, 110
RC transmitter not connected!
16, 33, 124, 35, 126, 111

Then the robot starts repeatedly making connect/disconnect noises.

Serial monitor during this period:

Relay connected
RC transmitter not connected!
15, 35, 124, 35, 126, 110
RC transmitter not connected!
15, 35, 124, 35, 126, 111
RC transmitter not connected!
15, 33, 126, 35, 124, 110
RC transmitter not connected!
16, 33, 125, 35, 124, 111
RC transmitter not connected!
16, 33, 126, 35, 124, 111
RC transmitter not connected!
Relay disconnected
16, 35, 126, 35, 125, 110
Relay connected
RC transmitter not connected!
16, 33, 126, 35, 124, 111
RC transmitter not connected!
15, 35, 126, 35, 124, 110
RC transmitter not connected!
16, 35, 124, 35, 126, 110
RC transmitter not connected!
16, 33, 124, 35, 126, 110
RC transmitter not connected!
16, 33, 124, 35, 126, 110
RC transmitter not connected!
16, 33, 126, 35, 126, 110
RC transmitter not connected!
Relay disconnected
16, 35, 124, 35, 126, 111
Relay connected
RC transmitter not connected!
16, 35, 124, 35, 126, 111
RC transmitter not connected!
16, 33, 124, 35, 126, 111
RC transmitter not connected!
16, 33, 124, 35, 126, 111
RC transmitter not connected!
16, 33, 124, 35, 126, 111
RC transmitter not connected!
16, 33, 124, 35, 126, 110
RC transmitter not connected!
16, 33, 124, 35, 126, 110
RC transmitter not connected!
Relay disconnected
16, 33, 124, 35, 126, 110
Relay connected
RC transmitter not connected!
16, 33, 126, 35, 125, 110
RC transmitter not connected!
17, 33, 125, 35, 124, 110
RC transmitter not connected!
16, 33, 124, 35, 126, 111
RC transmitter not connected!
17, 33, 124, 35, 126, 111
RC transmitter not connected!
17, 33, 124, 36, 126, 111
RC transmitter not connected!
16, 33, 124, 35, 126, 111
RC transmitter not connected!
Relay disconnected
16, 33, 124, 35, 126, 110
Relay connected
RC transmitter not connected!
15, 33, 125, 35, 125, 111
RC transmitter not connected!
16, 33, 126, 35, 125, 111
RC transmitter not connected!
18, 33, 126, 35, 126, 111
RC transmitter not connected!
18, 33, 124, 35, 126, 111
RC transmitter not connected!
18, 33, 124, 35, 126, 111
RC transmitter not connected!
16, 33, 124, 35, 126, 111
RC transmitter not connected!
Relay disconnected
16, 33, 124, 36, 126, 111
Relay connected
RC transmitter not connected!
18, 35, 124, 35, 126, 111
RC transmitter not connected!

This is very frustrating as I can't figure out what's wrong with it.

Yes, I'm aware there are several variables that aren't used. This is a work in progress and some variables are for later use, others are no longer needed.

Did you mean if (String(gotArray[0]) == "-145") {

1 Like

The maximum size of a rf24 payload is 32 bytes.

I will only ever be reading the first six entries though, and the numbers returned in the Serial Monitor are correct.

Changed this and nothing changed in the main problem, although it did resolve a separate problem i was having as well

If only the first six elements of "Array" actually contain data, why transmit all of 32 of them?

Because I may use them later. Also, using the dynamic payloads feature caused some issues with the modules communicating. It isn't affecting anything performance-wise, so why change it?

Huh? You are posting because your program doesn't work as expected.

The arduino is receiving the values just fine, so why change something that could affect it? Problem is not with recieved values
Fixing the = / == error above fixed one of the issues

Serial monitors now:

Before error:

15, 33, 124, 35, 126, 99
15, 35, 124, 35, 126, 99
15, 35, 125, 35, 126, 99
15, 33, 125, 35, 125, 98
16, 33, 124, 35, 126, 99
16, 33, 124, 35, 126, 99
16, 33, 124, 35, 126, 99
15, 33, 125, 35, 125, 99
15, 33, 125, 35, 125, 99
15, 33, 124, 35, 126, 99
17, 35, 124, 35, 126, 99
16, 33, 124, 35, 126, 99
16, 33, 124, 36, 126, 99

After error:

16, 33, 124, 35, 126, 99
16, 35, 124, 35, 126, 99
Relay disconnected
17, 33, 124, 35, 126, 99
Relay connected
15, 33, 125, 35, 125, 99
15, 33, 125, 35, 125, 99
15, 33, 125, 35, 125, 99
15, 33, 125, 35, 126, 99
Relay disconnected
16, 33, 124, 35, 126, 99
Relay connected
15, 33, 125, 35, 125, 98
15, 33, 124, 35, 126, 99
16, 33, 124, 35, 126, 99
16, 33, 124, 35, 126, 99
Relay disconnected
16, 33, 124, 35, 126, 98
Relay connected

Update: figured it out. The variable t was an int. Changed it to unsigned long and that fixed the issue.

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