Go Down

Topic: Keypad_I2C and Wire library problems with Due (Read 434 times) previous topic - next topic

Hello everyone,

After putting a huge delay (like 20 years) to my programming hobby, I returned to the job by purchasing an UNO.

Everything went well till I destroyed it's bootloader, and I decided to buy a DUE.

Now I have this strange problem with DUE, I have downloaded the new (1.5.6r2) IDE and select my old sketchbook folder, and tried to compile and upload my last project to my brand new DUE board and voila, I got an error which I don't seem to be able to fix it.

I get this error when trying to compile:

Code: [Select]
In file included from ads_project_v2.ino:6:
/home/cagriaksu/Documents/Arduino/arduino-1.5.6-r2/libraries/Keypad_I2C/Keypad_I2C.h: In constructor 'Keypad_I2C::Keypad_I2C(char*, byte*, byte*, byte, byte, byte, byte)':
/home/cagriaksu/Documents/Arduino/arduino-1.5.6-r2/libraries/Keypad_I2C/Keypad_I2C.h:44: error: no matching function for call to 'TwoWire::TwoWire()'
/home/cagriaksu/Documents/Arduino/arduino-1.5.6-r2/hardware/arduino/sam/libraries/Wire/Wire.h:34: note: candidates are: TwoWire::TwoWire(Twi*, void (*)())
/home/cagriaksu/Documents/Arduino/arduino-1.5.6-r2/hardware/arduino/sam/libraries/Wire/Wire.h:32: note:                 TwoWire::TwoWire(const TwoWire&)


When I select any other board from the IDE which is an avr type board, it succesfully compiles, but when it comes to be the DUE, I always get this error.

I tried searching the forum and the internet but neither of them directed to me a solution.

Does anyone have any ideas how to come over this problem?

raschemmel

Why don't we start at the beginning. Can you run the Blink IDE example on the DUE without errors. (forget your old project for the moment. We need to establish that everything else is working first , then we'll go back to that.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

I'm really sorry that I haven't given enough information,

I've tested the DUE with my other projects, which doesnt use the Keypad_I2C library, and they seem to work fine.

I also tried using the Wire library with LiquidCrystal_I2C library, and I got the connection with the I2C chip, and everything works fine.

The problem comes on when I include the library Keypad_I2C.h, I don't need to use it elsewere, just incluing it in the code brings up the problem

raschemmel

I can't find that library. Post the link. Where is it installed on your system ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

I've found out that, Wire library is located under two folders in 1.5.6r2

one for avr devices,

/arduinoIDE/hardware/arduino/avr/libraries/wire/

and for sam devices;

/arduinoIDE/hardware/arduino/sam/libraries/wire/

Their contents differs from each other, thats why when I select the board as UNO or MEGA it compiles the code, because it uses the old Wire library which I was using in the IDE 1.0. But when I select the DUE board, it switches to the new Library which doesnt seem to support the functions that Keypad_I2C is requesting for.

On the version 1, I've downloaded the Wire library from the playground and manually put it under /arduinoIDE/libraries/Wire

I'm running linux by the way

raschemmel

The standard convention is all sketches and all user added libraries reside in ONE folder have the name LIBRARIES and located
in " My Documents\Arduino\[Libraries]"
I have no idea how it work with Linux or any non-windows OS.
EVERY TIME you install a NEW LIBRARY you must verify several things. (EVERY TIME, NO EXCEPTIONS)
1- The new library name does not contain non-allowed characters like "-" or the word "Master". These must be removed.
2- That the zip file did NOT create TWO folders with the SAME name with the actual library folder at the LOWEST level inside a
      folder with the SAME name..In this case, CUT & PASTE the FILES (including the "Examples" file) into the folder with the same
     name at the higher level and delete the now empty folder at the LOWEST level.
3- The "Examples" folder is in the library folder and not somewhere else.
4- The library folder is a folder in the "Libraries " folder mentioned previously which is in the "Arduino" folder which is in the "My
     Documents" folder. This part may differ in other OSs that may not use the "My Documents" name for such a folder.

Once you have installed a library and done all of the above . You can can CUT & PASTE any added library into a LIBTEMP holding
folder in a different path when you want to reduce the number of items in the "File\Examples " menu and then COPY & PASTE them back into the "Libraries " folder when you want to use them. This way , you have a MASTER LIBRARY HOLDING FOLDER
(LIBTEMP) and you don't need to copy them back there since they are already there. You just delete the library from the "Libraries "
folder in the "Arduino" folder and copy & paste them there when you want to use them. I have 3 complete backups of my libraries
on three different drives plus on a 16 Gb thumb drive.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Thank you for the explanation and I already knew these things, and as I said, I have no problem when working with the UNO.

It doesn't matter for the ide , if I put the Wire library folder under the /arduino/library/ folder, because it directly selects the correct wire folder according to the type of the board I'm using (avr or sam). And it chooses the correct Wire folder from the /hardware/arduino/(avr or sam)/libraries/Wire.

So this problem occures when using the 1.5.6r2 IDE, and I have to use it because I'm using  the DUE board.

My problem is with the Keypad_I2C library (I believe) because it happens to work with the Wire library for the AVR devices, but not with the Wire library for the SAM devices.

I looked for another Keypad_I2C library which is designed for this type of use, but couldnt come up with a solution from my google hours..

mstanley

My problem is with the Keypad_I2C library (I believe) because it happens to work with the Wire library for the AVR devices, but not with the Wire library for the SAM devices.

At the risk of sounding rude: No, the problem is definitely with the IDE.  I looked at Wire.h and Wire.cpp for both versions of the IDE and whoever is making the changes for the SAM devices failed to maintain, or has yet to finish, the API for the Wire library.  It is after all only an RC2 version.  I believe RC in this case means Request for Comments so you might want to let them know on the developers list https://groups.google.com/a/arduino.cc/forum/?fromgroups#!forum/developers.

The Wire library for the SAM devices is missing a default, or empty, constructor.  You can add a default constructor but I didn't check to see if there were any other missing or modified functions in the SAM devices Wire library.

raschemmel

I can't help you with any of that . I'm primarily a HW guy.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

mstanley

I looked at the Wire library and the only function missing is the empty constructor.  I downloaded the source files Wire.h, and Wire.cpp from Github and added an empty constructor.  It is a brain-dead attempt to see if the problem can be easily fixed.  It looks like someone is trying to add a feature so there may be other parts of the library that are still broken.

I would have tried to compile it myself but when I went to download 1.5.6-r2 the server 503'd me.  Anyway, I've attached the modified source files here if you want to try them out.  Just put them in the Wire library folder under the SAM folder.

As another option you might be able to copy the entire Wire library from the AVR library subfolder and paste it over the one in the SAM folder.  Unless the Due has some unique hardware for doing I2C it might just work.


As another option you might be able to copy the entire Wire library from the AVR library subfolder and paste it over the one in the SAM folder.  Unless the Due has some unique hardware for doing I2C it might just work.


Thanks for the files, I'll be trying them right away, and for the info, I've already tried copying the avr folder over the SAM folder but I think that DUE has differences in ways of communicating via I2C because, it couldn't get it to compile either way with different errors this time

I've tried the new files you've uploaded, the code compiles but the communication is no longer working  =(

I tried playing with the addresses of the I2C chips but had no luck  =(

Go Up