Arduino Mega - sending commands via RS232

@Janii njce drawing, I see what you talking about now.

Also, once you do manage, start way slower with the Arduino code. Something like the sketch you posted first, that just listens and repeats.

@markd833 there is no driver issue when the USB to RS-232 cable is used with the anemometer on the USB side and the real RS

wait, @Janii - you have real RS-232 ports on the desktop machine?

How did you wire things up for the CoolTerm?

Since you so handy with pen and paper, please draw the setup you used to get the data stream in post #4 above.

a7

Okay so the problem isn't that there is no host? Because I was trying to do this first with USB to TTL adapter but I found out that I couldn't do this without USB host (according to what I found on the internet)..So I bought a USB host shield for Arduino but there was problem with the code..

@alto777
No, I don't have RS-232 port.

To get the data stream I just connected the anemometer via USB cabel to computer:

What USB host shield? What program?

@Janii sorry, confused.

Please correct and/or illuminate or elaborate:

You have not ever used the USB to RS-232 cable with success.

To get it to work with the PC would (probably) require a driver you might not have aready installed.

I think it should "just work" with the anemometer, but so far evidence suggests it is not. Just working.

A possible experiment, but a painful one, would be to use the USB on the Arduino to connect to the USB on the anemometer.

I say painful, what I mean is less than ideal as it will involve downloading the simple test code, disconnecting from the PC, powering the Arduino other that through the USB connector, connecting it to the anemometer and… seeing what you get.

Rinse and repeat if you have any hair left.

a7

When you connect the anemometer to your PC, does it appear as another COM port in Device Manager, or does it appear as a completely different device type?

It looks like this:


Would it be better if I shared link to the components that I'm posting here?
The USB host library has examples od codes on how to communicate with devices using this shield (like Xbox etc.):

And there are also drivers like pl2303 and so on but according to what I found, if those examples don't work for me, my device is probably using something else and solution is to write my own code to start such communication (and I have no idea whats in my device or how do such thing)

Yes I did. I connected this cable with USB to my computer and on the other side (RS232) I connected pins RX and TX.

It appears as another COM port device.

More information never hurts.

Yes I did. I connected this cable with USB to my computer and on the other side (RS232) I connected pins RX and TX.

So... isn't that the test of the franken-cable minus a few parts which should not cause it to no work?

I'm out the door, my beach buddy texted and she must not be kept waiting.

It seems like something simple at this point. It is not a PC driver issue (anymore?).

I'll run it by the Umbrella Academy, but they are known to be somewhat more interested in real life when we convene.

L8R and good luck.

a7

Yes, it is. The cable is fine. It's just wierd that when I connected this one to PC, the CoolTerm is really slow..even when I want to send something it takes time. When I connected anemometer right away everything it's okay. I don't know if it means something, just mentioning.

EDIT: Also I noticed that there is a little light on the RS-232 connector (on USB to RS232 cabel) and when I connected it to the PC, it lights up...when it's connected with anemometer it doesn't

Okay, thank you and for your help. I hope I will figure something out.

Do you mean something like this?

Just my opinion, but the USB host shield you had in post #25 is the piece of kit I would be thinking of. You need to check to see if the library for the host shield supports serial comms - there's a fancy USB speak name for it - might be CDC class - but i'm not sure.

The official Arduino docs for their shield say:

The following device classes are supported by the shield:

  • HID devices: keyboards, mice, joysticks, etc.
  • Game controllers: Sony PS3, Nintendo Wii, Xbox360.
  • USB to serial converters: FTDI, PL-2303, ACM, as well as certain cell phones and GPS receivers.
  • ADK-capable Android phones and tables.
  • Digital cameras: Canon EOS, Powershot, Nikon DSLRs and P&S, as well as generic PTP.
  • Mass storage devices: USB sticks, memory card readers, external hard drives, etc.
  • Bluetooth® dongles.

So I think you were on the right track with that sort of shield.

No. I think you need to keep it all USB in order for the setup to work.

still not completely clear what the cable in this picture is

is it a pure standard USB-cable with on one side a small USB-mini-plug and on the other side a USB-A plug.
Both beeing as small and flat as in tis picture

Or does this "cable" have a bigger housing that has a TTL to USB-converter inside?
Best way would be to post a picture of the real anemometer with its real cable one picture showing the anemometer with plugged in USB-cable
one picture showing the opposite end plugged into your computer

From what is being described, I believe it to be a straightforward USB cable. When the anemometer is plugged into a PC using the USB cable, it enumerates as a COM port. The documentation I found stated that the sensor has a USB port - likely an internal Serial-USB chip.

@StefanL38
Yes, it's that USB cable - one side USB mini plug and on the other USB A plug. Sorry, I thought it was clear.

Yes, it is.

Hm, I don't see anything like that, but I will look at it again.

I thought it would be easier use RS232 because of the code. But maybe you are right.

If I got it right, you used that shield before (or something like that). It connects on the top of the Arduino..is it possible to use the Arduino as before? Or all the other sensors etc. that I'm planning to connect to the Arduino Mega will have to be on other Arduino. Maybe silly question, I'm sorry :sweat_smile:

As with any shield, you would need to know which pins it used on your particular Arduino.

It seems that the original Arduino USB host shield didn't support serial comms, but there was a newer version that did. Your photo looks to be of a different USB host board. Do you know which one it is? What chip does it use to perform the USB functions? Did the board specify a library to use with it?

I have this one with MAX3421EE:

The datasheet:

The are mentioning library which I installed.

A quick search shows that the MAX3421 does support serial comms.

The Arduino USB Host Shield 2.0 uses the MAX3421 and the website of the board you linked to links back to the Arduino USB Host shield library. There's a good chance that the board you have is possibly a clone of the now discontinued Arduino shield. The Arduino documentation page here:

has a schematic of the shield, which shows the use of the SPI interface. Multiple devices can share the same SPI bus pins (MOSI, MISO & SCK) so that shouldn't be an issue. The board seems to be hard wired to use D10 as the SPI SS signal. You will have problems if another shield is also hard wired to use D10 as its SPI SS signal.

The Arduino library appears to have an example sketch called USBFTDILoopback.ino which I think would be a good starting point.

Also a search with your preferred search engine for "arduino usb host shield serial communication" should get you a fair bit of guidance on how to configure the shield for "serial" comms.

1 Like

Thank you for your advice and time. I'm gonna try it... I hope it's gonna work.

Hello everyone,

my attempts with USB host shield were not successful....So I bought RS232 host shield on Arduino. But I found out that the problem ist RS232 to USB cabel I'm using. It's powered from USB and it expects host device on USB side, not RS232. So thats why it worked with computer and the little led on the cabel lights up when I connect it to computer.

Thank you all for you advices, help and time :slightly_smiling_face: I appreciate it

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