3

I am using Digispark ATTiny85 and i need to send and receive data through the serial port of my computer. Does anyone have an idea as to how do i proceed with sending STRINGS and NUMBERS through the serial port ??

I have read that the ATTINY 85 does not have a serial port. If that is the case is there any alternative ??

Code Gorilla
  • 5,652
  • 1
  • 17
  • 31
Karan Motiramani
  • 39
  • 1
  • 1
  • 3

5 Answers5

4

You may use DigiCDC to virtually create a serial device. It's slow but does the job.

A serial-echo program would look something like this:

#include <DigiCDC.h>

void setup() { SerialUSB.begin(); }

// the loop routine runs over and over again forever: void loop() {

if (SerialUSB.available()) { SerialUSB.write(SerialUSB.read()); }

//SerialUSB.delay(10); /* if you don't call a SerialUSB function (write, print, read, available, etc) every 10ms or less then you must throw in some SerialUSB.refresh(); for the USB to keep alive - also replace your delays - ie. delay(100); with SerialUSB.delays ie. SerialUSB.delay(100); */ }

waqaslam
  • 141
  • 5
1

have read that the ATTINY 85 does not have a serial port.

It depends on your definition of serial port.

From a hardware perspective it has a usi. That can be configured as a uart. Whether it fits your need or not is up to your application. Read the datasheet to be sure.

dannyf
  • 2,813
  • 11
  • 13
0

The ATTiny85 does not have a hardware serial port, but you can use the Arduino SoftSerial library to implement a serial port in software. Have a look at SoftSerial. Or for better performance, including full duplex operation (transmit and receive at the same time) this may be better.

Steve G
  • 126
  • 3
0

You have a number of options.

  1. Go the DigiCDC/SerialUSB path. Or whatever replaces it.

  2. (harder), use an I2C to serial bridge, SC16IS750. This has a 64 byte buffer limit so input should be short, typically [Esc] or "U" (for firmware update), but basic menu control is possible.

  3. Use SendOnlySoftwareSerial, on a free pin as Tx and hook up an FTDI cable or a serial to USB adapter. This is good for PuTTy, Screen, MiniCom etc.

NB. I have no issues with blowing away the bootloader and just using the usb for power to get option 3 to work.

mckenzm
  • 191
  • 4
-1

Its quite simple, you need a program on your PC that will send data (that you type) to the serial port.

If you are on Windows then you want a 'Terminal Emulator' program, I don't know what its called on Linux but it will be along the same lines.

If you are using the Arduino IDE then there is already something built in, the Serial Monitor will do the job. You don't even need to be using the IDE for programming you should be able to use the monitor anyway.

Also you can write your own application to do it, but don't do that unless you really have to.

Code Gorilla
  • 5,652
  • 1
  • 17
  • 31