Arduino Uno + USB Host shield receiving serial data from second Arduino UNO USB port

Please can anyone give me some guidance on how to receive serial data from an Arduino UNO USB port into a second Arduino UNO with a USB Host shield fitted ? Example code would be great. I've installed the USB Host Shield 2 library and looked at endless examples but I've completely failed to understand how to achieve this. I think the acm_terminal example should do something like what I need but I've failed to get anywhere with it. Hardware is no problem, I can put together software so long as I have a few examples to work from, and yes I know it would be much easier to use a simple serial connection, see below for the reason I can't.

Background - I have a custom built Arduino UNO based weather station in a sealed box in a pretty innaccessible place that outputs a serial text string every two seconds. It currently feeds into a Raspberry Pi 3, along with six other indoor Arduino based sensors, which processes and publishes the data to an MQTT Broker. I've updated the other sensors to publish their data directly to the MQTT Broker via ethernet and would like to do the same with the weather station. It's not practical to do this with the weather station, hence I'd like to use a second (indoor) Arduino UNO to process and publish the MQTT data. I'd prefer a solution that can be shut off and powered back up without worrying about SD card corruption and other issues with using a Raspberry Pi.

I'm pretty sure what I need is do-able, in fact I'm surprised not to find any examples of doing just this on the web ! I just don't have the software knowledge to achieve it without some help :slight_smile:

PaulM

You can start with the acm_terminal example and modify it to fit your needs.

Thanks for your quick reply. So far I've got nowhere with the acm_terminal example, I'm beginning to wonder if my USB shield works :frowning:

The program runs and outputs 'Start' to the serial monitor, no errors. Should the serial data from the second UNO be received and displayed or do I have to add some code to accept it ? All I've done so far is to change the baud rates to 9600.

So far I've not found any documentation on the workings of the USB Shield library or any explanations of the API calls :frowning:

PaulM

Ok, I have a suspicion my host shield isn't working. I assume if I run the USB_desc example with a USB device connected it should give me some form of description of the device on the serial monitor. It just does the same as the other programs I've tried, 'Start' then nothing, so I assume there's a problem with the host shield somewhere :frowning:

I've made the 5v & 3.3v links to the UNO and the 5v 'VBUS' link to the USB connector, the INT and SS signals are connected to the UNO D9 & D10 as expected. The second UNO board has 5v when connected to the USB host. If I run any of the examples with no host shield plugged in I get the 'Usb.Init() == -1' error. Not sure where to go from here...