GPIO extension - Arduino

Or you can add a ethernet module to the mega2560 and use MQTT protocol for data exchange