Go Down

Topic: Wire Library for WiFi Rev2 compatibility issues (Read 515 times) previous topic - next topic

goomung

I am trying to program a robot that uses the Arduino Uno Wifi Rev 2 board. However the software that came with the robot was built for Arduino Uno. Digging into it, the Wire library is different between the two since the architecture is megaAVR and not AVR. Is there anyway to get Wire Library that is compatible with both?

pert

Since the Wire library is hardware-specific, each hardware core comes with its own version of the library. The Arduino IDE should automatically use the correct version of the Wire library according to which board you have selected from the Tools > Board menu. Although the underlying implementation is different from one architecture to another, the API is intended to be compatible between all Wire libraries. So there's a good chance that the code will work for either the Uno or the Uno WiFi Rev2. So there's absolutely no need to go hunting for a mythical Wire library that is written for both AVR and megaAVR architectures.

One difference you should be aware of between the Uno and the Uno WiFi Rev2 is that although the Uno has the I2C bus broken out to both pins A4/A5 and SDA/SCL, on the Uno WiFi Rev2 the I2C bus is only on the SCA/SCL pins. So you need to make sure your robot is not using the A4/A5 pins for the I2C connection.

If you are still having problems with your robot and the Uno WiFi Rev2, please provide a detailed description of the problem.

goomung

Thank you for your detailed reply! Glad to hear that the api should be compatible across the different architectures. I am quite new to Arduino.
I am starting to think the issue is with the compile flags in the EVShield code.  I am trying to get that code to work and making some progress.

Here is the detailed error I am getting:


/Users/peach/Documents/Arduino/libraries/evshield/EVShield.cpp: In function 'void pingEV()':
/Users/peach/Documents/Arduino/libraries/evshield/EVShield.cpp:813:9: error: 'TWCR' was not declared in this scope
         TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);

         ^~~~
/Users/peach/Documents/Arduino/libraries/evshield/EVShield.cpp:813:9: note: suggested alternative: 'TWI0'
         TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);

         ^~~~
         TWI0
/Users/peach/Documents/Arduino/libraries/evshield/EVShield.cpp:813:20: error: 'TWINT' was not declared in this scope
         TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);

                    ^~~~~
/Users/peach/Documents/Arduino/libraries/evshield/EVShield.cpp:813:20: note: suggested alternative: 'TWI_t'
         TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);

                    ^~~~~
                    TWI_t
/Users/peach/Documents/Arduino/libraries/evshield/EVShield.cpp:813:31: error: 'TWSTA' was not declared in this scope
         TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);

                               ^~~~~
/Users/peach/Documents/Arduino/libraries/evshield/EVShield.cpp:813:42: error: 'TWEN' was not declared in this scope
         TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);

                                          ^~~~
/Users/peach/Documents/Arduino/libraries/evshield/EVShield.cpp:813:42: note: suggested alternative: 'TWI0'
         TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);

                                          ^~~~
                                          TWI0
/Users/peach/Documents/Arduino/libraries/evshield/EVShield.cpp:815:9: error: 'TWDR' was not declared in this scope
         TWDR = 0x34;

         ^~~~
/Users/peach/Documents/Arduino/libraries/evshield/EVShield.cpp:815:9: note: suggested alternative: 'TWI0'
         TWDR = 0x34;

         ^~~~
         TWI0
/Users/peach/Documents/Arduino/libraries/evshield/EVShield.cpp:818:31: error: 'TWSTO' was not declared in this scope
         TWCR = (1<<TWINT)|(1<<TWSTO)|(1<<TWEN);

                               ^~~~~
/Users/peach/Documents/Arduino/libraries/evshield/EVShield.cpp:819:9: error: 'TCNT2' was not declared in this scope
         TCNT2  = 0;//initialize counter value to 0   

         ^~~~~
/Users/peach/Documents/Arduino/libraries/evshield/EVShield.cpp:819:9: note: suggested alternative: 'TCB2'
         TCNT2  = 0;//initialize counter value to 0   

         ^~~~~
         TCB2
Using library Wire at version 1.0 in folder: /Users/peach/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.2/libraries/Wire
Using library evshield in folder: /Users/peach/Documents/Arduino/libraries/evshield (legacy)
exit status 1
Error compiling for board Arduino Uno WiFi Rev2.



david_prentice

#3
Jul 07, 2019, 08:55 am Last Edit: Jul 07, 2019, 08:58 am by david_prentice
Your  evshield library  is not compatible with the ATmega4809.   It is accessing low level  Uno hardware registers.    The mega4809 has different rehgister names to mega328p.

See if there is an Update available for the evshield library.
If not,    make a request for one on Github.

Not many people have the WiFi Rev2.    There will  be a lot more sales for the new EVERY.     And a lot of libraries will be updated soon.

Sketches that use Wire should work straight out of the box.

David.

goomung

Thank you david_prentice for replying.
I agree it is not compatible. I wish the Wifi Rev2 board didn't have the UNO name attached to it. I just assumed that the board would be supported by EVShield based on that moniker.
Luckily I was able to update the EVShield library to get it to work.

david_prentice

Woo-Hoo.    So the library author had already updated the library.

David.

Demetriodf


I have a WiFi Rev2 and I want to use with RTC DS1307 so I read on this site the library I use on arduino uno is not compatible with ATmega4809. I need a library.

Go Up