nRF24L01+ & Teensy 3.6 Issues

Status
Not open for further replies.

theDVSguy

Active member
Hello,
I am really at my last bit of energy on all these nRF24L01 boards. Tried everything posted on every forum around. I have been unsuccessful running the ones with Antennas with a Teensy 3.6 so I decided to give the non-whip antennas a try. I am trying to communicate with a getting started sketch supplied. I am including my current wiring diagram also. Library https://tmrh20.github.io/RF24/

1. I have added a cap 100uf
2. Purchased a breakout board so I can hook 5.5v to en sure its getting what it needs.
3. Changed style of transmitters. Whip vs not. I am not looking for a ton of range.

I run the "nrf24_Connection_Start_teensy.ino" Sketch and show a connection. Then I run the "GettingStarted_Teensy.ino" to try to get 2 talking and thats where I die.
For some reason the sketch wont produce output to the Serial monitor until I pull the MISO wire out or touch it. It seems like its wired correctly unless I am missing something. I have only worked with MEGAs and UNOs in the past so Teensy is new to me.
If anyone can please help. I am so stuck, its driving me nuts ;)

Appreciate any feedback.
 

Attachments

  • nf24_Connection_Start_Teensy.ino
    2.3 KB · Views: 94
  • GettingStarted_Teensey.ino
    4.9 KB · Views: 57
  • Master.pdf
    817.1 KB · Views: 95
Hi,
If you are running into problems using the nRF24 modules in your "master" setup, it's best to focus on these modules alone and remove all the other electronics temporarily to make sure your problems are not caused by unwanted interaction and/or software.
You could follow this tutorial and see if you get it up and running first. If this works, then you can add other parts [and related software] step-by-step.

PS: I hope you swapped the + & - outputs of the LM2596 modules in your setup...

Success,
Paul
 
Mind you, there are quite a lot of fake nRF24L01 modules out there which may cause problems.
More info here.

Paul
 
I agree alot of fakes...and I have bought a few of them so far. Looks like others have had the same issue....its weird..the ones with antenna, will freeze the sketch until I touch the board itself (finger touch) with the ones without the antenna, it wants the MISO pin pulled to run the loop.....
 
The modules with the external antenna do have an additional Power Amplifier & a Low-Noise Amplifier onboard. That definitely means that they use more power. Maybe that is a problem in your setup?
 
Perhaps the NRF24L01+ Breakout Board is causing the issue? I assume it's a level shifter and a 5>3V3 regulator?
What if you delete the breakout board and connect the nRF24 module directly to the Teensy 3.6 and power it from the 3V3 pin of the T36?
 
Do you have your setup layed out on a breadboard? If so, could you move the CE & CSN signal to pin 7 & 8 and change your code accordingly?
Perhaps the regular CS pins of the SPI bus on pins 9 & 10 are causing the issue?
 
Not using a breakout board...its wired directly. Other than the VCC and ground..those are connected to a dedicated power source......
 
I tried moving them around...what would that have to do with the MISO pin ? they seem to work once I unplug that pin
 
NRF24L01P test Script starting...

If you do not see a long message after this line, something is not right!

SPI Speedz = 10 Mhz
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0

RX_ADDR_P0-1 = 0xe7e7e7e7e7 0xe8e8f0f0e1

RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6

TX_ADDR = 0xe7e7e7e7e7

RX_PW_P0-6 = 0x00 0x20 0x00 0x00 0x00 0x00

EN_AA = 0x3f

EN_RXADDR = 0x3e

RF_CH = 0x02

RF_SETUP = 0x21

CONFIG = 0x03

DYNPD/FEATURE = 0x00 0x00

Data Rate = 250KBPS

Model = nRF24L01+

CRC Length = 8 bits

PA Power = PA_MIN
 
What is generating this line in the serial output: "SPI Speedz = 10 Mhz" ?

Anyway, I would really urge you to start even more basic and that is use the example in the tutorial first. So, only Teensy 3.6 and the nRF24 module connected. No other hardware used.
You must get the MISO line working otherwise you won't be able to receive data ever.

Paul
 
Hi , sorry to butt in. My personal experience with the nRF24L01 (both with antenna and without antenna) on an arduino micro-controller though , was terrible. I have added capacitors and even bought the power modules , with no luck. I have wasted so much money on these same modules. It was terrible.

I ended up buying these instead :

https://www.sparkfun.com/products/691

The sparkfun, solved my connectivity issues.

With the other modules, I was having your same issue where I had to touch wires and do whatever crazy on those nRF24L01 to have on/off transmission, but I never solved the issue with them to the point of having a stable continuous transmission.

After I bought the sparkfun, the problem went away, though I can not make proper use of these wireless modules anyway, due to a 1 sec delay in transmission between my 5 modules.

No idea why I have had this delay. I tend to think that the delay was/is due to the the arduino developer being not that competent with these modules and not writing a proper arduino code for them.

I am still looking to find a solution for these sparkfun modules , to remove this delay.

Wondering if u will have the same issue with the delay after you solve the connectivity issue

20201023_173332(1).jpg
 
Last edited:
Hi Marco,
You may have been using fake nRF24 modules that caused the problems you described.
For what's it worth, I have been using these modules from Robotdyn in several projects without any issues. As far as I can tell, they use genuine Nordic chips on their modules.
Recently I built a bidirectional wireless CAN-bus bridge [CAN-nRF24-nRF24-CAN] using Teensy 3.2's and these Robotdyn modules. CAN-bus frames are transmitted within 1 milli-second.

Perhaps you should give Teensy boards a try for your project?

Paul
 
Hi Marco,
You may have been using fake nRF24 modules that caused the problems you described.
For what's it worth, I have been using these modules from Robotdyn in several projects without any issues. As far as I can tell, they use genuine Nordic chips on their modules.
Recently I built a bidirectional wireless CAN-bus bridge [CAN-nRF24-nRF24-CAN] using Teensy 3.2's and these Robotdyn modules. CAN-bus frames are transmitted within 1 milli-second.

Perhaps you should give Teensy boards a try for your project?

Paul

Hi Paaul, thank you for the reply!

I will post a picture of the modules I was using.

Now I am using the sparkfun hooked this way:

Schematic (16).jpg




1) chest

Code:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include "Adafruit_BMP3XX.h"
#include <utility/imumaths.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define BNO055_SAMPLERATE_DELAY_MS (100)

RF24 radio(9, 10);
#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BMP3XX bmp;
Adafruit_BNO055 bno = Adafruit_BNO055(-1, 0x28);

int y3_axis_1 , y3_axis_2;
int y3_thres_1 , y3_thres_2;

const uint64_t pipes[6] = {  0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL, 0xF0F0F0F0E2LL, 0xF0F0F0F0D3LL, 0xF0F0F0F0E3LL, 0xF0F0F0F0D4LL };

int pos;
float altitude;
float altitudeThres;

void setup(void)
{
  Serial.begin(115200);
  radio.begin();
  radio.openWritingPipe(pipes[2]);
  radio.stopListening();

  if (!bno.begin())
  {
    Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
    while (1);
  }

  if (!bmp.begin()) {
    Serial.println("Could not find a valid BMP3 sensor, check wiring!");
    //while (1);
  }
  bmp.setTemperatureOversampling(BMP3_OVERSAMPLING_8X);
  bmp.setPressureOversampling(BMP3_OVERSAMPLING_4X);
  bmp.setIIRFilterCoeff(BMP3_IIR_FILTER_COEFF_3);

  delay(1000);
  int8_t temp = bno.getTemp();
  bno.setExtCrystalUse(true);
  unsigned long timer;
  Serial.println("Calibration...");
  while (millis() - timer < 10000) {
    imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
    y3_thres_1 = euler.y();
    y3_thres_2 = euler.z();
    if (bmp.performReading()) {
      altitudeThres = bmp.readAltitude(SEALEVELPRESSURE_HPA);
    }
    Serial.print(".");
    delay(100);
  }
  Serial.println("\nDone");
  Serial.println(String(y3_thres_1) + " " + String(y3_thres_2) + " " + String(altitudeThres));
  delay(3000);
}

void loop(void)
{
  imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
  y3_axis_1 = euler.y();
  y3_axis_2 = euler.z();
  altitude = bmp.readAltitude(SEALEVELPRESSURE_HPA);

  if (altitude > altitudeThres + 0.35)
    pos = 1;
  else if (altitude < altitudeThres - 0.28)
    pos = 2;
  else
    pos = 0;

  String temp = String(y3_axis_1) + "," + String(y3_axis_2) + "," + String(y3_thres_1) + "," + String(y3_thres_2) + "," + String(pos);
  const char text[40];
  temp.toCharArray(text , temp.length() + 1);
  radio.write(&text, sizeof(text));
  Serial.println(pos);
  delay(100);
}

2) left hand

Code:
/*

  Software Requirements:
  ----------------------
  -Arduino IDE 1.0

  Hardware Requirements:
  ----------------------
  -Arduino
  -Pressure sensors
  -Gyroscope
  -Servo motors

  Project Requirents:
  -------------------
  • Game pad controller

*/

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

#define SensorV 15

#define Button 4

const int POT_0_CS = 6;
const int LOOP_DELAY = 200;

RF24 radio(9,10);
MCP4261 pot0 = MCP4261(POT_0_CS);

const uint64_t pipes[6] = {0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL, 0xF0F0F0F0E2LL, 0xF0F0F0F0D3LL, 0xF0F0F0F0E3LL, 0xF0F0F0F0D4LL};

int speed = 0;
int angle = 0;

int y1_axis = 0, y2_axis = 0, y3_axis_1, y3_axis_2;
int y1_last = 0, y2_last = 0;
int y1_thres = 0, y2_thres = 0 , y3_thres_1 , y3_thres_2;
int sensorBL;
int sensorBR;
int sensorSL;
int sensorSR;

int prev_y1_axis = 0;
int y1_hold = 0;
unsigned long timer;
int start = 0;
byte step = 0;
String steps ,  laststep;
int freq;
int runC;
int press1 = 0 , press2 = 0;
byte pos;
int pox;

void setup() {
  Serial.begin(115200);
  pinMode(POT_0_CS , OUTPUT);
  pinMode(10 , OUTPUT);
  selectSlave(1);
  radio.begin();
  radio.setRetries(15, 15);
  pinMode(Button , OUTPUT);
  digitalWrite(Button , LOW);
  selectSlave(2);
  // Setup SPI communications
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV8);
  SPI.begin();
  pot0.initialize();
}

void loop() {
  receiveData();
  checkV();

  if (sensorSL > 120) {
    speed = map( sensorSL , 0 , 1023 , 0 , 255);
    if (sensorSL < 700) {
      selectSlave(2);
      pot0.setWiper0(86);
      press1 = 0;
    }
    else {
      selectSlave(2);
      pot0.setWiper0(0);
      press1 = 1;
    }
  }
  else if (sensorSR > 120) {
    speed = map( sensorSR , 0 , 1023 , 0 , 255);

    if (sensorSR < 700) {
      selectSlave(2);
      pot0.setWiper0(180);
      press1 = 0;
    }
    else {
      selectSlave(2);
      pot0.setWiper0(256);
      press1 = 1;
    }
  }

  if (sensorSL < 120 && sensorSR < 120 && pos == 0)  {
    selectSlave(2);
    pot0.setWiper0(127);
    press1 = 0;
  }
  else if (sensorSL < 120 && sensorSR < 120 && pos == 1) {  //left down
    selectSlave(2);
    pot0.setWiper0(256);
    pot0.setWiper1(256);
  }
  else if (sensorSL < 120 && sensorSR < 120 && pos == 2) {  //left up
    selectSlave(2);
    pot0.setWiper0(256);
    pot0.setWiper1(0);
  }
  else if (sensorSL < 120 && sensorSR < 120 && pos == 3) {  //right down
    selectSlave(2);
    pot0.setWiper0(0);
    pot0.setWiper1(256);
  }
  else if (sensorSL < 120 && sensorSR < 120 && pos == 4) {  //right up
    selectSlave(2);
    pot0.setWiper0(0);
    pot0.setWiper1(0);
  }
  else if (sensorSL < 120 && sensorSR < 120 && pos == 5) {  //left
    selectSlave(2);
    pot0.setWiper0(256);
    pot0.setWiper1(127);
    press1 = 1;
  }
  else if (sensorSL < 120 && sensorSR < 120 && pos == 6) {  //right
    selectSlave(2);
    pot0.setWiper0(0);
    pot0.setWiper1(127);
    press1 = 1;
  }
  else if (sensorSL < 120 && sensorSR < 120 && pos == 7) {  //down
    selectSlave(2);
    pot0.setWiper0(127);
    pot0.setWiper1(256);
    press1 = 1;
  }
  else if (sensorSL < 120 && sensorSR < 120 && pos == 8) {  //up
    selectSlave(2);
    pot0.setWiper0(127);
    pot0.setWiper1(0);
    press1 = 1;
  }
  /*else if (sensorSL < 120 && sensorSR < 120 && pos == 9) {  //Jump
    selectSlave(2);
    pot0.setWiper0(127);
    pot0.setWiper1(256);
    press1 = 1;
  }
  else if (sensorSL < 120 && sensorSR < 120 && pos == 10) {  //Crawl
    selectSlave(2);
    pot0.setWiper0(127);
    pot0.setWiper1(0);
    press1 = 1;
  }*/


  //0 right  - 64 centr - 127 left

  if (sensorBL > 250 && pos == 0) {
    speed = map( sensorBL , 0 , 1023 , 0 , 255);
    if (sensorBL < 500) { //less pressure 90+20=110
      selectSlave(2);
      pot0.setWiper1(50);
      angle = 95;
      press2 = 0;
    }
    else if (sensorBL > 500 && pos == 0) { //more pressre 90+90 = 180
      selectSlave(2);
      pot0.setWiper1(0);
      angle = 105;
      press2 = 1;
    }
  }
  else if (sensorBR > 250 && pos == 0) {
    speed = map( sensorBR , 0 , 1023 , 0 , 255);
    if (sensorBR < 500) {  //less pressure
      selectSlave(2);
      pot0.setWiper1(50);
      angle = 95;
      press2 = 0;
    }
    else if  (sensorBR > 500 && pos == 0) { //more pressre
      selectSlave(2);
      pot0.setWiper1(0);
      angle = 105;
      press2 = 1;
    }
  }
  else if (pos == 0 && (start == 0 || millis() - timer > 800) && y1_axis > y1_thres - SensorV && y1_axis < y1_thres + SensorV && y2_axis > y2_thres - SensorV && y2_axis < y2_thres + SensorV && sensorBL < 200 && sensorBR < 200) //flat dead end no servo movement - center position -  can we separate on different lines the pressure sensor and accell so that I can set the dead end value separately for the press sens and acc ?
  {
    if (angle == 70 && runC > 0) {
      angle = 78;
      selectSlave(2);
      pot0.setWiper1(150);
      runC--;
      press2 = 0;
    }
    else {
      selectSlave(2);
      pot0.setWiper1(128);
      start = 1;
      angle = 87;
      press2 = 0;
    }
    //Serial.println("Servo goes to zero");
    step = 0;
    steps = "0";
  }
  else if ((y1_axis < y1_thres - SensorV) && (step == 0 || step == 2))
  {
    step = 1;
    steps = "1";
  }
  else if ((y2_axis < y2_thres - SensorV) && (step == 0 || step == 1))
  {
    step = 2;
    steps = "2";
  }

  if (!steps.equals(laststep) && pos == 0) {
    if ((step == 1 || step == 2)  &&  millis() - timer < 300) {
      if (freq > 1) {
        selectSlave(2);
        pot0.setWiper1(256);
        angle = 70;
        press2 = 1;
      }
      else {
        selectSlave(2);
        pot0.setWiper1(150);
        angle = 78;
        press2 = 0;
      }
      freq++;
      runC = 1;
    }
    else if ((step == 1 || step == 2 &&  millis() - timer > 675)) {
      selectSlave(2);
      pot0.setWiper1(150);
      angle = 78;
      freq = 1;
      press2 = 0;
    }
    timer = millis();
  }

  if (press1 == 1 || press2 == 1)
    digitalWrite(Button , LOW);
  else
    digitalWrite(Button , HIGH);

 /* Serial.print("SL: " + String(sensorSL) + " SR: " + String(sensorSR));
  Serial.print(" BL: " + String(sensorBL) + " BR: " + String(sensorBR));
  Serial.print(" Y1: " + String(y1_axis) + " Y2: " + String(y2_axis));
  Serial.print("Pos: " + String(pos));
  Serial.print(" Y3x: " + String(y3_axis_1) + " Y3y: " + String(y3_axis_2));
  Serial.println(" Y3xx: " + String(y3_thres_1) + " Y3yy: " + String(y3_thres_2));*/
  Serial.println("Angle: " + String(angle));

  laststep = steps;
  delay(80);
}

void receiveData() {
  selectSlave(1);
  for (int i = 0 ; i < 3;) {
    radio.openReadingPipe(1, pipes[i]);
    radio.startListening();
    if ( radio.available() )
    {
      char rawMessage[40] = {0} ;
      while ( radio.available() )
      {
        radio.read( &rawMessage, sizeof(rawMessage) );
       // Serial.println(rawMessage);
        delay(10);
      }
      radio.stopListening();
      String data = String(rawMessage);
      switch (i) {
        case 0:
          y1_thres = data.substring(0, data.indexOf(",")).toInt();
          data.remove(0, data.indexOf(",") + 1);
          y1_axis  = data.substring(0,  data.indexOf(",")).toInt();
          data.remove(0, data.indexOf(",") + 1);
          sensorBR  = data.substring(0,  data.indexOf(",")).toInt();
          data.remove(0, data.indexOf(",") + 1);
          sensorSR = data.substring(0,  data.length()).toInt();
          break;
        case 1:
          y2_thres = data.substring(0, data.indexOf(",")).toInt();
          data.remove(0, data.indexOf(",") + 1);
          y2_axis  = data.substring(0,  data.indexOf(",")).toInt();
          data.remove(0, data.indexOf(",") + 1);
          sensorBL  = data.substring(0,  data.indexOf(",")).toInt();
          data.remove(0, data.indexOf(",") + 1);
          sensorSL = data.substring(0,  data.length()).toInt();
          break;
        case 2:
          y3_axis_1 = data.substring(0, data.indexOf(",")).toInt();
          data.remove(0, data.indexOf(",") + 1);
          y3_axis_2  = data.substring(0,  data.indexOf(",")).toInt();
          data.remove(0, data.indexOf(",") + 1);
          y3_thres_1  = data.substring(0,  data.indexOf(",")).toInt();
          data.remove(0, data.indexOf(",") + 1);
          y3_thres_2 = data.substring(0,  data.indexOf(",")).toInt();
          data.remove(0, data.indexOf(",") + 1);
          pox = data.substring(0,  data.length()).toInt();
          break;
      }
      i = i + 1;
    }
  }
  radio.stopListening();
  radio.openWritingPipe(pipes[3]);
  String t = String(pox);
  char callback[5];
  t.toCharArray(callback , t.length() + 1);
  radio.write( &callback, sizeof(callback));
}

void checkV() {
  if (y3_axis_1 > y3_thres_1 - 15 && y3_axis_1 < y3_thres_1 + 15 && y3_axis_2 > y3_thres_2 - 15 && y3_axis_2 < y3_thres_2 + 15)
    pos = 0; //center
  else if (y3_axis_1 > 0) {       //left
    if (y3_axis_2 > y3_thres_2 - 15 && y3_axis_2 < y3_thres_2 + 15)
      pos = 5;                    //left
    else if (y3_axis_2 > 0) {
      if (y3_axis_1 > y3_thres_1 - 15 && y3_axis_1 < y3_thres_1 + 15)
        pos = 7;                    //Down
      else
        pos = 1;                    //left down
    }
    else if (y3_axis_2 < 0) {
      if (y3_axis_1 > y3_thres_1 - 15 && y3_axis_1 < y3_thres_1 + 15)
        pos = 8;                    //UP
      else
        pos = 2;                    //left up
    }
  }
  else if (y3_axis_1 < 0) {       //right
    if (y3_axis_2 > y3_thres_2 - 15 && y3_axis_2 < y3_thres_2 + 15)
      pos = 6;                    //Right
    else if (y3_axis_2 > 0) {
      if (y3_axis_1 > y3_thres_1 - 15 && y3_axis_1 < y3_thres_1 + 15)
        pos = 7;                    //Down
      else
        pos = 3;                    //right down
    }
    else if (y3_axis_2 < 0) {
      if (y3_axis_1 > y3_thres_1 - 15 && y3_axis_1 < y3_thres_1 + 15)
        pos = 8;                    //UP
      else
        pos = 4;                    //right up
    }
  }
}

void selectSlave(byte x) {
  switch (x) {
    case 1:
      digitalWrite(POT_0_CS , HIGH);
      digitalWrite(10 , LOW);
      break;
    case 2:
      digitalWrite(POT_0_CS , LOW);
      digitalWrite(10 , HIGH);
      break;
  }
}

3) right hand:

Code:
/*


  Software Requirements:
  ----------------------
  -Arduino IDE 1.0

  Hardware Requirements:
  ----------------------
  -Arduino
  -Pressure sensors
  -Gyroscope
  -Servo motors

  Project Requirents:
  -------------------
  • Game pad controller

*/

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

#define Button 4

const int POT_0_CS = 6;
const int LOOP_DELAY = 200;

RF24 radio(7, 8);
MCP4261 pot0 = MCP4261(POT_0_CS);

const uint64_t pipes[6] = {  0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL, 0xF0F0F0F0E2LL, 0xF0F0F0F0D3LL, 0xF0F0F0F0E3LL, 0xF0F0F0F0D4LL };
int pos , press1;

void setup() {
  Serial.begin(115200);
  pinMode(POT_0_CS , OUTPUT);
  pinMode(8 , OUTPUT);
  selectSlave(1);
  radio.begin();
  radio.setRetries(15, 15);
  pinMode(Button , OUTPUT);
  digitalWrite(Button , LOW);
  selectSlave(2);
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV8);
  SPI.begin();
  pot0.initialize();
}

void loop() {
  receiveData();

  if (pos == 2) {  //down
    selectSlave(2);
    pot0.setWiper0(127);
    pot0.setWiper1(256);
    press1 = 0;
  }
  else if (pos == 1) {  //up
    selectSlave(2);
    pot0.setWiper0(127);
    pot0.setWiper1(0);
    press1 = 1;
  }
  else {
    pot0.setWiper0(127);
    pot0.setWiper1(127);
    press1 = 0;
  }

  
  if (press1 == 1)
    digitalWrite(Button , LOW);
  else
    digitalWrite(Button , HIGH);

  Serial.println("Pos: " + String(pos));
  delay(80);
}

void receiveData() {
  selectSlave(1);
  radio.openReadingPipe(1, pipes[3]);
  radio.startListening();
  if ( radio.available() )
  {
    char rawMessage[32] = {0} ;
    while ( radio.available() )
    {
      radio.read( &rawMessage, sizeof(rawMessage) );
      Serial.println(rawMessage);
      delay(10);
    }
    radio.stopListening();
    String data = String(rawMessage);
    pos = data.toInt();
  }
}

void selectSlave(byte x) {
  switch (x) {
    case 1:
      digitalWrite(POT_0_CS , HIGH);
      digitalWrite(8 , LOW);
      break;
    case 2:
      digitalWrite(POT_0_CS , LOW);
      digitalWrite(8 , HIGH);
      break;
  }
}

4) left shoe

Code:
/*


  Software Requirements:
  ----------------------
  -Arduino IDE 1.0

  Hardware Requirements:
  ----------------------
  -Arduino
  -Pressure sensors
  -Gyroscope
  -Servo motors

  Project Requirents:
  -------------------
  • Game pad controller

*/

#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define SensorV 15

#define Sensor_BL A0
#define Sensor_SL A1

RF24 radio(9,10);
Adafruit_BNO055 bno1 = Adafruit_BNO055(-1, 0x28);

const uint64_t pipes[6] = {0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL, 0xF0F0F0F0E2LL, 0xF0F0F0F0D3LL, 0xF0F0F0F0E3LL, 0xF0F0F0F0D4LL };

int y1_axis = 0;
int y1_thres = 0;

int sensorBL;
int sensorSL;

void setup() {
  Serial.begin(115200);

  radio.begin();
  radio.openWritingPipe(pipes[1]);
  radio.stopListening();

  if (!bno1.begin())
  {
    Serial.print("Ooops, no BNO055 1 detected ... Check your wiring or I2C ADDR!");
    while (1);
  }

  delay(1000);

  bno1.setExtCrystalUse(true);
  delay(100);

  unsigned long timer;
  Serial.println("Calibration...");
  while (millis() - timer < 10000) {
    imu::Vector<3> euler1 = bno1.getVector(Adafruit_BNO055::VECTOR_EULER);
    y1_thres = euler1.z();
    Serial.print(".");
    delay(100);
  }
  Serial.println("\nDone");
  Serial.println(String(y1_thres));
  delay(3000);
}

void loop() {
  imu::Vector<3> euler1 = bno1.getVector(Adafruit_BNO055::VECTOR_EULER);

  y1_axis = euler1.z();

  sensorBL = analogRead(Sensor_BL);
  sensorSL = analogRead(Sensor_SL);

  String temp = String(y1_thres) + "," + String(y1_axis) + "," + String(sensorBL) + "," + String(sensorSL);
  const char text[32];
  temp.toCharArray(text , temp.length() + 1);
  radio.write(&text, sizeof(text));
  Serial.println(text);
  delay(50);
}

5) right shoe

Code:
/*


  Software Requirements:
  ----------------------
  -Arduino IDE 1.0

  Hardware Requirements:
  ----------------------
  -Arduino
  -Pressure sensors
  -Gyroscope
  -Servo motors

  Project Requirents:
  -------------------
  • Game pad controller

*/

#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define SensorV 15

#define Sensor_BR A0
#define Sensor_SR A1

RF24 radio(9,10);
Adafruit_BNO055 bno1 = Adafruit_BNO055(-1, 0x28);

const uint64_t pipes[6] = {  0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL, 0xF0F0F0F0E2LL, 0xF0F0F0F0D3LL, 0xF0F0F0F0E3LL, 0xF0F0F0F0D4LL };

int y1_axis = 0;
int y1_thres = 0;

int sensorBR;
int sensorSR;


void setup() {
  Serial.begin(115200);

  radio.begin();
  radio.openWritingPipe(pipes[0]);
  radio.stopListening();

  if (!bno1.begin())
  {
    Serial.print("Ooops, no BNO055 1 detected ... Check your wiring or I2C ADDR!");
    while (1);
  }

  delay(1000);

  bno1.setExtCrystalUse(true);
  delay(100);

  unsigned long timer;
  Serial.println("Calibration...");
  while (millis() - timer < 10000) {
    imu::Vector<3> euler1 = bno1.getVector(Adafruit_BNO055::VECTOR_EULER);
    y1_thres = euler1.z();
    
    Serial.print(".");
    delay(100);
  }
  Serial.println("\nDone");
  Serial.println(String(y1_thres));
  delay(3000);
}

void loop() {
  imu::Vector<3> euler1 = bno1.getVector(Adafruit_BNO055::VECTOR_EULER);

  y1_axis = euler1.z();

  sensorBR = analogRead(Sensor_BR);
  sensorSR = analogRead(Sensor_SR);

  String temp = String(y1_thres) + "," + String(y1_axis) + "," + String(sensorBR) + "," + String(sensorSR);
  const char text[32];
  temp.toCharArray(text , temp.length() + 1);
  radio.write(&text, sizeof(text));
  Serial.println(text);
  delay(50);
}

I would love to test and use such same sort of setup on the teensy to make my wired locomotion system, wireless.

Not sure where to start from. What hardware should I need and also how to adapt these code lines for the teens .Moreover, I have no clue where the issue is for the delay I have had.

Do you see anything weird in this codes?

Any help would be great

Thanks!

ps: I have an improved version of this code for the wired system, but before reach to the point how to adapt that code to a wireless system, I think the 1st step for me is testing if I can have a wireless setup on the teensy with no 1 sec delay

These are my of old wireless modules I used

https://ibb.co/n7R1nqq
https://ibb.co/xJjFYYZ
https://ibb.co/BVd3t4C
https://ibb.co/qj7HvRN
https://ibb.co/kJYN5NM
https://ibb.co/pK0BXg1
 

Attachments

  • 20201024_091041.jpg
    20201024_091041.jpg
    56.7 KB · Views: 49
Last edited:
the 1st step for me is testing if I can have a wireless setup on the teensy with no 1 sec delay]

Yes, that is exactly what I wanted to advice you!
Start with a 2-node setup [2 Teensy's + 2 NRF24 modules] and make that work satisfactorily. No other peripherals attached. The nRF24 GettingStarted sample code gives you timing results.
Then add another Teensy + RF node to your setup, and so on. Then add the peripherals [hardware and software] step by step.

I did not go through your pieces of code very extensively but I noticed that for example in the "chest" code that you set the nRF24 in transmit mode in your setup(). My advice would be to set every nRF24 module in your system to receive mode by default in setup() and only switch to transmit mode when you actually gathered the data from the sensors and the data is available for transmitting out. In pseudo code:
Code:
setup(){
   radio.startListening();
}

loop(){
   if sensor data available {
[INDENT]read data from sensor();[/INDENT]
[INDENT]radio.stopListening();[/INDENT]
[INDENT]radio.write(data);[/INDENT]
[INDENT]radio.startListening();[/INDENT]
   }
}

This way, the air is clear from RF transmit carriers as much as possible.
You may also want to set the RF frequency high in the 2.4GHz ISM band, e.g. radio.setChannel(120);. Most WiFI accesspoints and clients operate in the lower part of the ISM band.

Success,
Paul
 
Yes, that is exactly what I wanted to advice you!
Start with a 2-node setup [2 Teensy's + 2 NRF24 modules] and make that work satisfactorily. No other peripherals attached. The nRF24 GettingStarted sample code gives you timing results.
Then add another Teensy + RF node to your setup, and so on. Then add the peripherals [hardware and software] step by step.

I did not go through your pieces of code very extensively but I noticed that for example in the "chest" code that you set the nRF24 in transmit mode in your setup(). My advice would be to set every nRF24 module in your system to receive mode by default in setup() and only switch to transmit mode when you actually gathered the data from the sensors and the data is available for transmitting out. In pseudo code:
Code:
setup(){
   radio.startListening();
}

loop(){
   if sensor data available {
[INDENT]read data from sensor();[/INDENT]
[INDENT]radio.stopListening();[/INDENT]
[INDENT]radio.write(data);[/INDENT]
[INDENT]radio.startListening();[/INDENT]
   }
}

This way, the air is clear from RF transmit carriers as much as possible.
You may also want to set the RF frequency high in the 2.4GHz ISM band, e.g. radio.setChannel(120);. Most WiFI accesspoints and clients operate in the lower part of the ISM band.

Success,
Paul

Ok . Thanks! Going to look into this
 
Status
Not open for further replies.
Back
Top