0

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
radio.write(&moisture);
radio.write(&temp);
//the above couple lines is where I start having trouble. The RPi will spit output a seemingly random selection of numbers
asked Feb 17, 2017 at 2:37

4 Answers 4

1

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);
answered Feb 17, 2017 at 7:18
0

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.

answered Feb 17, 2017 at 11:57
0

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.

answered Sep 2, 2017 at 18:01
0

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

answered Jun 14, 2019 at 14:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.