RX Sketch Nano RP2040 Connect

I replaced an Arduino Uno with a Nano RP2040 Connect and successfully loaded the Uno Receiver Sketch in the Nano RP2040 Connect. NRF24LO1 connections were the same: D13(SCK), D12(MISO), D11(MOSI), D10(CSN), D5(CE), D6(ServoTwo), D3(Servo).

Receiver Sketch

#include <Servo.h>
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "RF24_config.h"
 
Servo myServo;
Servo myServoTwo;
 
RF24 radio(5,10);
const uint64_t pipe = 0XE8E8F0F0E1LL;
int msg[2];
 
void setup(){
  myServo.attach(3);
  myServoTwo.attach(6);
  
  radio.begin();
  radio.openReadingPipe(1, pipe);
  radio.setChannel(76);  
  radio.startListening();
  }
 
void loop(){
  if(radio.available()){
      radio.read(&msg, sizeof(msg));
      myServo.write(msg[0]);
      myServoTwo.write(msg[1]);
  }
      
}

The system does not work! Any suggestions would help.

Larry

@talleyl, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project :wink: See About the Installation & Troubleshooting category.

Please edit your post, select all code and click the </> button to apply so-called code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code.

Welcome to the forum.

You did not confirm whether you adapted your circuit to 3.3V. The Arduino Nano RP2040 Connect is a 3.3V device while the Arduino Uno is 5V. Any circuits that are 5V only will need some level shifters for all signals connected to the Arduino.

Please have a look into the following post for other information that may be required to help you.

The NRF24LO1 device is connected to the 3.3 v pin out on the Nano RP2040 connect. The sane hookup as the Uno. The servos are powered by a separate 5v source.

Larry

The best way to forward is to test your radio and the servos separately.

Do you know what levels the servos control require?

Are you sure the nRF24L01 module you are using is happy with 3.3V?

Do you have datasheets for your modules and the servos? Can you provide links?

Upon investigating, I found that my servos require a 4.8V level control signal to operate. I have ordered DC-DC step up power modules to boost the signal levels from 3.3v to 5v. My issue should be solved. The nRF24LO1 device is happy with 3.3v. Thanks for your spot on help.

Larry

You need a logic level-shifter not a DC-DC step up converter.

DC-DC converters are for power e.g. drive a complete 5V circuit from a 3V battery at the expense of higher current.
A level-shifter is for signals. Most typical modules have two or 8 channels. The PCBs look very simplistic compared to a DC-DC PCB. Just try Google for both and see the difference.

Corrected! Thanks for the info.

Larry

I added a logic level converter (3.3v and 5.0v) for the output PWM signals for the two servos. The system still does not work. I double checked all wiring and voltage levels, all ok. I reloaded the Rx sketch, still does not work. I tested my transmitter with the same sketch loaded on an Uno, it works fine. The NRF24L01+ unit is a 3.3v device.

Larry

Test each of the components individually to find which of them stops your system from working.

Write some simple test sketches e.g., just make your servo move and see what happens.

I think the servo library is not working fine on an Arduino Nano RP2040 Connect.
Using the code here below I sometimes get a reversed servo signal on the output (all the time 3.3V except during 1000 to 2000 microseconds) sometimes a correct servo signal (3.3V during 1000 to 2000 microseconds every 20 0000 microseconds).

#include <Servo.h>
Servo MyServo;
void setup() {
  MyServo.attach(2);
}
void loop() {
  MyServo.writeMicroseconds(1000);
  delay(500);
  MyServo.writeMicroseconds(2000);
  delay(500);
}

@ateliervilvoorde, is this a statement or a request for help?

@sterretje I came on this topic when looking for a solution for my problem with servo on my Arduino Nano RP2040 connects.
I was hoping that pointing out that servo is not working for me is helpfull for all looking into this.

I can add that I have tried it on a 2nd ANRP2040C... same situation.
By the way on both systems D3 does not work with servo at all.

EDIT
Adding a short delay in setup (see code here below) does make the code work perfectly on all PWM-pins except pin3.

#include <Servo.h>
Servo MyServo;
void setup() {
  MyServo.attach(2);
  delay(1);
}
void loop() {
  MyServo.write(0);
  delay(500);
  MyServo.write(180);
  delay(500);
}

The delay does not need to be after the MyServo.attach... the code here below also works perfectly.

#include <Servo.h>
Servo MyServo;
void setup() {
  delay(1);
  MyServo.attach(2);
}
void loop() {
  MyServo.write(0);
  delay(500);
  MyServo.write(180);
  delay(500);
}