PlatformIO Community

Help Importing Arduino ATtiny85 Sketch with SendOnlySoftwareSerial

I’m new to PlatformIO.

I am trying to import a simple Arduino sketch for Atiny85 but want to include the SendOnlySoftwareSerial library. There are other libraries I also want to use but I thought I’d start with this one as it allows me some debug output on a single pin. Up to now I have dodged the issue by putting all the Arduino library stuff in conditional compile sections, writing (and test compiling) the code in PlatformIO and then doing a final compile in Arduino IDE. This is hard work and I believe I can achieve all this within PlatformIO - I just need help getting started.

Before I opened this topic, I did look at the ‘sounds like a similar’ list of topics and also some postings of how not to manually import Arduino libraries - I have tried a few of these methods but failed here too. Below is the nearest I believe I have come to achieving my goal but I need a bit of help.

The sketch below works if compiled and loaded via Arduino IDE

// ATtiny85SendOnlySoftwareSerial
// Test Arduino sketch to import into PlatformIO

#include <SendOnlySoftwareSerial.h>
#define BAUD 9600                       // Check fuse CKDIV8 is un-programmed on ATtiny85
SendOnlySoftwareSerial mySerial (PB1);  // Tx pin

/*                                ATtiny85
        PCINT5/-RESET/ACD0/dw PB5 1| u |8 VCC
 PCINT3/XTAL1/CLKI/-OC1B/ADC3 PB3 2|   |7 PB2 SCK/USCK/SCL/ADC1/T0/INT0/PCINT2
  PCINT4/XTAL2/CLKO/OC1B/ADC2 PB4 3|   |6 PB1 MISO/DO/AIN1/OC0B/OC1A/PCINT1
                              GND 4|___|5 PB0 MOSI/DI/SDA/AIN0/OC0A/-OC1A/AREF/PCINT0

 PB0 - 
 PB1 - TTY output
 PB2 - 
 PB3 - 
 PB4 - 
 PB5 - (RESET)
*/
 
void setup() {
  // put your setup code here, to run once:
  DDRB |= (1<<PB1);
  mySerial.begin(BAUD);
  mySerial.println(F("\n\r\n\rStarting"));
}

void loop() {
  // put your main code here, to run repeatedly:
  mySerial.print(F("."));
  delay(100);
}

My first attempt at a build on PlatformIO yielded

 *  Executing task in folder 221022-113635-attiny85: C:\Users\Peter\.platformio\penv\Scripts\platformio.exe run 

Processing attiny85 (platform: atmelavr; board: attiny85; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/attiny85.html
PLATFORM: Atmel AVR (3.4.0) > Generic ATtiny85
HARDWARE: ATTINY85 8MHz, 512B RAM, 8KB Flash  
DEBUG: Current (simavr) On-board (simavr)     
PACKAGES:
 - framework-arduino-avr-attiny @ 1.5.2       
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
Converting ATtiny85SendOnlySoftwareSerial.ino 
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 9 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\attiny85\src\ATtiny85SendOnlySoftwareSerial.ino.cpp.o
Archiving .pio\build\attiny85\libFrameworkArduinoVariant.a
Compiling .pio\build\attiny85\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\attiny85\FrameworkArduino\Print.cpp.o
Compiling .pio\build\attiny85\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\attiny85\FrameworkArduino\TinySoftwareSerial.cpp.o
Compiling .pio\build\attiny85\FrameworkArduino\Tone.cpp.o
Compiling .pio\build\attiny85\FrameworkArduino\WInterrupts.c.o
D:/Users/Peter/Documents/PlatformIO/Projects/221022-113635-attiny85/src/ATtiny85SendOnlySoftwareSerial.ino:4:10: fatal error: SendOnlySoftwareSerial.h: No such file or directory

********************************************************************************
* Looking for SendOnlySoftwareSerial.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SendOnlySoftwareSerial.h"
* Web  > https://registry.platformio.org/search?q=header:SendOnlySoftwareSerial.h
*
********************************************************************************

 #include <SendOnlySoftwareSerial.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\attiny85\src\ATtiny85SendOnlySoftwareSerial.ino.cpp.o] Error 1
========================================================= [FAILED] Took 3.11 seconds =========================================================

 *  The terminal process "C:\Users\Peter\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

So I checked your library registry as suggested and it found SendOnlySoftwareSerial.h lurking in

ingarage/Maker PlayGround Device

To install this I added a line to the lib_deps section of my platformio.ini which now looks like

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:attiny85]
platform = atmelavr
board = attiny85
framework = arduino
lib_deps = ingarage/Maker PlayGround Device@^1.0.0

I understand that this means any new copies of the library that are back wards compatible with v 1.0.0 will be used.

I did another build with the following output

 *  The terminal process "C:\Users\Peter\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task in folder 221022-113635-attiny85: C:\Users\Peter\.platformio\penv\Scripts\platformio.exe run 

Processing attiny85 (platform: atmelavr; board: attiny85; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------Library Manager: Installing ingarage/Maker PlayGround Device @ ^1.0.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Library Manager: Maker PlayGround Device@1.0.0 has been installed!
Library Manager: Resolving dependencies...
Library Manager: Installing git+https://github.com/adafruit/Adafruit_Motor_Shield_V2_Library.git#1.0.4
Error: Please install Git client from https://git-scm.com/downloads

 *  The terminal process "C:\Users\Peter\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

I then attempted to install v 2.38.1 of Git and this is the step I think I got wrong because now on doing a build I still get the following output

 *  Executing task in folder 221022-113635-attiny85: C:\Users\Peter\.platformio\penv\Scripts\platformio.exe run 

Processing attiny85 (platform: atmelavr; board: attiny85; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------Library Manager: Installing git+https://github.com/adafruit/Adafruit_Motor_Shield_V2_Library.git#1.0.4
Error: Please install Git client from https://git-scm.com/downloads

 *  The terminal process "C:\Users\Peter\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

What do I need to do to install the Git client having installed Git by executing the download “Git-2.38.1-64-bit.exe”?

Time passes - I decided to restart PlatformIO and try again - Now I get a slightly different error

 *  Executing task in folder 221022-113635-attiny85: C:\Users\Peter\.platformio\penv\Scripts\platformio.exe run 

Processing attiny85 (platform: atmelavr; board: attiny85; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------Library Manager: Installing git+https://github.com/adafruit/Adafruit_L3GD20_U.git#1.1.0
git version 2.38.1.windows.1
Cloning into 'C:\Users\Peter\.platformio\.cache\tmp\pkg-installing-wb_sw5bh'...
warning: Could not find remote branch 1.1.0 to clone.
fatal: Remote branch 1.1.0 not found in upstream origin
Error: VCS: Could not process command ['git', 'clone', '--recursive', '--depth', '1', '--branch', '1.1.0', 'https://github.com/adafruit/Adafruit_L3GD20_U.git', 'C:\\Users\\Peter\\.platformio\\.cache\\tmp\\pkg-installing-wb_sw5bh']

 *  The terminal process "C:\Users\Peter\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

So it looks like Git 2.38.1 is loaded but … - any ideas?

If I look in the src folder below Maker PlayGround Device in the libdeps\attiny85 folder within .pio under my project (below) (but why all the references to Adafruit libraries??)
PIO_A

I can see the library I am using but this seems to have an issue opening the .h file - is this getting closer to the problem? - I don’t understand how to respond to the ‘Please update your includeOPath’

Here’s an image of the above
PIO_B

Time passes
I think I corrected the issue above by right clicking the error message and (can’t exactly remember now) updated the include path - I think. Anyway this looks different now, the error message and squiggle have gone
PIO_C

But I am still left with the ‘Remote branch not found’ error below on build.

 *  Executing task in folder 221022-113635-attiny85: C:\Users\Peter\.platformio\penv\Scripts\platformio.exe run 

Processing attiny85 (platform: atmelavr; board: attiny85; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------Library Manager: Installing git+https://github.com/adafruit/Adafruit_L3GD20_U.git#1.1.0
git version 2.38.1.windows.1
Cloning into 'C:\Users\Peter\.platformio\.cache\tmp\pkg-installing-_x0wsrjd'...
warning: Could not find remote branch 1.1.0 to clone.
fatal: Remote branch 1.1.0 not found in upstream origin
Error: VCS: Could not process command ['git', 'clone', '--recursive', '--depth', '1', '--branch', '1.1.0', 'https://github.com/adafruit/Adafruit_L3GD20_U.git', 'C:\\Users\\Peter\\.platformio\\.cache\\tmp\\pkg-installing-_x0wsrjd']

 *  The terminal process "C:\Users\Peter\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

Version 1.1.0 no longer exists. There are these:

  • 1.0.0
  • 1.0.1
  • 2.0.0 (possibly with a bug)
  • 2.0.1 (bug fixed)

You can see them all here: Releases · adafruit/Adafruit_L3GD20_U · GitHub

Try 2.0.1 but be aware that 2.0.0 onwards may have backeard compatability problems, according to that page I linked.

Cheers,
Norm.

Hi Norman
Thank you for your time and reply but please may we take a step back.
What at version 1.1.0 no longer exists? The line above this error message was talking about Cloning into 'C:\Users\Peter\.platformio\.cache\tmp\pkg-installing-_x0wsrjd'...
The link to Releases · adafruit/Adafruit_L3GD20_U · GitHub has files like Adafruit_LGG20.h What has this got to do with the SendOnlySoftwareSerial.h library I am trying to include.

What should I be doing with the suggested 2.0.1 version download Adafruit_L3GD20_U-2.0.1.zip?

I appreciate I have much to learn - I don’t understand the nuts and bolts of what’s happening - or not in my case.

How do I update the library reference in libdeps\attiny58 folder to be the 2.0.1 version I just downloaded?

Best regards
Peter

Ok, stepping back. Sorry, my apologies for getting ahead of myself.

This is the error message:

warning: Could not find remote branch 1.1.0 to clone.

And a couple of lines later, the failing command is listed:

fatal: Remote branch 1.1.0 not found in upstream origin
Error: VCS: Could not process command ['git', 'clone', '--recursive', '--depth', '1', '--branch', '1.1.0', 'https://github.com/adafruit/Adafruit_L3GD20_U.git', 'C:\\Users\\Peter\\.platformio\\.cache\\tmp\\pkg-installing-_x0wsrjd']

So, a git clone of the library “Adafruit_L3GD20_U” has failed, why? Because branch 1.1.0 doesn’t exist. (Any longer?). I simply ent to the afore mntioned github and checked the release versions, and branches. The releases I’ve already listed, but the branches are looking remarkably like there has been a merge and this might be why you can’t install.

Can you please post the lib_deps section of your platfomio.ini pleade? You can paste the text between triple back-ticks as per:

```
Paste text here.
```

Thanks.

Well, you posted this as the remaining error, I thought from that that you hd resolved the softwareserial problem. But before we proceed, we should fix this library problem while we can.

Cheers,
Norm.

Thanks for your patience Norm, I appreciate it as a newbie.
Here’s my platformio.ini again (as in original post).

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:attiny85]
platform = atmelavr
board = attiny85
framework = arduino
lib_deps = ingarage/Maker PlayGround Device@^1.0.0

I only added the lib_deps line as it was suggested in the error section of the original error I had (also previously posted but here again).

********************************************************************************
* Looking for SendOnlySoftwareSerial.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SendOnlySoftwareSerial.h"
* Web  > https://registry.platformio.org/search?q=header:SendOnlySoftwareSerial.h
*
********************************************************************************

I checked the library register by accessing the suggested Web link https://registry.platformio.org/search?q=header:SendOnlySoftwareSerial.h

My SendOnlySoftwareSerial library is contained in the ingarage/Maker PlayGround Device

Clicking this entry https://registry.platformio.org/libraries/ingarage/Maker%20PlayGround%20Device
and then selecting the Installation tab, it suggested I add the line ingarage/Maker PlayGround Device@^1.0.0 to the lib_deps option of my [env:] section.

I did that which is when I got the Error: Please install Git client from https://git-scm.com/downloads

I believe I installed this - still didn’t work at first but then I restarted PlatfiormIO and am where we are.

I only need the SendOnlySoftwareSerial library which is in > Maker Playground Device (see picture).
Can I resolve my issue by simply deleting all the Adafruit libdeps?
PIO_D

Best regards Peter

No problem. I was a newbie once, and to be honest, I still am with a lot of these controller boards. I’m more of an Arduino (and ATtiny85) man myself. I haven’t got my head around the 8266, STM32 and various ARM boards. Yet!

This is, I have found, to get hold of the SendOnlySoftwareSerial library, however I notice that there is a lot more stuff that is included with that library. Some of which appears to be Adafruit amongst others.

I’ve been able to reproduce the errors you have been getting and I thing the reason is because the github repository that SendOnlySoftwareSerial is found in, is over 7 years old. When you added that to lib_deps it tried to install all the libraries in the repo. At least, I think that’s what it did.

The project I created is a very simple one, based on the ATtiny85 and SendOnlySoftwareSerial, this is it:

#include "Arduino.h"
#include "SendOnlySoftwareSerial.h"

int main() {

    SendOnlySoftwareSerial fred(2);
    fred.begin(9600);
    while (true) {
        fred.write('A');
        fred.write('B');
    }
}

Yet, when I compile it, it pulls in all sorts of motor controlling libraries and such like, from Adafruit, before barfing with exactly the same error as yours:

Error: VCS: Could not process command ['git', 'clone', '--recursive', '--depth', '1', '--branch', '1.1.0', 'https://github.com/adafruit/Adafruit_L3GD20_U.git', '/home/norman/.platformio/.cache/tmp/pkg-installing-j10tjj_b']

So to get a clean compile, I did the following:

  • I downloaded the most recent release of the Maker PlayGround Device library, it’s dated 2018, from https://github.com/InGarage/MakerPlayGround_Library_Arduino/archive/refs/tags/emergency.zip and saved the file in a temporary location. It arrives as emergency.zip.
  • Unzipped emergency.zip. This created a directory named MakerPlayGround_Library_Arduino-emergency and in there, a src directory.
  • I created a folder in my project’s lib folder, named SendOnlySoftwareSerial – but I could have called it anything.
  • I copied the two SendOnlySoftwareSerial files into this new directory from the location where I unzipped emergency.zip.
  • I removed, with great prejudice, the .pio folder in my project, and everything in it. A “clean” operation would have done, but I like the full nuclear option occasionally! :wink:
  • I edited platformio.ini to remove ingarage/Maker PlayGround Device@^1.0.0 from lib_deps. If lib_deps is now empty, just delete the line.

Now, when I compile my silly little project, I get a clean compile!

My project structure is:

testSendOnly
├── include
│   └── README
├── lib
│   ├── README
│   └── SendOnlySoftwareSerial
│       ├── SendOnlySoftwareSerial.cpp
│       └── SendOnlySoftwareSerial.h
├── platformio.ini
├── src
│   └── main.cpp
└── test
    └── README

I haven’t tested anything yet, I’m a bit short on ATtiny85s at the moment, but I managed to compile the code and get rid of all the additional stuff that including that github repository insisted on bringing in, even though it wasn’t needed.

HTH

Cheers,
Norm.

PS.

This is because some of the other stuff, that is included with the “ingarage” library is well out of date. The required (at that time) repositories are no longer present.

Cheers,
Norm.

Hi Norm
Thanks - I’ll be working on this and confirm outcome.
Best regards
Peter

1 Like

Hi Norm
Thank you so much.
I now have a small prog that compiles - a winner for me is it uses an Arduino library - in this case SendOnlySoftwareSerial.h. I’ll be moving away from Studio7 from now on and dropping the conditional compile sections to jump round the Arduino stuff that I used to have to do.
I started again from scratch with a new project (didn’t bother trying to import an Arduino sketch), used the library instance you suggested but I don’t understand why I needed to delete the .pio section (It was rebuilt subsequently).
My ‘nothing’ prog that compiles OK now:

#include <Arduino.h>
#include <SendOnlySoftwareSerial.h>
#include <util/delay.h>
#define BAUD 9600                       // Check fuse CKDIV8 is un-programmed

int main(){
  SendOnlySoftwareSerial mySerial (PB1);  // Tx pin
  DDRB |= (1<<PB1);
  mySerial.begin(BAUD);
  mySerial.println(F("\n\r\n\rStarting"));

  while(1){
    mySerial.print(F("%"));
    _delay_ms(100);
  }
}

Now all I need to do is re-learn how to upload this as it’s been a while!!

How did you know where to look for the up to date library (I have a hunch I’ll need to do this again soon)?

Best regards Peter

I upload to the ATtiny85 by adding upload_protocol = usbtiny in my platformio.ini file, then click the upload option in VSCode, or the upload button on the lower toolbar in VSCode, or, in the command line, pio run --target upload.

Obviously if you don’t use a usbTinyIsp then change accordingly. You don’t have the option of a bootloader with the ATtiny85 as far as I remember.

The error message that you posted showed the failing command being executed by some Python code. I merely went to the GitHub URL and when there, looked for the named branch. It wasn’t there.

Simply to get rid of the half installed Adafruit libraries etc that you didn’t need and which, because they failed to install, meant that you didn’t get the SendOnlySoftwareSerial files that you needed, which was why the #include of the header didn’t work as the file wasn’t downloaded.

Glad you got things sorted out. Have fun.

Cheers,
Norm.

PS. https://docs.platformio.org has the latest docs and explains all about uploading to various devices.

Hi Norm
Many thanks - I see now how you targeted the missing branch issue - I failed to scroll right through the error message far enough - doh!
Thanks for the reminder on uploading - I’ve now successfully test uploaded using an Arduino Uno as ISP, a USBASP V2.0 (with updated firmware care of https://www.fischl.de/usbasp/ and a Pololu USB AVR Programmer V2.1.

1 Like