Converting incoming messages to Unicode.

I have successfully managed to communicate back and forth ( message ,Temp and Humidity data) between Two Arduino Nano using NRF24L01 module. However when I am trying to receive the same block of information in Raspberry Pi3 it is not converting the incoming message to proper Unicode character. Also RX Address is not consistent with the address defined in the pipe.

Attaching the copy of both Arduino and Raspeberry (Python) code with with RSPi output screen.

Not sure where is the problem, appreciate your quick help.

Rgds/rajeev

**** Arduino code****

#include<SPI.h> #include<RF24.h> #include<nRF24L01.h> #include<dht.h> #define DHT11_PIN 3 dht DHT;

RF24 radio(9,10);

char SentMessage[] = "Hi from Arduino.Today's"; const uint64_t pipe[] = {0xE8E8F0F0E1LL ,0xF0F0F0F0E1LL}; void setup(void) {

Serial.begin(9600); radio.begin(); radio.setPALevel(RF24_PA_MAX); radio.setChannel(0x76); radio.setDataRate(RF24_1MBPS); radio.setCRCLength( RF24_CRC_8); radio.setRetries(15,15); radio.setAutoAck(false); radio.openWritingPipe(pipe[1]); radio.enableDynamicPayloads(); radio.powerUp(); //radio.openReadingPipe(0, pipe); //radio.startListening(); //Serial.println("Sending.."); Serial.flush(); } void loop(void) {

int chk = DHT.read11(DHT11_PIN); int Humidity = DHT.humidity; int Temp = DHT.temperature; 'Convert Humidity--'; char Str_HDT[10]; String Str; Str = String(Humidity); Str.toCharArray(Str_HDT ,10); 'Convert Temp----'; char Str_Temp[10]; String StrT; StrT = String(Temp); StrT.toCharArray(Str_Temp ,10);

radio.write(&SentMessage , sizeof(SentMessage));
Serial.print(SentMessage);
Serial.print("  Humidity ");
Serial.print( Str_HDT);
radio.write(&Str_HDT, sizeof(Str_HDT));
Serial.print(" | Temperature ");
Serial.println(Str_Temp);
radio.write(&Temp, sizeof(Temp));

Serial.print(" "); Serial.flush(); delay(1000); }

***************** Raspberry Pi ( Python) ******** import RPi.GPIO as GPIO from lib_nrf24 import NRF24 import time import spidev

GPIO.setmode(GPIO.BCM)

pipes = [[0xE8 , 0xE8, 0xF0, 0xF0, 0xE1],[0xF0, 0xF0, 0xF0, 0xF0,0xE1]] radio = NRF24(GPIO , spidev.SpiDev()) radio.begin(0,8)

radio.setPayloadSize(32) radio.setChannel(0x76) radio.setDataRate(NRF24.BR_1MBPS) radio.setPALevel (NRF24.PA_MAX) radio.setAutoAck(True) radio.enableDynamicPayloads() radio.enableAckPayload() radio.openReadingPipe(1 ,pipes[1]) radio.printDetails() radio.startListening()

while True: while not radio.available(0): time.sleep(1/100)

Temp = []
radio.read(Temp, radio.getDynamicPayloadSize())
print("Received Temp: {}".format(Temp))
print("Translating our received Message into Unicode character...")
string1 = " "
for n in Temp:
      if (n >=32 and n <= 126):
              string1 += chr(n)
print (" Our received message decodes to : {} ".format(string1))      

Str_HDT = []
radio.read(Str_HDT, radio.getDynamicPayloadSize())
print("Received Humidity: {}".format(Str_HDT))
print("Translating our received Message into Unicode character...")
string = " "
for n in Str_HDT:
      if ( n >=32 and n <= 126):
              string += chr(n)
print (" Our received message decodes to : {} ".format(string))
      

SentMessage = ["Hello"]
radio.read(SentMessage, radio.getDynamicPayloadSize())
print("Received Message: {}".format(SentMessage))
print("Translating our received Message into Unicode character...")
string = " "
for n in SentMessage:
      if ( n >=32 and n <= 126):
              string += chr(n)
print (" Our received message decodes to : {} ".format(string))

radio.stopListening()
GPIO.cleanUp()


Output

TATUS = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0 RX_ADDR_P0-1 � = 0x0040007800 0xfe00100000 RX_ADDR_P2-5 � = 0x00 0x00 0x00 0x00

TX_ADDR = 0x78000000f8 RX_PW_P0-6 � = 0x00 0x00 0x00 0x00 0x00 0x00

EN_AA = 0x00

EN_RXADDR � = 0x00

RF_CH = 0x00

RF_SETUP � = 0x40

CONFIG = 0x00

DYNPD/FEATURE � = 0xfe 0x00

Data Rate = 1MBPS Model = nRF24L01 CRC Length = Disabled PA Power = PA_MIN Received Temp: [64, 0, 0, 16, 0, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] Translating our received Message into Unicode character... Our received message decodes to : @ Received Humidity: [0, 16, 0, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] Translating our received Message into Unicode character... Our received message decodes to :
Received Message: [] Translating our received Message into Unicode character... Our received message decodes to :
Received Temp: [64, 16, 0, 0, 16, 0, 254, 0, 0, 0, 64, 0, 0, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] Translating our received Message into Unicode character... Our received message decodes to : @@ Received Humidity: [] Translating our received Message into Unicode character... Our received message decodes to :
Received Message: [0, 0, 0, 0, 0, 16, 0, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] Translating our received Message into Unicode character... Our received message decodes to :

  • I would be surprise if anyone would look into your code and try to debug for you.

    Please provide us your debugging information, not your code.

    Tell us what's wrong with the data you transmit and receive, are they the same or not ? If the address is not match, how would you receive the data ?

    We have nothing to do with Unicode encoding, we only do data transmission. Give us an array of bytes, we give you back the array on the other side.

  • As I mentioned I am just sending the real time Temp and Humidity data ( using DHT module) and a Hello world message. But what I am getting in raspberry Pi3 is just streams of zeros. What is the standard pin layout for NRFL01 and Raspberry Pi3. I have tri d all combination but the result seems to be same .

    Also do you suggest any changes in the above code.

  • Before you try to read and write with Temperature and humidity data, please try with dummy data first. Make sure you can communicate between the RPI3 and the NRFL01p.

    We don't make the python library on the RPI3 so i don't know what could be wrong here. My suggestion is to use a logic analyzer and check the actual data on SPI pins. Check it with the NRF24L01P spec, try to read a register inside nRF24L01P for example.