PlatformIO Community

I'm in trouble with TinyWireM

Greetings!

I’m new in this community, but I hope there’re a lot of helpful people around here.
I use PIO with Visual Studi Code, and I had to change my Arduino ADK board to Arduino Mega 2560, and rewired it, because ADK has died.
So I simply changed my platfomr.ini for this:
platfomrio.ini
The platform_packages =

  • ; use GCC AVR 7.3.0+*
  • toolchain-atmelavr@>=1.70300.0*

is for FASTLED library.

So, after that I rebuild my project, and I got these nice errors. I guess the problem is with the adafruit RTC library…
Could somebody help me out?
I tried reinstall PIO, PIO core, Visual studio code, but noone of them helped me out.

Thx,
Daniel

1 Like

Can you give your full platformio.ini? It seems that the error just lies in the TinyWireM library being incompatible with your target, which is included by the RTC library.

Edit: Actually I don’t see why a Mega2560 would need that library at all, since it’s written for ATtiny chips. I suggest you try adding

lib_ignore = TinyWireM

to the platformio.ini.

1 Like

Hi!
I linked it before, but here is my modified platformio.ini (I added that you suggested), but then it stops at rtc.begin();

;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:megaatmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino
lib_deps =
     FastLED
platform_packages =
  ; use GCC AVR 7.3.0+
  toolchain-atmelavr@>=1.70300.0
monitor_speed = 115200
upload_port = COM13
monitor_port = COM13
lib_ignore = TinyWireM

Since it’s compiling now that’s one error less. PlatformIO tries to include TinyWireM because

and without lib_ldf_mode set to deep+ or chain+, it doesn’t evaluate the #ifdef macro (docs).

What does “stop” mean exactly? No more output? What exact code are you running?

Can you test only the RTClib with its minimal example sketch first (https://platformio.org/lib/show/83/RTClib) to see whether the library works with your hardware ok?

I’ll test them that you suggested. But I’ve already commented

/*#ifdef __AVR_ATtiny85__
37. #include <TinyWireM.h>
38. #define Wire TinyWireM
39. #else*/
40. #include <Wire.h>
//41. #endif

The PIO says

> Executing task in folder ArduinoMegaGate: C:\Users\dani\.platformio\penv\Scripts\platformio.exe run <


Processing megaatmega2560 (platform: atmelavr; board: megaatmega2560; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/megaatmega2560.html
PLATFORM: Atmel AVR 2.0.0 > Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)
HARDWARE: ATMEGA2560 16MHz, 8KB RAM, 248KB Flash
PACKAGES:
 - framework-arduino-avr 5.0.0
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 15 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <FastLED> 3.3.3
|   |-- <SPI> 1.0
|   |-- <SoftwareSerial> 1.0
|-- <SparkFun Qwiic RFID Arduino Library> 1.1.6
|   |-- <Wire> 1.0
|-- <Adafruit PN532> 1.2.0
|   |-- <Adafruit BusIO> 1.2.3
|   |   |-- <SPI> 1.0
|   |   |-- <Wire> 1.0
|   |-- <SPI> 1.0
|   |-- <Wire> 1.0
|-- <SoftwareSerial> 1.0
|-- <SPI> 1.0
|-- <Wire> 1.0
Building in release mode
Compiling .pio\build\megaatmega2560\src\ArduinoMegaGate.cpp.o
Archiving .pio\build\megaatmega2560\lib16d\libSPI.a
Archiving .pio\build\megaatmega2560\libdc1\libSoftwareSerial.a
Archiving .pio\build\megaatmega2560\lib3f0\libWire.a
Compiling .pio\build\megaatmega2560\libd43\SparkFun Qwiic RFID Arduino Library_ID6562\SparkFun_Qwiic_Rfid.cpp.o
Compiling .pio\build\megaatmega2560\lib2b4\Adafruit BusIO_ID6214\Adafruit_BusIO_Register.cpp.o
Compiling .pio\build\megaatmega2560\lib2b4\Adafruit BusIO_ID6214\Adafruit_I2CDevice.cpp.o
Compiling .pio\build\megaatmega2560\lib2b4\Adafruit BusIO_ID6214\Adafruit_SPIDevice.cpp.o
Compiling .pio\build\megaatmega2560\lib1fb\Adafruit PN532_ID29\Adafruit_PN532.cpp.o
Archiving .pio\build\megaatmega2560\libFrameworkArduinoVariant.a
src\ArduinoMegaGate.cpp:11:10: fatal error: RTClib.h: No such file or directory

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

Compiling .pio\build\megaatmega2560\FrameworkArduino\CDC.cpp.o
 #include <RTClib.h>
          ^~~~~~~~~~
compilation terminated.
C:\Users\dani\.platformio\lib\SparkFun Qwiic RFID Arduino Library_ID6562\src\SparkFun_Qwiic_Rfid.cpp: In member function 'void Qwiic_Rfid::_readTagTime(uint8_t)':
C:\Users\dani\.platformio\lib\SparkFun Qwiic RFID Arduino Library_ID6562\src\SparkFun_Qwiic_Rfid.cpp:194:46: warning: left shift count >= width of type [-Wshift-count-overflow]
     _tempTime  = int32_t(_i2cPort->read() << 24);
                                              ^~
C:\Users\dani\.platformio\lib\SparkFun Qwiic RFID Arduino Library_ID6562\src\SparkFun_Qwiic_Rfid.cpp:195:46: warning: left shift count >= width of type [-Wshift-count-overflow]
     _tempTime |= int32_t(_i2cPort->read() << 16);
                                              ^~
C:\Users\dani\.platformio\lib\SparkFun Qwiic RFID Arduino Library_ID6562\src\SparkFun_Qwiic_Rfid.cpp: In member function 'void Qwiic_Rfid::_readAllTagsTimes(uint8_t)':
C:\Users\dani\.platformio\lib\SparkFun Qwiic RFID Arduino Library_ID6562\src\SparkFun_Qwiic_Rfid.cpp:250:47: warning: left shift count >= width of type [-Wshift-count-overflow]
       _tempTime = int32_t(_i2cPort->read() << 24);
                                               ^~
C:\Users\dani\.platformio\lib\SparkFun Qwiic RFID Arduino Library_ID6562\src\SparkFun_Qwiic_Rfid.cpp:251:48: warning: left shift count >= width of type [-Wshift-count-overflow]
       _tempTime |= int32_t(_i2cPort->read() << 16);
                                                ^~
*** [.pio\build\megaatmega2560\src\ArduinoMegaGate.cpp.o] Error 1
C:\Users\dani\.platformio\lib\Adafruit PN532_ID29\Adafruit_PN532.cpp: In member function 'void Adafruit_PN532::readdata(uint8_t*, uint8_t)':
C:\Users\dani\.platformio\lib\Adafruit PN532_ID29\Adafruit_PN532.cpp:1534:14: warning: unused variable 'timer' [-Wunused-variable]
     uint16_t timer = 0;
              ^~~~~
==================================================================================================================================================================================== [FAILED] Took 1.46 seconds ====================================================================================================================================================================================
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

Commenting it out shouldn’t be necessary if either the library is ignored via lib_ignore or lib_ldf_mode = chain+ is set.

Your new compilation is missing the RTClib as a dendency. You should explicitly declare it in a lib_deps statement (docs)

Stop means it never reaches line 51 or 55
Here is my setup code: https://pastebin.com/ikAqC2St

If I use lib_ignore=TinyWireM the building and the uploading is success, but the program never reaches line 51 or 55… :frowning:

I tested the code that you linked on arduino uno.
it uploaded.
Here the output:
dt0 2000/1/1 0 hours 42 minutes 42 seconds (2562 total seconds)
days 0 hours 0 minutes 0 seconds (26179200 total seconds)
dt10-dt6 0 days 0 hours 42 minutes 42 seconds (2562 total seconds)
dt0 2000/1/1 0:0:0 = 946684800s / 10957d since 1970
dt1 2001/1/1 0:0:0 = 978307200s / 11323d since 1970
dt2 2009/1/1 0:0:0 = 1230768000s / 14245d since 1970
dt3 2009/1/2 0:0:0 = 1230854400s / 14246d since 1970
dt4 2009/1/27 0:0:0 = 1233014400s / 14271d since 1970
dt5 2009/2/27 0:0:0 = 1235692800s / 14302d since 1970
dt6 2009/12/27 0:0:0 = 1261872000s / 14605d since 1970
dt7 2009/12/27 1:0:0 = 1261875600s / 14605d since 1970
dt7.5 2009/12/27 1:0:0 = 1261875600s / 14605d since 1970
dt8 2009/12/28 0:0:0 = 1261958400s / 14606d since 1970
dt8.5 2009/12/28 0:0:0 = 1261958400s / 14606d since 1970
dt9 2010/1/3 0:0:0 = 1262476800s / 14612d since 1970
dt9.5 2010/1/3 0:0:0 = 1262476800s / 14612d since 1970
dt10 2009/12/27 0:42:42 = 1261874562s / 14605d since 1970
dt11 2009/12/20 0:0:0 = 1261267200s / 14598d since 1970
dt6-dt5 303 days 0 hours 0 minutes 0 seconds (26179200 total seconds)
dt10-dt6 0 days 0 hours 42 minutes 42 seconds (2562 total seconds)

But the RTClib example code does not run on the target ATMega2560?

It runs on Mega too.

Here is the output:
dt0 2000/1/1 0:0:0 = 946684800s / 10957d since 1970
dt1 2001/1/1 0:0:0 = 978307200s / 11323d since 1970
dt2 2009/1/1 0:0:0 = 1230768000s / 14245d since 1970
dt3 2009/1/2 0:0:0 = 1230854400s / 14246d since 1970
dt4 2009/1/27 0:0:0 = 1233014400s / 14271d since 1970
dt5 2009/2/27 0:0:0 = 1235692800s / 14302d since 1970
dt6 2009/12/27 0:0:0 = 1261872000s / 14605d since 1970
dt7 2009/12/27 1:0:0 = 1261875600s / 14605d since 1970
dt7.5 2009/12/27 1:0:0 = 1261875600s / 14605d since 1970
dt8 2009/12/28 0:0:0 = 1261958400s / 14606d since 1970
dt8.5 2009/12/28 0:0:0 = 1261958400s / 14606d since 1970
dt9 2010/1/3 0:0:0 = 1262476800s / 14612d since 1970
dt9.5 2010/1/3 0:0:0 = 1262476800s / 14612d since 1970
dt10 2009/12/27 0:42:42 = 1261874562s / 14605d since 1970
dt11 2009/12/20 0:0:0 = 1261267200s / 14598d since 1970
dt6-dt5 303 days 0 hours 0 minutes 0 seconds (26179200 total seconds)
dt10-dt6 0 days 0 hours 42 minutes 42 seconds (2562 total seconds)

It looks like all of the problems were solved. =)

A failed RTC (ds3231) modul was guilty. It communicates via I2C and thus it affected my whole I2C communication… I changed it, and now it’s working perfectly. :slight_smile:
Anyway, thank you for your help.

1 Like