I'm using IDE 2.xx with OPTA and i made a program to connect by wifi.
The PLC as reported 2 errors "AlPlcLoad failed " and "WiFiFirmwareUpdater". I try to upload firmware as recommended but the PLC flashes red LED after upload. Can any one please help me
!! AlPlcLoad failed
Ligado a Modulo Wifi do OPTA - CONNECTED TO WIFI MODULE
A ligar a Rede Wifi:TP-Link_9C05 - TRYING TO CONNECT TO WIFI NETWORK
File not found
Please run the "WiFiFirmwareUpdater" sketch once to install the WiFi firmware.
Code:
#include <Nicla_Vision_System.h>
#include <Portenta_System.h>
#include <STM32H747_System.h>
#include <Ethernet.h>
#include <Arduino_Portenta_OTA.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiSSLClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>
#include <AlPlc_Opta.h>
#include <Arduino_ConnectionHandler.h>
#include <ArduinoIoTCloud.h>
bool digital01;
bool digital02;
// definições de ligação a a rede WIFI.........................................................................
#define SECRET_SSID "TP-Link_9C05" //Rede WIFI de Ligação
#define SECRET_PASS "31005212" //Pass de WIFI
const char ssid[] = SECRET_SSID; // your network SSID (name)
const char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS;
//.............................................................................................................
#if !(defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT))
#error ".....ERRO CONTROLADOR NÃO SUPORTA IOT CLOUD....."
#endif
//.....................................definições para IOT Cloud.......................................
#if defined(BOARD_HAS_SECRET_KEY)
#define BOARD_ID "424194e5-3185-4464-bb02-ee7a9dc13f48"
#endif
//.............................................................................................................
struct PLCSharedVarsInput_t
{
};
PLCSharedVarsInput_t& PLCIn = (PLCSharedVarsInput_t&)m_PLCSharedVarsInputBuf;
struct PLCSharedVarsOutput_t
{
bool out_digital01;
bool out_digital02;
};
PLCSharedVarsOutput_t& PLCOut = (PLCSharedVarsOutput_t&)m_PLCSharedVarsOutputBuf;
AlPlc AxelPLC(-1662570896);
// shared variables can be accessed with PLCIn.varname and PLCOut.varname
WiFiClient client;
void setup()
{
AxelPLC.InitFileSystem();
AxelPLC.Run();
// check for the WiFi module:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("Comunicação com modulo Wifi Impossivel");
// Fica preso nesta rotina
while (true);
}
Serial.println("Ligado a Modulo Wifi do OPTA");
// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print("A ligar a Rede Wifi:");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 3 seconds for connection:
delay(3000);
}
Serial.println("Ligado a rede Wifi");
Serial.println(ssid);
pinMode(LED_D0, OUTPUT); //led para sinalizar entrada 1
pinMode(LED_D1, OUTPUT); // led para sinalizar entrada 2
pinMode(LED_D2, OUTPUT); // led para sinalizar ligacao a wifi
pinMode(A0, INPUT); // Entrada I1 como input
pinMode(A1, INPUT); // Entrada I2 como input
}
void loop()
{
if (digitalRead(A0) == LOW) // entrada sensor sala 1 desligado
{
if (digitalRead(A1) == LOW) // entrada sensor sala 2 desligado
{
digitalWrite (LED_D0, HIGH); // liga led1
digitalWrite (LED_D1, HIGH); // liga led2
delay(500);
digitalWrite (LED_D0, LOW); //Desliga led2
digitalWrite (LED_D1, LOW); //desliga led2
delay (500);
}
}
if (digitalRead(A0) == HIGH) // se entrada sensor sala 1 ligado
{
digitalWrite (LED_D0, HIGH); // liga led status 1
PLCOut.out_digital01 = HIGH;
};
if (digitalRead(A1) == HIGH) // se entrada sensor sala 2 ligado
{
digitalWrite (LED_D1, HIGH); // liga led status 2
PLCOut.out_digital01 = HIGH;
};
}