USB ATTiny85 comms vs. SoftwareSerial - Solved See post #48

This is my toe-in-the-water experience with ATTiny85.

long term goal – ATTiny responds to IR remote signals and turns on an LED for a set time.

short term goal – Give the Tiny a Serial.print capability for debugging.

In a bare minimum sketch with #include <SoftwareSerial.h>
SoftwareSerial will compile correctly with UNO selected as board.

When Digispark (Default – 16.5MHz) is set as the board compilation fails with message ‘No such file or directory’.

This is what I entered in the boards manager URL under the IDE file/preferences tab.

https://raw.githubusercontent.com/digistump/arduino-boards-index/master/package_digistump_index.json

I can load a sketch onto the Tiny and modify it.

My board:

The bare minimum code:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {

// put your setup code here, to run once:

}

void loop() {

// put your main code here, to run repeatedly:

}

If more is needed lemme know and I'll get on it.

I think tinyserial.h can be for ATtiny devices. GitHub - carloscn/tinyserial: Tiny Serial Open Source Project. · GitHub

It seems I'm still missing something.  Say I want the Tiny to print the value of some analog input value in the IDE serial monitor.  That's what I want to make happen.

For T85 I've always used Spence Konde's core, mostly successfully.
Additional Boards Manager URLs
http://drazzy.com/package_drazzy.com_index.json

Your board link to amazon.com just took me to the amazon home page - maybe because I'm in UK - but I assume you have the development board, not the chip?

If so, this is what I get from AI:

If your ATtiny85 is mounted on a Digispark development board (or an equivalent with a USB bootloader installed), you can use the Digispark board options:

Board Manager: Install the Digistump AVR boards package in your Arduino IDE using the Digistump Boards Index URL.

Settings: Select Digispark (Default - 16.5mhz) or whichever clock speed your hardware requires.

Upload Process: Do not plug the board in yet. Click the upload button in the IDE, wait for the prompt in the console to "Plug in device now" (you will have a 60-second window to do so), and then plug the Digispark board directly into your computer's USB port.

The following sketch compiles fine under:
Tool ----> Board: ----> ATTinyCore ----> ATtiny25/45/85 (No bootloader)

#include<SoftwareSerial.h>
SoftwareSerial SUART(1, 2);  //SRX = PB1 and STX = PB2

void setup()
{
  SUART.begin(9600);
}

void loop()
{

}

Note:
1. Use UNO R3 as an Arduino as ISP programmer
2. For debugging purposes, use a TTL<-----> USB converter to connect STX-pin with PC.
3. The attaced document may be helpful:
ProgrammingATtiny85 (5).pdf (172.6 KB)

What if you gave up two pins for I2C and used an OLED for your Serial Monitor?

I have amended the Amazon link in post #1 and also reproduce it here.

My board.

I'm still getting the feeling we're talking past each other. What I'd like to do, if possible, is this:

Initialization, setup, etc. then something like -

Serial.print(analog input 0);

I did see a YouTube video which has the Tiny talking via the Tx Rx pins on an UNO - which UNO is running the bare minimum sketch.

but it's no use if SoftwareSerial.h won't even compile.
......................................................................................

a. I don't have an OLED lying around - and never having used one before I'm not keen on an additional rabbit hole at this point.

  1. The monitor function is not needed in the final version.

Yes, I'm doing it the AI way. I also got a USB power switch to negate having to plug/unplug the board every programming cycle.

If you are using Digispark Attiny85 Deb board, then the attached file will be helpful for you to program it.
Ch-16 ATtiny85 MCULec.pdf (959.2 KB)

1. Build the following setup (Fig-1):


Figure-1:

2. Connect the ATtiny85 Dev Board with PC.
3. Check that the PC has recognized the ATtiny85 Dev bboard as USB device.
4. Engage the TTL<-------> USB connector with PC.
5. Go to Device Manager and chcek that the TTL<-----> USB adapter is recognized as a COM Port.

6. Select the ATtiny85 Dev board as:
Tools ---> Board:---->ATTinyCore-----> ATtiny85 (Micronucleus / Digospark)

7. Upload the following sketch (not tested):

#include <SoftwareSerial.h>
SoftwareSerial SUART(0, 1);  //SRX = 0 = PB1, STX = 1 = PB1

void setup()
{
     SUART.begin(9600);
}

void setup()
{
     int y = analogRead(A1);  //PB2
     SUART.println(y, DEC);
     delay(1000);
}

8. Open an Arduino IDE from Start. Check that the COM Port agrees with that shown by Device Manager.

9. Open Serial Monitor at Bd = 9600.

10. Slowly rotate the Pot and check that value in Serial Monitor changes.

Try this AI advice.

Because the board's core ATtiny85 microcontroller lacks a hardware UART port, software emulation is the only way to achieve standard serial communication. [1, 2, 3, 4]

When implementing Software Serial on this board, keep several critical architectural constraints in mind:

:hammer_and_wrench: Working with the Default Library

You can use the standard #include <SoftwareSerial.h> library included with the Arduino IDE. However, because the standard library creates a 64-byte receive buffer and completely disables interrupts while transmitting, it can consume a significant amount of the ATtiny85's limited 512 bytes of SRAM. [1, 2, 3]

:pushpin: Pin Availability Conflicts

The Digispark breaks out 6 General Purpose Input/Output (GPIO) pins (P0 to P5), but choosing your Serial RX/TX pins requires caution: [1, 2, 3]

  • P3 and P4: These pins are directly connected to the USB data lines ((D-) and (D+)) for programming. Connecting external serial devices to these pins during boot can interfere with uploading code or cause USB communication faults.
  • P5: This pin functions as the hardware Reset pin. Unless you burn specific fuses to change it to an I/O pin (which prevents you from easily re-programming the board via USB), its voltage restrictions make it difficult to use for serial data.
  • Best Practice: Use P0, P1, or P2 for your Software Serial communication to prevent interference with the USB upload process. [1, 2, 3, 4, 5]

:stopwatch: Clock Speed and Baud Rates

  • Frequency Adjustment: The default configuration of the Digispark runs at 16.5 MHz using its internal oscillator via the Micronucleus bootloader. If your baud rates exhibit timing drift or output garbage data, you may need to scale your project down to 8 MHz inside the Arduino IDE board manager to stabilize software-timed bit-banging.
  • Baud Limit: Keep your communication speeds low. While it can theoretically go higher, a baud rate of 9600 bps is highly recommended to prevent data corruption due to the un-clocked internal oscillator. [1, 2, 3, 4]

:light_bulb: Lightweight Alternatives

If you are running low on memory or only need to output debugging data, consider these alternative approaches:

  • Send-Only Libraries: Use a transmit-only library (such as SendOnlySoftwareSerial). It eliminates the memory overhead of a receive buffer and frees up one physical pin because it only requires a single TX pin.
  • DigiKeyboard: Instead of trying to open a standard serial monitor over USB, you can use the built-in DigiKeyboard.h library. This instructs the computer to recognize the Digispark as a USB keyboard. You can open an empty Notepad document, and the board will type out its sensor values or debug text directly into the file. [1, 2, 3, 4, 5]

Heading

Stopped here - output of ATTinyCore installation:

Tool arduino:avr-gcc@7.3.0-atmel3.6.1-arduino7 already installed
Downloading packages
arduino:avrdude@6.3.0-arduino18
ATTinyCore:micronucleus@2.5-azd1b
Failed to install platform: 'ATTinyCore:avr:1.5.2'.
Error: 2 UNKNOWN: Get "https://azduino.com/bin/micronucleus/micronucleus-cli-2.5-azd1b-x86_64-mingw32.zip": dial tcp 3.218.2.136:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Output:

In file included from C:\Users\User\OneDrive\Documents\Arduino\blink_tiny85_2\blink_tiny85_2.ino:25:0:
c:\Users\User\OneDrive\Documents\Arduino\libraries\SendOnlySerial\src/SendOnlySerial.h:67:2: error: #error “SendOnlySerial only supports boards with AVR ATmega168A/PA/328/P/PB processor.”
#error “SendOnlySerial only supports boards with AVR ATmega168A/PA/328/P/PB processor.”

exit status 1

Compilation error: exit status 1

I've noticed other send only libraries. I'm off to search.

I have given a working Tutorial in post #9. Tell me in what step you are failing.

Fails here:

Figure-19.5: Scemtaic of Digispark ATtiny85 Dev Board
The procedures of the operation of Digospark ATtiny85 Dev Board are: For the schematic of
Digispark Board, see Section-19.4.4.
(1) Installtion of ATTinyCore Package
Follow the steps of Section-19.2.1.(1)(a)(b).

The section referenced is:

The core allows to select ATtiny85 as a Board; as a result, sketch can be created using
Arduino IDE. The Core can be installed this way:
(a) Open the Arduino IDE and on the main menu, select Files -> Preferences. In
the Additional Boards Manager URLs textbox, type this URL:
http://drazzy.com/package_drazzy.com_index.json, and then press the OK button.
(b) Perform this task: Tools  Board:  Boards Manager…  click. When the Borads

Installation of Drazzy core fails.

Failed to install platform: 'ATTinyCore:avr:1.5.2'.
Error: 2 UNKNOWN: Get "https://azduino.com/bin/micronucleus/micronucleus-cli-2.5-azd1b-x86_64-mingw32.zip": dial tcp 3.218.2.136:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Which step number -- 1 or 2, ... of post #9?

Do you think that the Digispark ATtiny85 Dev board's bootloader contains Keyboard emulation code so that the chip will start communicaton with a Notepad window opened in PC? Please, check if you have hardware.

@dougp

If you are facing problem with Digispark board, then go with stand-alone project using ATtiny85. Here, you need to use a seperate Programmer to upload sketch into ATtny85. And you must know the fuse vlaues of your MCU to figue out the internal configuration -- internal clock or not and etc.

I do not have a T85 Digispark development board.

Are you deeply committed to using that relatively rare board? You will find much more help here if you buy a few T85 8-pin chips and learn how to upload sketches to those.

EDIT: Sorry, the above was of course intended for @dougp

I have Digispark board and this board does not support upstreaming. It is not included because of low amount of flash of ATtiny85. You can use the STX to display debugging message or use the onboard led to indicate the nature of error in the executing code.

Yes i have the same issue. (on a secondary PC, on my laptop it is installed and working) It is a known problem with the core repository. You can get it to work by doing a manual install of the core i think.

The maintainer has just simply run out of time and motivation. Taking over the core maintenance from others.
The complete re-write is still incomplete.

The manual install works as i have just completed it.

Download the core ZIP file from here

Go to your sketchbook folder and create a folder called 'hardware' if it does not already exists
navigate to that folder and extract the contents of the downloaded ZIP file into it.
Restart the IDE (i tend to close the IDE before i start and open when i finish)
The core should now be installed to be used.