Solving multiple definitions with TinyWireM and DigisparkOLED

Hi guys.

Can somebody help me solve this multiple definitions errors? I understand in general, what this means, but I don't know why or when this happens.

Let me start with what works:

#include <Wire.h>
#include <DigisparkOLED.h>

when using the Digispark Pro as the selected board. Inside DigisparkOLED.h Wire.h is included, too! No problems here!

But for the Digispark (not Pro) I have to use TinyWireM.h because of space. And because I think, it's not good to have Wire and TinyWire at the same time, I made a copy of the DigisparkOLED library, named it TinyOLED and put it into a separate folder in my custom libraries. So inside this there are 2 files TinyOLED.h and TinyOLED.cpp. I exchanged Wire with TinyWireM whereever necessary in those files.

Now, when I do

#include <TinyWireM.h>
#include <TinyOLED.h>

and switch the board to the Digispark, I get a lot of errors for multiple definitions in DigisparkOLED.cpp, TinyOLED.cpp and also between the Wire library and TinyWireM. Those had no problems before! For example it's complaining about SSD1306Device::SSD1306Device() being defined in DigisparkOLED and my TinyOLED.

Why in hell is this sketch accessing DigisparkOLED and Wire in the first place? I have not included them! And why is there this problem, while the first example has no problems with multiple definitions? And can't there be 2 libraries using the same class name by accident?

One thing: I need TinyWireM in my sketch, too, so I need to include it.

Is Digistump the maker of the Digispark ?

Digispark: ATtiny85 running the Micronucleus bootloader with V-USB.
Digispark Pro: ATtiny87 or ATtiny167

You should have bought a Arduino board. The V-USB was no longer needed when the Arduino Leonardo was introduced. Look how small a "Pro Micro" is, that is a mini version of the Leonardo boards.

Digistump has its own build environment.
I think that was maintained up to 6 years ago.
There might be more than just a few compatibility issues. If you show all your files, someone might install that build environment and try it. But not me, sorry, I don't like those board. I don't want to take a leap 10 years back and experience all those troubles that I had then with weird boards and custom bootloaders.
Are you a beginner ? Then start with something that works.

My advice is to use a official Arduino board or even a clone of a official Arduino board. You will have the newest bootloader and the latest bug fixes and a community that will help.

Thanks for the input. I am not really a beginner, I have finished a hand full of small projects with either Digispark or Digispark Pro. The Pro boards I have use the ATtiny167. The current problems are not really board related, because the errors occurr already on compile, when the board is not even plugged in. I don't know the parameters that change in the background when switching the board type in the IDE, but in general this library / include stuff should work in either config, right?

I uploaded project + libs. This Boards Manager URL is needed for all the Digistump AVR boards http://www.digistump.com/package_digistump_index.json
I anyone could try it - would be great!

I got it right... Only mistake was, not to copy font6x8.h and font8x16.h into the new lib folder :roll_eyes: This must have caused the IDE to search for them and while doing so, it came across the not included other libs, which made me confused. With those additional 2 header files, I can now use TinyOLED and TinyWireM in the same Sketch.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.