invalid library

Hi All,

I have moved on from the project guidance section. It's all about the code now, and this is my first project.

I have several digital inputs to an arduino micro, which then sends outputs over i2c to an i2c interface board connected to a board with 16 relays for outputs to various 12vdc solenoids.

My first problem was getting the library supplied by the interface board installed. I finally got that figured out, as far as I know, and have a library called Relay16 in the arduino library folder with the Relay16.cpp and Relay16.h files.

The manufacturer also supplied an example sketch that sequentially turns on each relay, then all on, then off in the loop.

Now, I can verify the example code and it finishes without errors.

If I try to upload to the micro, it errors out with "invalid library" and a path to where the sketch is.

I tried adding a copy of the Relay16 library folder to the example sketch folder, but that didn't help.

I can communicate with the micro just fine, it returns the board info just like it should.

Does the compiler use both the .h and .cpp files?

Does anyone see why this lib shouldn't run?

Here is the contents of the Relay.cpp file:

/*************************************************************************
Title:    Iowa Scaled Engineering I2C-RELAY16 Driver Library
Authors:  Nathan D. Holmes <maverick@drgw.net>
File:     $Id: $
License:  GNU General Public License v3

LICENSE:
    Copyright (C) 2014 Nathan D. Holmes & Michael D. Petersen

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    For more information about the Iowa Scaled Engineering I2C-RELAY16, see:
    http://www.iascaled.com/store/I2C-RELAY16

*************************************************************************/

#include <stdlib.h>
#include <string.h>
#include "Arduino.h"
#include "Wire.h"
#include "Relay16.h"

Relay16::Relay16()
{
	this->addr = 0;
	this->relayBits = 0; // All relays off
	this->dioReset = -1; // Unknown digital I/O for the reset line
}

void Relay16::refresh()
{
   Wire.beginTransmission(this->addr);
   Wire.write(~(this->relayBits & 0xFF));
   Wire.write(~((this->relayBits >> 8) & 0xFF));
   Wire.endTransmission();
}


void Relay16::allOff()
{
	this->relayBits = 0;
	refresh();
}

void Relay16::allOn()
{
	this->relayBits = 0xFFFF;
	refresh();
}

void Relay16::relayOn(byte relayNum)
{
	if (relayNum < 1 || relayNum > 16)
		return;
	this->relayBits |= 1<<(relayNum-1);
	refresh();
}

void Relay16::relayOff(byte relayNum)
{
	if (relayNum < 1 || relayNum > 16)
		return;
	this->relayBits &= ~(1<<(relayNum-1));
	refresh();
}


void Relay16::begin(boolean j5, boolean j6, boolean j7, char dioResetPin)
{
	uint8_t addrBitmap = (j5?0x01:0x00) | (j6?0x02:0x00) | (j7?0x04:0x00);
	this->addr = 0x20 | (addrBitmap);
	
	// If there's a DIO pin assigned to reset, use it to do a hardware reset on initialization
	if (-1 != dioResetPin)
	{
		pinMode(dioResetPin, OUTPUT);
		digitalWrite(dioResetPin, LOW);
		delayMicroseconds(100);
		digitalWrite(dioResetPin, HIGH);
	}
	
	this->allOff();
}

And the example sketch:

/*************************************************************************
Title:    Iowa Scaled Engineering I2C-RELAY16 Driver Library Example Sketch
Authors:  Nathan D. Holmes <maverick@drgw.net>
File:     $Id: $
License:  GNU General Public License v3

LICENSE:
    Copyright (C) 2014 Nathan D. Holmes & Michael D. Petersen

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    For more information about the Iowa Scaled Engineering I2C-RELAY16, see:
    http://www.iascaled.com/store/I2C-RELAY16

*************************************************************************/

#include <Wire.h>
#include <Relay16.h>

Relay16 relayBoard;

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
  Wire.begin();
//  Both of the following initialization examples assume that address jumpers J5, J6, and J7
//  on the I2C-RELAY16 are set to low (center pin is jumpered to the one away from the + sign on
//  each jumper block).  If they're set the other direction (center to + pin), replace "LOW" with "HIGH"

//  If you're using a standard Iowa Scaled shield to connect the I2C lines to the Arduino,
//  the /IORST line is likely tied to Digital IO line 4.  Use the initializer below.
  relayBoard.begin(LOW, LOW, LOW, 4);

//  If the /IORST line on the I2C cable isn't connected anywhere, use this initializer
//   instead of the one above.
//  relayBoard.begin(LOW, LOW, LOW, -1);

}

void loop() {
  // print the results to the serial monitor:

  byte relayNum;

  for (relayNum = 1; relayNum <= 16; relayNum++)
  {
    relayBoard.relayOn(relayNum);
    delay(250);
    relayBoard.relayOff(relayNum);  
    
  }

  relayBoard.allOn();
  delay(250);
  relayBoard.allOff();
  delay(250);   

}

Thanks

Does the compiler use both the .h and .cpp files?

Yes, it does.

Does anyone see why this lib shouldn't run?

It probably does. "It doesn't work" is the lamest possible thing you could say here, and will NOT get you help. Describe the hardware (with links) and say what the program actually does, and how that differs from what you expect. We can then help you adjust your expectations.

The cause of the "Invalid Library" warning is that the folder structure of that library doesn't allow it to be correctly installed directly from the .zip file you downloaded using Sketch > Include Library > Add .ZIP library.... You need to manually install it, as described in the instructions:
http://www.iascaled.com/info/Relay16LibraryReference

Setup

You'll need to copy the Relay16 directory (with the Relay16.cpp and Relay16.h files) into your arduino/libraries directory. This is known as "Manual Installation" of an Arduino library. More details can be found in the "Arduino - Libraries" documentation.

If the example sketch actually compiled I suspect that you have somehow managed to correctly install one copy of the library and incorrectly install the other. That warning should not prevent you from uploading. If you can compile but not upload that indicates the problem is not with the code.

Please do this:

  • Tools > Preferences > Show verbose output during: > compilation (uncheck) > upload (check) > OK
  • Sketch > Upload
  • After the process fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • Paste the error messages in a reply here using code tags.

The OP has decided to continue his existing post in this new thread.
A lot of information exists in the previous thread he started.

Missing is still a print out of the actual error message.

Here are the ACTUAL error msgs

PLEASE NOTE: I DIDN'T HAVE A BORD CONNECTED THIS TIME SO IGNORE THE "NO BOARD CONNECTED" STUFF.

IT'S THE INVALID LIBRARY ERRORS AT THE END.

I mentioned before, but I copied the library Relay16 folder into both of the sketch directories and still got same errors.

There may be a typo in a library file, but I don't know what i'm looking at.

The only two libraries included in the example are "wire" and "Relay16"

Arduino: 1.8.2 (Windows 7), Board: "Arduino/Genuino Micro"

Sketch uses 5632 bytes (19%) of program storage space. Maximum is 28672 bytes.
Global variables use 327 bytes (12%) of dynamic memory, leaving 2233 bytes for local variables. Maximum is 2560 bytes.
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
Couldn't find a Board on the selected port. Check that you have the correct port selected.  If it is correct, try pressing the board's reset button after initiating the upload.
Invalid library found in C:\Users\jeff\Documents\Arduino\libraries\scissor_lift: C:\Users\jeff\Documents\Arduino\libraries\scissor_lift
Invalid library found in C:\Users\jeff\Documents\Arduino\libraries\sketch_apr22c: C:\Users\jeff\Documents\Arduino\libraries\sketch_apr22c
Invalid library found in C:\Users\jeff\Documents\Arduino\libraries\scissor_lift: C:\Users\jeff\Documents\Arduino\libraries\scissor_lift
Invalid library found in C:\Users\jeff\Documents\Arduino\libraries\sketch_apr22c: C:\Users\jeff\Documents\Arduino\libraries\sketch_apr22c

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Verbose on compile not checked and verbose checked on upload as instructed.

Also as stated before, the Relay16.cpp and Relay16.h are in the C:\program files(x86)\arduino\library\Relay16 folder.

The IDE shows the Relay16 library included in the sketch > include library list.

I did the manual library install.

at the #include statement in the example sketch, the Relay16.h is NOT in red like the wire.h is.

Hope that is everything.

Thanks (and thanks for the link to my other posts 6v6GT)

It appears your sketch compiled OK.
The IDE is also taking the opportunity to inform you that it has discovered some invalid libraries at the locations mentioned. Clearly, these libraries are not relevant to your sketch otherwise it would not have compiled. Just clean these out.

The invalid library warning is unrelated to the actual error - the IDE spits out those warnings under multiple conditions (and irritatingly frequently, too). You can resolve the warning by removing the two folders it lists from libraries (it looks like you saved at least one sketch in the libraries folder, don't do that). This will not fix your upload problem though, your upload problem is this:

Arduino: 1.8.2 (Windows 7), Board: "Arduino/Genuino Micro"

Sketch uses 5632 bytes (19%) of program storage space. Maximum is 28672 bytes.
Global variables use 327 bytes (12%) of dynamic memory, leaving 2233 bytes for local variables. Maximum is 2560 bytes.
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
Couldn't find a Board on the selected port. Check that you have the correct port selected.  If it is correct, try pressing the board's reset button after initiating the upload.

jeff238:
PLEASE NOTE: I DIDN'T HAVE A BORD CONNECTED THIS TIME SO IGNORE THE "NO BOARD CONNECTED" STUFF.

The whole point of me asking for verbose output during upload was so that we could see if there was an upload problem. There's no way to check for an upload problem if you don't bother plugging the board in.

jeff238:
at the #include statement in the example sketch, the Relay16.h is NOT in red like the wire.h is.

That doesn't matter. It just means that Relay16 is not one of the keywords included in the keywords.txt file for the library. It's purely aesthetics and makes no functional difference.