Python to Arduino transmitter to Arduino receiver using NRF24LO1

I have been trying to send a list of data from my controller connected to python to the Arduino transmitter, so I can control my plane from the receiver. I have been able to send a list from python using PySerialTransfer to the transmitter, however, when I try to send that list to the receiver I am only able to send the first value in the list, the other values are 0. Any advice would be greatly appreciated.

Here is the python code:

[color=#a9b7c6][color=#cc7832]import [/color]time
[color=#cc7832]from [/color]pySerialTransfer [color=#cc7832]import [/color]pySerialTransfer [color=#cc7832]as [/color]txfer

[color=#cc7832]if [/color]__name__ == [color=#6a8759]'__main__'[/color]:
 [color=#cc7832]try[/color]:
 link = txfer.SerialTransfer([color=#6a8759]'COM3'[/color])

 link.open()
 time.sleep([color=#6897bb]2[/color]) [color=#808080]# allow
[/color][color=#808080] # time for the Arduino to completely reset
[/color]
 [color=#cc7832]while True[/color]:
 send_size = [color=#6897bb]0
[/color]
 [color=#808080]###################################################################
[/color][color=#808080] # Send a list
[/color][color=#808080] ###################################################################
[/color] list_ = [[color=#6897bb]5[/color][color=#cc7832], [/color][color=#6897bb]1[/color]]
 list_size = link.tx_obj(list_)
 send_size += list_size

 [color=#808080]###################################################################
[/color][color=#808080] # Transmit all the data to send in a single packet
[/color][color=#808080] ###################################################################
[/color] link.send(send_size)

 [color=#808080]###################################################################
[/color][color=#808080] # Wait for a response and report any errors while receiving packets
[/color][color=#808080] ###################################################################
[/color] [color=#cc7832]while not [/color]link.available():
 [color=#cc7832]if [/color]link.status < [color=#6897bb]0[/color]:
 [color=#cc7832]if [/color]link.status == txfer.CRC_ERROR:
 [color=#8888c6]print[/color]([color=#6a8759]'ERROR: CRC_ERROR'[/color])
 [color=#cc7832]elif [/color]link.status == txfer.PAYLOAD_ERROR:
 [color=#8888c6]print[/color]([color=#6a8759]'ERROR: PAYLOAD_ERROR'[/color])
 [color=#cc7832]elif [/color]link.status == txfer.STOP_BYTE_ERROR:
 [color=#8888c6]print[/color]([color=#6a8759]'ERROR: STOP_BYTE_ERROR'[/color])
 [color=#cc7832]else[/color]:
 [color=#8888c6]print[/color]([color=#6a8759]'ERROR: {}'[/color].format(link.status))

 [color=#808080]###################################################################
[/color][color=#808080] # Parse response list
[/color][color=#808080] ###################################################################
[/color] rec_list_ = link.rx_obj([color=#aa4926]obj_type[/color]=[color=#8888c6]type[/color](list_)[color=#cc7832],
[/color] [color=#aa4926]obj_byte_size[/color]=list_size[color=#cc7832],
[/color] [color=#aa4926]list_format[/color]=[color=#6a8759]'i'[/color])

 [color=#808080]###################################################################
[/color][color=#808080] # Display the received data
[/color][color=#808080] ###################################################################
[/color] [color=#8888c6]print[/color]([color=#6a8759]'SENT: {} '[/color].format(list_))
 [color=#8888c6]print[/color]([color=#6a8759]'RCVD: {}'[/color].format(rec_list_))
 [color=#8888c6]print[/color]([color=#6a8759]' '[/color])

 [color=#cc7832]except [/color][color=#8888c6]KeyboardInterrupt[/color]:
 [color=#cc7832]try[/color]:
 link.close()
 [color=#cc7832]except[/color]:
 [color=#cc7832]pass
[/color]
[color=#cc7832] except[/color]:
 [color=#cc7832]import [/color]traceback

 traceback.print_exc()

 [color=#cc7832]try[/color]:
 link.close()
 [color=#cc7832]except[/color]:
 [color=#cc7832]pass[/color][/color]

Here is the Arduino transmitter code:

#include "SerialTransfer.h"

#include <SPI.h> //Call SPI library so you can communicate with the nRF24L01+
#include <nRF24L01.h> //nRF2401 libarary found at GitHub - nRF24/RF24: OSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices
#include <RF24.h> //nRF2401 libarary found at GitHub - nRF24/RF24: OSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices

SerialTransfer myTransfer;

const uint8_t pinCE = 9; //This pin is used to set the nRF24 to standby (0) or active mode (1)
const uint8_t pinCSN = 10; //This pin is used to tell the nRF24 whether the SPI communication is a command
RF24 wirelessSPI(pinCE, pinCSN); // Declare object from nRF24 library (Create your wireless SPI)
const uint64_t wAddress = 0xB00B1E50C3LL; //Create pipe address to send data, the "LL" is for LongLong type

void setup()
{
Serial.begin(115200);
myTransfer.begin(Serial);
wirelessSPI.begin(); //Start the nRF24 module
wirelessSPI.openWritingPipe(wAddress); //open writing or transmit pipe
wirelessSPI.stopListening(); //go into transmit mode
}

void loop()
{
if(myTransfer.available())
{
// send all received data back to Python
for(uint16_t i=0; i < myTransfer.bytesRead; i++){
wirelessSPI.write(&myTransfer.packet.rxBuff[uint16_t(0)], sizeof(myTransfer.packet.rxBuff[uint16_t(0)]));
myTransfer.packet.txBuff = myTransfer.packet.rxBuff*;*
* myTransfer.sendData(myTransfer.bytesRead);*
* }*
* }*
}
Here is the Arduino receiver code:
#include <SPI.h> //Call SPI library so you can communicate with the nRF24L01+
#include <nRF24L01.h> //nRF2401 libarary found at https://github.com/tmrh20/RF24/*_
_
#include <RF24.h> //nRF2401 libarary found at https://github.com/tmrh20/RF24/*_
const uint8_t pinCE = 9; //This pin is used to set the nRF24 to standby (0) or active mode (1)
const uint8_t pinCSN = 10; //This pin is used for SPI comm chip select
RF24 wirelessSPI(pinCE, pinCSN); // Declare object from nRF24 library (Create your wireless SPI)
const uint64_t rAddress = 0xB00B1E50C3LL; //Create pipe address for the network and notice I spelled boobies because I am mature, the "LL" is for LongLong type
const uint8_t rFChan = 89; //Set channel frequency default (chan 84 is 2.484GHz to 2.489GHz)
//Create a structure to hold fake sensor data and channel data
struct PayLoad {
* uint8_t chan;
uint8_t sensor;
_
};*

PayLoad payload; //create struct object
byte list_data;
void setup() {
* wirelessSPI.begin(); //Start the nRF24 module*
* wirelessSPI.openReadingPipe(1,rAddress); //This is receiver or master so we need to be ready to read data from transmitters*
* wirelessSPI.startListening(); // Start listening for messages*
* Serial.begin(9600); //serial port to display received data*
* Serial.println("Network master is online...");*
}
void loop() {
* if(wirelessSPI.available()){ //Check if recieved data*
* wirelessSPI.read(&hi, sizeof(list_data)); //read packet of data and store it in struct object*
* Serial.print("Received data: ");*
* Serial.println(list_data);
_
}_
_
}*_

Please read the first topic telling how to get the best from Forum.
Use formatted Arduino code in code tags. The text You sent is not readable and not suited for being copied.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.