2

I am starting with electronics / arduinos / atmegas here. For a couple of recent days I've played with USBasp programmer, atmega328P MCU as well as with 7805 and LM317 voltage regulators. Now my next step is to try to talk with DS18B20 temperature sensor and then with RF 434 / 868 module.

I was thinking how can I see the data read from temperature sensor without having any LCD and the simple answer is using RX/TX pins. The problem is I've stuck on choosing the right cable to do so. I found THIS great stackexchange post about UARTs and RS232 and it narrowed my problem to THAT data cable - which ish FTDI's DS_TTL-232R.

Now, I've also read this datasheet and I do see it's "USB to UART, 3.3V TTL logic level, Raspberry Pi compatible flying leads" but it also states "5V safe TTL inputs make the TTL - 232R easy to interface to 5V MCU’s".

Do I get it right that this cable will allow me to:
- connect PC via USB to atmega328 RS pins (which have 5V logic level AFAIK)
- connect PC via USB to RaspberryPi's RS pins (which have 3.3V logic level)

Also I do guess basing what I've googled that I will need some other part (logic level / voltage shifter) to connect atmega328 MCU to RasPi directly, right? Or.. is it enough to supply 3.3V to MCU so it has up to 3.05 V ouput high, and not up to 5V, which I again guess would cause damage to my RasPi?

1 Answers1

3

The ATMega has a wide VCC range, some run at 3.3v, some at 5v. It's pins are not tolerant of an input at a higher than VCC voltage.

The Raspberry PI is 3.3v signal only. No 5v Tolerant pins.

The USB to Uart with 3.3v signal but 5v Tolerant pins means you can connect a 5v ATMega to the 3.3v USB-to-Uart, and the Uart will be fine. The opposite is not true. Connecting a 5v Uart to a Raspberry PI or 3.3v ATMega will not end well.

If you need to connect a two way signal between a 5v ATMega and 3.3v Raspberry Pi, you would want a level translator on the ATmega TX -> RPI RX line. The other way round, from RPI TX -> ATMega RX, should be good, as the ATMega has a (VCC * 0.6) Input Voltage High threshold. In this case, 5 * 0.6 = 3v. A 3v or higher signal will be read as a logic high, which works fine.

Update: I take it you mean connect a RPI to an ATMega through a usb-to-serial adaptor connect to the RPI? Then you don't need to worry about level translation. A 5v or 3.3v USB-To-Serial adaptor will work, since the adaptor is a buffer between the two.

Passerby
  • 72,580
  • 7
  • 90
  • 202
  • So this cable is not 5V UART, it's just 5V tolerant and I can connect it to RasPi without issues? – Krzysztof Szynter Dec 14 '13 at 12:56
  • @qlf00n that specific cable is made for the RPI, so 3.3v serial connection with 5v tolerant inputs. The FT232 in general can be set up for 3.3v or 5v connections, with a couple of different variations. Generally, if you want to connect an ATMega to the RPI, you can use the serial connections (with level translation) or a usb to serial (Usb on the rpi, serial to the ATMega). – Passerby Dec 14 '13 at 13:04
  • Aaah, I was fixed on the idea connecting PC USB <-> RasPi serial, not RasPi USB <-> MCU serial. Now everything is clear, thank you! – Krzysztof Szynter Dec 14 '13 at 13:17
  • @qlfoon I think I might have been a bit unclear. That cable is meant for connecting the RPI serial, to another computer via usb. Regular FT232 cables can be used for RPI USB to another serial device. What do you want to connect together? – Passerby Dec 14 '13 at 13:30
  • I was thinking about having a possibility to connect laptop's USB to MCU / RasPi serial pins. That's why I asked about using USB to RS in the first place. In the end I also asked about connecting RasPi to MCU directly sensing it may not be so simple by with some luck I would not need to order a cable. Anyway, your details helped me a lot and digging more in the datasheet I think I will go with the TTL-232RG-VIP-WE cable version. This will allow me using the cable in different scenarios and for all logic levels using red wire as a reference voltage. Correct me if I'am wrong please. – Krzysztof Szynter Dec 14 '13 at 13:35
  • 1
    @qlf00n yes, that one is very good if you want to use the same cable on different voltage levels. Tie the VCCIO Red cable to the 3.3v of the RPI's serial, or the 5v of an ATMEga or whatever. – Passerby Dec 14 '13 at 14:15