I am using UIPEthernet to get an Arduino Nano to drive an ENC28J60 Ethernet Shield for a UDP-based application. I'm customizing a number of its #define parameters to change default settings to save space, but I'm not sure I'm doing it correctly. It's clearly designed to facilitate per-sketch customization, but things aren't quite working for me, and I can't tell if it's me doing it wrong, or if the customization doesn't quite do what I'm expecting.

Specifically, the comments at the top of utilities/uip-conf.h say:

uIP has a number of configuration options that can be overridden for each project. These are kept in a project-specific uip-conf.h file and all configuration names have the prefix UIP_CONF.

So that sounds great - I've copied uip-conf.h into my sketch (into the top directory next to my other sources), adjusted it appropriately, and ... nothing changes.

Now, I'm #including <UIPEthernet.h> into my source files, and everything compiles using the Arduino IDE (v1.8.10). Looking in the library, I can see <UIPEthernet.h> includes <utilities/uipopt.h>, which in turn includes "uip-conf.h" (note the quotes). So I think it's intended to be picking up my local one. But it doesn't - it uses the original one from the library.

My understanding of #include "example.h" is that it looks for example.h relative to the current file location, (ie <utilities/uipopt.h>, so utilities/), so I'm actually seeing correct inclusion behaviour and now I don't see how this customization approach could ever work!

I tried adding the #include "uip-conf.h" to my own sources, and that sort of works for my sources, but of course doesn't affect the library .cpp files themselves which still see the original version.

I could probably drag the entire lib into my sketch and fix up the includes, but that seems like the wrong answer. It's extensively designed to be customizable. Do you know what steps need to be taken to do it please? (Or a pointer to some docs would be fine!) Thanks!

  • have you tried any of the example sketches?
    – jsotola
    Jan 5, 2020 at 0:28
  • @jsotola Yep, extensively whilst evaluating the library. But the examples don't flex the configuration options.
    – SusanW
    Jan 5, 2020 at 11:00

1 Answer 1


Creating a copy of the include file in sketch folder will not work. At library compilation the source files of sketch are not included. The "" for include is "search first in the same folder as the including file".

The project in the description of use of uip-conf.h is UIPEthernet. It includes the UIP library by Adam Dunkels and configures it with this file.

A project with UIPEthernet library can configure the library with options in uipopt.h. Most of the options in uipopt.h are defined as

#else /* UIP_CONF_UDP_CONNS */
#define UIP_UDP_CONNS    10
#endif /* UIP_CONF_UDP_CONNS */

this allows to define the value on compiler command line as -D. Most IDEs enable to set project defines in project settings. Arduino IDE does not enable this yet, because it doesn't have a project configuration file.

With Arduino IDE you can add defines for platform or for board definitions with build.extra_flags in platform.local.txt or in boards.local.txt. Example for boards.local.txt for Arduino Mega:

mega.build.extra_flags=-DUIP_CONF_UDP_CONNS=20 -DUIP_CONF_MAX_LISTENPORTS=30

platform.local.txt and boards.local.txt must be in boards package folder nect to platform.txt and boards.txt.

  • 1
    A clear answer in the first line. Perspective and context follows, and then options and workarounds - and all before breakfast. Perfect answer, thank you, Juraj - again!
    – SusanW
    Jan 5, 2020 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.