1

I'm working on a big software project consisting of several Arduino sketches. I have one Arduino project providing general functionality, such as TCP/IP communication, parsing queries, handling errors, and some more. This part is fundamental for several devices, which extend this fundamental part by specific functionalities. E.g. one device needs to read temperature sensors and manage a loop to control the temperature and has its own sketch. Another device is driving a servo motor and measuring sun light and also has its own sketch. (And there are some other devices with specific sketches.)

I want to maintain the fundamental part in ONE sketch and the specific parts of the different devices each in OTHER sketches, so I can code both separately.

The problem is, those specific parts can not be compiled if not merged with the fundamental sketch, as this provides basic functions. So if I compile any specific part, I want the fundamental part to be added to the specific one and afterwards the whole code should be compiled.

Is there a way to manipulate the makefile used by the Arduino IDE? Then I could use whatever I want (bash or Python script) to merge in the desired way first.

2 Answers 2

5

Assuming that each separate hardware device (ESP32?) must run self-contained with both the fundamental parts, and the use-specific parts, then you would do well to separate out the fundamentals into a library, and then include that library in each use-specific sketch.

The Adafruit Unified Sensor Driver would be one project that shows this. Each of the sensor libraries based on this driver must #include the unified sensor driver library, and that provides some basic properties and interfaces, while each sensor's individual code handles the specifics for communicating to/from that particular unique hardware device.

1
  • Okay, that's a pretty simple approach. Don't know how that didn't come to my mind! Thanks for that! Thinks are a bit complicate in my scenario, but I think implementing specific code as a library should work...
    – Sim Son
    Commented Apr 12, 2018 at 15:03
1

In my opinion, you don't need another Arduino. Most of the time, Arduino is fast enough to handle all the things you mentioned. It highly depends on your programming skills. For example, don't make your Arduino do nothing while waiting for a communication to complete and so on. The techniques you require are:

1) No delay functions at all in your programming. Go Arduino's examples and look for 'blink without delay' sketch.

2) Organize your programming. Make use of creating your own functions. Your void loop() should be a to-do-list.

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.