I am able to send text from the Arduino wirelessly to RPi. I am now trying to send the sensor data I'm measuring to the Pi. This is what I have below:

int moisture = A0;
int temp = 3;

//Skipping the setup and reading of the values


//the above couple lines is where I start having trouble.  The RPi will spit output a seemingly random selection of numbers

4 Answers 4


As you haven't said or shown which NRF24L01 library you are using, one can't say for sure what the problem is, but in some NRF24 implementations, the write() method accepts (or requires) a second parameter, len, giving the number of bytes to be sent. If the library you're using doesn't require that parameter, it could be defaulting it to some value, or could be treating the buffer as a string, to be terminated with a null byte.

Either of those cases could produce erratic results.

Instead of leaving off the second parameter, specify it. For example:

radio.write(&moisture, 2);
radio.write(&temp, 2);

I recommend you to choose a platform for communication. You don't need to deal with the low level communication. I suggest you to try https://www.mysensors.org/ It helps to wire your sensors, gives you example codes for the chosen sensors for data transfer in the direction to your Pi. There is a well documented API you can build your application on. On the Pi you can use a serial gateway or/and a controller installed. These controllers are written to communicate with your sensors and other nodes. They give graphical web interface to visualize your data and their history. For a controller I recommend to start with https://www.domoticz.com/ or Openhab I think Domoticz is the better choice to start with on Pi.


most likely is that your nrf24l01 library only allow text or string communcaiton, not nuermical data. when you send your measured data, nrf24l01 treats it as text. so what you read is text (text's unicode numbers). I encountered the same problem.


I will suggest you to provide valid size of data with write function for eg radio.write(&moisture,sizeof(moisture)). hope this will work for further explanation of this method www.robofever.in

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.