#include #include #include #include // Demo PLC firmware using the ESPMegaPRO OOP library ESPMegaPRO espmega = ESPMegaPRO(); void input_change_callback(uint8_t pin, uint8_t value) { Serial.print("Input change callback: "); Serial.print(pin); Serial.print(" "); Serial.println(value); } void setup() { espmega.begin(); espmega.enableIotModule(); ETH.begin(); espmega.iot->bindEthernetInterface(Ð); NetworkConfig config = { .ip = {192, 168, 0, 11}, .gateway = {192, 168, 0, 1}, .subnet = {255, 255, 255, 0}, .dns1 = {192, 168, 0, 1}, .dns2 = {192, 168, 0, 1}, .useStaticIp = true, .useWifi = false, .wifiUseAuth = false, }; strcpy(config.ssid, "ssid"); strcpy(config.password, "password"); strcpy(config.hostname, "espmega"); Serial.println("Setting network config"); espmega.iot->setNetworkConfig(config); Serial.println("Connecting to network"); espmega.iot->connectNetwork(); Serial.println("Begin MQTT Modules"); MqttConfig mqtt_config = { .mqtt_port = 1883, .mqtt_useauth = false }; Serial.println("Setting MQTT Server"); strcpy(mqtt_config.mqtt_server, "192.168.0.26"); strcpy(mqtt_config.base_topic, "/espmegaoop"); Serial.println("Loading MQTT Config Struct to IoT Module"); espmega.iot->setMqttConfig(mqtt_config); Serial.println("Connecting to MQTT"); espmega.iot->connectToMqtt(); Serial.println("Registering Output Card"); espmega.iot->registerCard(0); Serial.println("Registering Input Card"); espmega.iot->registerCard(1); Serial.println("Registering Input Change Callback"); espmega.inputs.registerCallback(input_change_callback); Serial.println("Enabling Internal Display"); espmega.enableInternalDisplay(&Serial); Serial.println("Initialization Routine Complete"); } void loop() { espmega.loop(); }