Wireless remote help

I am creating a wireless remote transmitter and receiver. The transmitter has a analog potentiometer, and the receiver has a digital potentiometer as the output. I can see in the serial monitor that the analog value is being received but it’s not doing anything to the digital potentiometer.

Tx Code


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

RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";

void setup() {
 Serial.begin(9600);
 radio.begin();
 radio.openWritingPipe(address);
 radio.setPALevel(RF24_PA_LOW);
 radio.stopListening();
}

void loop() {
 int raw = analogRead(A0);
 byte wiper = map(raw, 0, 1023, 0, 127);
 radio.write(&wiper, sizeof(wiper));
 delay(100);
}

Rx Code

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

#define DS3502_ADDR 0x28

RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
byte wiperVal = 0;

void setup() {
 Serial.begin(9600);
 Wire.begin();
 radio.begin();
 radio.openReadingPipe(0, address);
 radio.setPALevel(RF24_PA_LOW);
 radio.startListening();
}

void loop() {
 if (radio.available()) {
   radio.read(&wiperVal, sizeof(wiperVal));
   setDS3502(wiperVal);
 }
}

void setDS3502(byte value) {
 Wire.beginTransmission(DS3502_ADDR);
 Wire.write(0x00); // Wiper register
 Wire.write(value); // 0–127
 Wire.endTransmission();
} `

Please verify the I2C address by running an I2C scanner code.

So it seems that there is nothing wrong with the radio link.
Have you tried running an I2C scanner to check that your digital potentiometer is responding to I2C at the address you have defined for it?
[Edit: I wrote the above before @ahsrabrifat replied, sorry for the duplication]
Have you tried running a variant of the [Edit wrong I2C scanner - I meant the receiver] sketch that doesn't have any wireless receiver code. Maybe it could write some value to the potentiometer that you type into the serial monitor.
First thing to do is check the return value of Wire.endTransmission() and print it to the serial monitor.

How are you testing that? Not knowing your experience level, it may be that your test isn't a valid test.

What do your debug prints to the Serial Monitor show (hint).

I am testing by actually trying to operate it where I’m gonna be using it. I will do the I2C scanner when I get back home. Which line would I add to include the Wire.endtransmission to the serial monitor?

That doesn't help me, or anyone reading this, to perhaps spot an error with how you are using / testing it.

[Edit: I modified the above code to make it clearer what's going on. The three lines with arrow comments need to be changed / added]

Thank you I will add that in and see what happens when I get home later. What value should I be looking for on the serial monitor?

I don't mind answering, but in future you could Google for "Arduino Wire.endTransmission() reference". You can usually find the official info on any Arduino built in library function using that technique.
My search gave me this link which contains this info:


So you should see a value of zero if it's working

Additionally, print both the byte value sent by the TX nRF24L01 and the byte value received from the RX nRF24L01. Confirm they match and are as expected.

I have the tx serial monitor printing the analog potentiometers output value, and the byte value is matching on the rx serial monitor. The Wire.endtransmission return value is 2 in the monitor. I did an I2C scanner and it showed 0x28 for the address found.

Hello mkyle15451

Welcome to the world's best Arduino forum ever.

I have been following the topic of using this type of wireless module and the associated software functions for some time now.

For wireless projects, I recommend using the HC12 module.

What are the advantages:

  1. no external functions from a library are needed.
  2. the development of a communication protocol is in your hands
  3. the necessary development steps can be programmed and tested without using the wireless module
  4. the radio module can be easily configured for the project requirements
  5. both transmitter and receiver are contained in one radio module.

hth

Have a nice day and enjoy coding in C++.

A value of 2 means: A NACK after an address is sent, which in turn means no slave responded to that address, but the scanner found it at 0x28 and your code seems to be using 0x28.

I'm puzzled now.