[Help needed] How to connect external Hardware to GPIO and manage it from HA

I mates, my idea is to use RasPiArduino (the way to run Arduino sketches on Raspberry) to easy write code by Arduino IDE, using its libraries, produce a .bin file and run it at startup, and control the .bin file running by MQTT messages.

I think there isn’t an easier way to manage external hardware (sensors, relays, PWM, display, RTC, etc.) than Arduno with its libraries, the problem I’m experiencing is to include a MQTT library and compile it. These libraries are written for use an ethernet shield, and we need to use the existent ethernet port of Raspberry, or simply the localhost.
Can somebody help me to find a way to correct the library?
for example this: https://github.com/256dpi/arduino-mqtt

thank you for kind help