0
\$\begingroup\$

Alright, I know this question is pretty silly, but I have stumbled upon different posts saying opposing things. So to make a conclusion, does anyone knows for sure if it's possible to send data via serial communication to one of Attiny85 pins?

I would use CH340G to convert USB to serial from PC and then forward the info to Attiny85. Idea is to create a rather small device that could control 2-3 relays depending on the received commands. It would be nice that Attiny85 could reply to my requests and now just receive them (Rx/Tx) but Rx channel would work also.

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

For this simple task you can use a software UART like Here is an example.

SPI is rather unusual to use with a PC and makes control software more complicated and I understand you don't want that.

Not sure why you use USB to serial,you don't have an RS232 port or you find it"s TTL output handy. If you have an RS232 port on your PC you can use-it with some simple resistor level translator and inverting the RX input.

\$\endgroup\$
0
\$\begingroup\$

The Attiny85 doesn't have an UART (read its datasheet!).

Of course, for low rates, you can just use software running on the Attiny to sample any pin and decode classical UART communication. But that's bit of a hassle.

Instead, just not use the CH340 but any USB-to-Serial converter that offers SPI. SPI is a synchronous, two wire, bus and the Attiny has built-in support for it. Funnily, most USB-to-Serial ICs that I know can do SPI (it's really the simplest to implement serial bus I can think of), but the CH340 specifically can't. shrug

Anyway, if you want USB connectivity, just don't use an Attiny + USB converter, but one of the literal thousands of microcontrollers that include a USB interface. Personally, I don't think that a hobbyist has much demand for something as feature-deprived and small-memoried as the Attiny (you don't care for 2ct of component cost, do you?); go for an easy-to-program ARM Cortex-M chip. There's Arduino compatible ARM boards which are really cheap and it'd allow you to interact with a USB host directly.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Well I'm not looking for finished solution for prototyping, I'm looking for some rather simple uC with support for RS232/UART communication. Since my experience is so low with uC/communication protocols, I decided to use CH340G because it's USB CDC gets recognized by default Windows drivers (no additional driver installation is required, that's like limiting factor, if the controller is not recognized by default drivers it's a big no-no for me). I have absolutely no idea if any other USB-to-I2C/SPI controller gets recognized by Windows with default drivers... \$\endgroup\$ May 24, 2018 at 12:50
  • \$\begingroup\$ This "device" that I'm planning to make has to be recognized by Windows when plugged in and Windows has to assign it COM port through which i can send commands to control the behaviour of uC (depending on the command, several relays will get switched). It's planned for the device to have 3 relays so I don't need gazillion I/O ports. \$\endgroup\$ May 24, 2018 at 12:52
  • \$\begingroup\$ then simply go for any microcontroller with an UART: You'll have a hard time finding a microcontroller without one, aside from the attiny. Your component choice really hurts you here! \$\endgroup\$ May 24, 2018 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.