You are here

Custom Display Receiver for VESC

2 posts / 0 new
Last post
WatEvsCevs
Offline
Last seen: 2 years 9 months ago
Joined: 2019-08-28 02:05
Posts: 1
Custom Display Receiver for VESC

I am currently designing a wireless controller that displays the VESC data (voltage, current, speed, etc.). I am using 2 arduinos that are connected to 2 NRF24L01 transceivers. The sending arduino is located on the skateboard and sends the telemetry data from the VESC to the receiving arduino. I am having trouble coding the transmitter side of the project as I do not know how to send the multiple variables to the receiving arduino. I am unfamiliar with this library for the NRF24L01 transceivers. Here is the code I have so far for the transmitting arduino.

#include <SPI.h>
#include "RF24.h"
#include <VescUart.h>

RF24 myRadio (7, 8); //Radio Setup
byte addresses[][6] = {"0"};

struct package
{
  int id=1;
};

typedef struct package Package;
Package data;

VescUart UART; //Enables UART communication

void setup() {
  Serial.begin(115200);//Radio Setup (again)
  delay(1000);
  myRadio.begin();
  myRadio.setChannel(115);
  myRadio.setPALevel(RF24_PA_MAX);
  myRadio.setDataRate( RF24_250KBPS ) ;
  myRadio.openWritingPipe( addresses[0]);
  delay(1000);
  Serial1.begin(19200);//UART Communication Setup
  while (!Serial) {;}
  UART.setSerialPort(&Serial1);
}

void loop() {

    if ( UART.getVescValues() ) {//If Arduino recieves VESC Values then send data to recieving module.
      
      myRadio.write(&data, sizeof(data)); 

  Serial.print("\nPackage:");
  Serial.print(data.id);
  Serial.print("\n");
  data.id = (UART.data.rpm)(UART.data.inpVoltage)(UART.data.ampHours)(UART.data.tachometerAbs);

    }

}

 

I am aware that the code does not work, but much help is greatly appreciated :)

frank
Offline
Last seen: 38 min 14 sec ago
VESC BronzeVESC FreeVESC GoldVESC OriginalVESC PlatinumVESC Silver
Joined: 2016-12-27 20:19
Posts: 847