Reading A USB Serial Port from the USB Shield

I have been working with Arduino now for many years and recently purchased your Sparkfun USB Host Shield DEV-09947 Order 9672741.

I have interfaced several Victron solar devices to a host Windows computer via USB – reading the various comX: ports and capturing the serial data broadcast by these devices, e.g., BMV-12, MPPT, etc.

Interfacing to: BMV-712 Smart - Victron Energy 2

Using cable: VE.Direct to USB interface - Victron Energy

Now I have a Victron device in a remote location that cannot be wired directly to the USB Hub on the computer.

I purchased the USB Host Shield to read the Victron Serial input on an Arduino Uno WiFi R2 and transmit it via UDP to the computer. I have coded UDP transmission routines successfully and they are working on a dozen or so other Arduino sensors in my project … so no help needed there.

I have studied the schematic of the device. I am aware the SS, MOSI, MISO and SCLK lines from the Max3241E are brought into the Uno, but don’t know how to use this information.

I have been researching this for a week or so and cannot figure out how to read the SF USB Host Shield serial input on the Arduino Uno. Do have a SAMPLE SKETCH I can look at and a link to any special libraries needed (e.g., SPI)?

If I cannot solve this, I will order the RS232 cable from Victron and (horrors!) interface it to a DB9 shield. I would like to avoid that route because it involves obsolete technology. Any guidance appreciated.

It should be something like:

void setup() {

Serial.begin(19200);

}

void loop() {

if (Serial.available()) {

char c = Serial.read();

// do something with the received character

}

}

But my code breaks all the time so use at your own risk! lol

(Then you can send the serial over a different pin/protocol/what-have-you)

I believe the ACM terminal example from the USB_Host_Shield_2.0 library (link below) is what you are looking for. You’ll need to change the baud rate to 19200 to match the Victron VE.Direct interface (line 31 in the example → lc.dwDTERate = 115200; ← change 115200 to 19200). If the device fails to connect, you may need to manual decode the device descriptors that it provides to determine what USB driver you will need to register with the host shield to get the device properly configured (I can probably help if it gets to that point).

https://github.com/felis/USB_Host_Shiel … rminal.ino

For your project, when you get serial data from the Acm.RcvData() function, you can put that data in a UDM packet and send it off to the PC. Hopefully this helps you out.