Unable to download PLC program with different PC

I'm using Arduino PLC ide to download the program to Arduino Opta.
os: Windows 11 pro
ide: Arduino PLC IDE version 1.0.8.0

This is the code

#include <Arduino.h>
#include <Wire.h>
#include <Ethernet.h>
#include <ArduinoJson.h>
#include <ArduinoHttpClient.h>
#include <ArduinoMqttClient.h>
#include "arduino_secrets.h"

// -----------------------------
// Ethernet / MQTT Configuration
// -----------------------------
EthernetClient ethernetClient; // use runtime-managed interface
HttpClient client(ethernetClient, "192.168.0.5", 80);
MqttClient mqttClient(ethernetClient);

const char broker[] = "192.168.0.5";
int port = 1883;
const char topict[] = "Temp&Humidity/Coating/2t";
const char topich[] = "Temp&Humidity/Coating/2h";
const char topicp[] = "NK2/Air_Pressure/main";

char *urlPath = "/rest/v1/rpc/update_dlot_value";
const String HTTP_METHOD = "POST";

// -----------------------------
// Timing and state variables
// -----------------------------
const unsigned long STATE_DURATION = 1000;
const unsigned long LED_DURATION = 2000;
const unsigned long HTTP_TIMEOUT = 5000;

bool initialized = false;
bool switchActive = false;
bool lastSwitchState = false;
bool LED_BLUE;

unsigned long ledOnTime = 0;
unsigned long switchActivatedAt = 0;

void setup()
{
    Serial.begin(9600);
    delay(1500);

    IPAddress ip = Ethernet.localIP();
    if (ip != INADDR_NONE)
    {
        Serial.print("Ethernet ready, IP: ");
        Serial.println(ip);
    }
    else
    {
        Serial.println("Ethernet not yet ready, continuing...");
    }

    connectToMQTT();
}

// -----------------------------
void loop()
{
    mqttClient.poll();
    if (!mqttClient.connected())
        connectToMQTT();

    bool currentState = PLCOut.OUT_LIMIT_SWITCH_PIN;
    if (currentState == true && lastSwitchState == false)
    {
        handleSwitchNonBlocking(true);
    }
    lastSwitchState = currentState;

    publishMessage(topict, String(PLCOut.OUT_TEMP_SWITCH_PIN).c_str());
    publishMessage(topich, String(PLCOut.OUT_HUM_SWITCH_PIN).c_str());
    publishMessage(topicp, String(PLCOut.OUT_AIRP_SWITCH_PIN, 3).c_str());

    updateLeds();
    delay(5);
}

// -----------------------------
void handleSwitchNonBlocking(bool state)
{
    if (state && !switchActive)
    {
        switchActive = true;
        switchActivatedAt = millis();
        sendUpdate(true);
    }

    if (switchActive && millis() - switchActivatedAt >= STATE_DURATION)
    {
        sendUpdate(false);
        switchActive = false;
    }
}

// -----------------------------
void sendUpdate(bool state)
{
    StaticJsonDocument<128> doc;
    doc["schema_name"] = "sequence";
    doc["table_name"] = "nk3_inp_seq";
    doc["target_id"] = 1;
    doc["dlot_value"] = state;

    String payload;
    serializeJson(doc, payload);

    Serial.println("HTTP POST → Supabase RPC");

    client.beginRequest();
    client.startRequest(urlPath, HTTP_METHOD.c_str(), "application/json");
    client.sendHeader("Accept", "application/json");
    client.sendHeader("Content-Length", payload.length());
    client.sendHeader("apikey", SERVICE_ROLE_KEY);
    client.sendHeader("Authorization", String("Bearer ") + SERVICE_ROLE_KEY);
    client.beginBody();
    client.print(payload);
    client.endRequest();

    unsigned long startTime = millis();
    while (!client.available() && millis() - startTime < HTTP_TIMEOUT)
    {
        delay(10);
    }

    if ((millis() - startTime) >= HTTP_TIMEOUT)
    {
        Serial.println("HTTP POST timed out");
        return;
    }

    int statusCode = client.responseStatusCode();
    String response = client.responseBody();

    Serial.print("Status: ");
    Serial.println(statusCode);
    Serial.print("Response: ");
    Serial.println(response);

    if (statusCode == 200 || statusCode == 204)
    {
        PLCIn.LED_01 = true;
        ledOnTime = millis();
    }
    else
    {
        PLCIn.LED_01 = true;
        PLCIn.LED_02 = true;
        PLCIn.LED_03 = true;
        PLCIn.LED_04 = true;
        ledOnTime = millis();
    }
}

// -----------------------------
void updateLeds()
{
    if (millis() - ledOnTime >= LED_DURATION)
    {
        PLCIn.LED_01 = false;
        PLCIn.LED_02 = false;
        PLCIn.LED_03 = false;
        PLCIn.LED_04 = false;
    }
}

// -----------------------------
void connectToMQTT()
{
    IPAddress ip = Ethernet.localIP();
    if (ip == INADDR_NONE)
    {
        Serial.println("Network not ready for MQTT");
        return;
    }

    Serial.print("Connecting to MQTT broker ");
    Serial.println(broker);

    int retryCount = 0;
    while (!mqttClient.connect(broker, port) && retryCount < 5)
    {
        Serial.print("MQTT connect failed, error = ");
        Serial.println(mqttClient.connectError());
        delay(3000);
        retryCount++;
    }

    if (mqttClient.connected())
        Serial.println("Connected to MQTT broker.");
    if (!initialized)
    {
        PLCIn.IN_LED_BLUE = true;
        initialized = true;
    }
    else
        Serial.println("MQTT connection failed after retries.");
}

// -----------------------------
bool publishMessage(const char *topic, const char *message)
{
    if (mqttClient.beginMessage(topic))
    {
        mqttClient.print(message);
        if (mqttClient.endMessage())
            return true;
    }
    Serial.println("MQTT publish failed");
    return false;
}

I can compile and download it with PC1
But cannot compile or download with PC2

When using PC2, it show 2 type of error
In the Resource window:
Cannot generate Sketch file (error message: Error: Permission denied)

or

Cannot generate Sketch file (error message: Error: Invalid procedure call or argument)

Tried to allow all permission in security tab or put the project in C: root.
Both not work at all.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.