Would you guys help me to fix this? the output shows "Compilation error: too many initializers for 'Perintah'" thank you

#include <LoRa_E220.h>
#include <Blynk.h>
#include<SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#define DESTINATION_ADDL 3

LoRa_E220 e220ttl(D3, D4, D5, D7, D6);

//TEMPLATE MENYAMBUNGKAN APLIKASI DAN ESP8266//
#define BLYNK_TEMPLATE_ID "TMPLa1jBSJmW"
#define BLYNK_TEMPLATE_NAME "Aplikasi Kontroler"
#define BLYNK_AUTH_TOKEN "KEhBiA71LJ4pXGYhnyYmp554umY1zf8e"

// Kredensial Wi-Fi
char ssid[] = "T2";
char pass[] = "N0#geming#boz";

char auth[] = BLYNK_AUTH_TOKEN;

BlynkTimer timer;

//define ESP8266 NodeMCU GPIO pins
//SoftwareSerial loraSerial(12, 14); // RX, TX

#define pSwitch_1 10 //SD3
#define pSwitch_2 0 //D3
#define pSwitch_3 14 //D5
#define pSwitch_4 3 //RX

#define wifiLed 16 //D0
#define sLED 2 //D4

#define VPIN_BUTTON_1 V1
#define VPIN_BUTTON_2 V2
#define VPIN_BUTTON_3 V3
#define VPIN_BUTTON_4 V4
#define VPIN_BUTTON_5 V5

int wifiFlag = 0;
int i;
String incomingString;
boolean state;

String command;

struct Perintah
{
char type[5];
char command[8];
int VPIN_BUTTON_1;
int VPIN_BUTTON_2;
int VPIN_BUTTON_3;
};

struct Perintah perintah = {"", "", 0, 0, 0};

void getFeedback(String excpt_str){
i = 0;
incomingString = "";
state = true;

digitalWrite(sLED, LOW);
Blynk.virtualWrite(VPIN_BUTTON_5, "Waiting for Feedback...");

//Serial.print("Waiting for feedback");
while(1){
if(Serial.available()>0){
incomingString = Serial.readString();
Serial.println(incomingString);
if(incomingString.indexOf(excpt_str) > 0) {
state = true; break;
}
}
if (i > 70) {
state = false; break;
}
delay(50);
digitalWrite(sLED, !digitalRead(sLED));
i++;
}

if(state){
  digitalWrite(sLED, HIGH);
  Blynk.virtualWrite(VPIN_BUTTON_5, "Feedback Received.");
  //Serial.println("Received");
}
else{
  digitalWrite(sLED, LOW);
  Blynk.virtualWrite(VPIN_BUTTON_5, "Feedback Not Received.");
  //Serial.println("Not Received");
}    

}

void setup() {
Serial.begin(115200);
delay(500);

// Startup all pins and UART
e220ttl.begin();

Serial.println("Hi, Saya akan mengirimkan perintah untuk mengaktifkan aktuator!");

struct Perintah command = {""}

// Saat tombol ditekan - mengalihkan status
Blynk.virtualWrite(VPIN_BUTTON_1,0) {
if(param.asInt() == 1){
command = "2,R1";
Serial.println(command);
getFeedback("FR1");
delay(10);
command = "";
}
}

Blynk.virtualWrite(VPIN_BUTTON_2,0) {
if(param.asInt() == 1){
command = "2,R2";
Serial.println(command);
getFeedback("FR2");
delay(10);
command = "";
}
}

Blynk.virtualWriteE(VPIN_BUTTON_3,0) {
if(param.asInt() == 1){
command = "2,R3";
Serial.println(command);
getFeedback("FR3");
delay(10);
command = "";
}
}

void checkBlynkStatus()
{ // called every 3 seconds by SimpleTimer
bool isconnected = Blynk.connected();
if (isconnected == false) {
wifiFlag = 1;
digitalWrite(wifiLed, HIGH); //Turn off WiFi LED
}
if (isconnected == true) {
wifiFlag = 0;
digitalWrite(wifiLed, LOW); //Turn on WiFi LED
}
}

void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(wifiLed, OUTPUT);
pinMode(sLED, OUTPUT);

pinMode(pSwitch_1, INPUT_PULLUP);
pinMode(pSwitch_2, INPUT_PULLUP);
pinMode(pSwitch_3, INPUT_PULLUP);

digitalWrite(wifiLed, HIGH); //Turn off WiFi LED
digitalWrite(sLED, HIGH); //Turn on Status LED

Blynk.begin(auth, ssid, pass);
timer.setInterval(3000L, checkBlynkStatus); // check if Blynk server is connected every 3 seconds

delay(1500);

digitalWrite(sLED, LOW);
Blynk.virtualWrite(VPIN_BUTTON_5, "Ready...");
}

void loop()
{
// put your main code here, to run repeatedly:
if (Serial.available()){
Serial.write(Serial.read());
}

Blynk.run();
//manual_control();
timer.run(); // Initiates SimpleTimer
}

// Send message
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &command, sizeof(Perintah));
// Check If there is some problem of succesfully send
Serial.println(rs.getResponseDescription());
}

void loop() {
// If something available
if (e220ttl.available()>1) {
// read the String message
#ifdef ENABLE_RSSI
ResponseStructContainer rsc = e220ttl.receiveMessageRSSI(sizeof(Perintah));
#else
ResponseStructContainer rsc = e220ttl.receiveMessage(sizeof(Perintah));
#endif

// Is something goes wrong print error
if (rsc.status.code!=1){
	Serial.println(rsc.status.getResponseDescription());
}else{
	// Print the data received
	Serial.println(rsc.status.getResponseDescription());
	struct Perintah message = *(Perintah*) rsc.data;
	Serial.println(message.type);
	Serial.println(message.command);
	Serial.println(message.V1);
Serial.println(message.V2);
Serial.println(message.V3);

#ifdef ENABLE_RSSI
Serial.print("RSSI: "); Serial.println(rsc.rssi, DEC);
#endif
}
}
if (Serial.available()) {
struct Perintah command = {" "};
command.V1 = Serial.parseInt();
command.V2 = Serial.parseInt();
command.V3 = Serial.parseInt();

  // Send message
  ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &command, sizeof(Perintah));
  // Check If there is some problem of succesfully send
  Serial.println(rs.getResponseDescription());

}
}

Post your sketch, well formated, with well-tempered comments and in so called code tags "< code >" to see how we can help.

Addition to the formatting the code, please explain what the problem you have with it. If there are a compile errors, please insert them in full using the code tags.

upload a schematic showing the wiring in particular how you power the Ebyte E220 LoRa and other devices
I assume you are using LoRa P2P communication have you tested the E220 in a seperate program?
does the program compile and run? if so upload a copy of the Serial Monitor output - it is always worth adding extra Serial.println() statements to display variable values at key points in the program execution

Very generalised question. So much generalised that the very generalised answer is:

Yes.
.
.... ---- .... --- ..... so what? ....-------.......--------.........-------......

We can help you in more detail if you take the effort to the instructions
that you can read here

best regards Stefan

here is my code

BLYNK_LORA_COMMAND.ino (5.3 KB)

You should really read this !

the output shows
"Compilation error: too many initializers for 'Perintah'"

Still only very poor information:

You are trying to be quick by quick and short postings. All that happens is that you are slowing things down, because all that happends is asking back that you provide the information that you thought leave it away to be quicker

you mean like this? sorry, sorry I'm a newbie user

#include <LoRa_E220.h>
#include <Blynk.h>
#include<SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h> 


#define DESTINATION_ADDL 3

LoRa_E220 e220ttl(D3, D4, D5, D7, D6);


//TEMPLATE MENYAMBUNGKAN APLIKASI DAN ESP8266//
#define BLYNK_TEMPLATE_ID "TMPLa1jBSJmW"
#define BLYNK_TEMPLATE_NAME "Aplikasi Kontroler"
#define BLYNK_AUTH_TOKEN "KEhBiA71LJ4pXGYhnyYmp554umY1zf8e"

// Kredensial Wi-Fi
char ssid[] = "T2";
char pass[] = "N0#geming#boz";


char auth[] = BLYNK_AUTH_TOKEN;

BlynkTimer timer;

//define ESP8266 NodeMCU GPIO pins
//SoftwareSerial loraSerial(12, 14);  // RX, TX

#define pSwitch_1 10  //SD3
#define pSwitch_2 0   //D3 
#define pSwitch_3 14  //D5
#define pSwitch_4 3   //RX

#define wifiLed   16   //D0
#define sLED       2   //D4

#define VPIN_BUTTON_1    V1 
#define VPIN_BUTTON_2    V2
#define VPIN_BUTTON_3    V3 
#define VPIN_BUTTON_4    V4
#define VPIN_BUTTON_5    V5

int wifiFlag = 0;
int i;
String incomingString;
boolean state;

char command[8];

struct Perintah
{
  char type[5];
  char command[8];
  int VPIN_BUTTON_1[8];
  int VPIN_BUTTON_2[8];
  int VPIN_BUTTON_3[8];
} perintah = {"", "", "", "", "", ""};

void getFeedback(String excpt_str){
  i = 0;
  incomingString = "";
  state = true;

  digitalWrite(sLED, LOW);
  Blynk.virtualWrite(VPIN_BUTTON_5, "Waiting for Feedback...");

  //Serial.print("Waiting for feedback");
  while(1){
    if(Serial.available()>0){
      incomingString = Serial.readString();
      Serial.println(incomingString);
      if(incomingString.indexOf(excpt_str) > 0) {
        state = true; break;
      }
    }      
    if (i > 70) {
      state = false; break;
    }
    delay(50);
    digitalWrite(sLED, !digitalRead(sLED));
    i++;
    }

    if(state){
      digitalWrite(sLED, HIGH);
      Blynk.virtualWrite(VPIN_BUTTON_5, "Feedback Received.");
      //Serial.println("Received");
    }
    else{
      digitalWrite(sLED, LOW);
      Blynk.virtualWrite(VPIN_BUTTON_5, "Feedback Not Received.");
      //Serial.println("Not Received");
    }    
}



void setup() {
  Serial.begin(115200);
  delay(500);

  // Startup all pins and UART
  e220ttl.begin();

  Serial.println("Hi, Saya akan mengirimkan perintah untuk mengaktifkan aktuator!");

struct Perintah command = {""}


// Saat tombol ditekan - mengalihkan status 
BLYNK_WRITE(VPIN_BUTTON_1) {
  if(param.asInt() == 1){
    command = "2,R1";
    Serial.println(command);
    getFeedback("FR1");
    delay(10);
    command = "";
  }
}

BLYNK_WRITE(VPIN_BUTTON_2) {
  if(param.asInt() == 1){
    command = "2,R2";
    Serial.println(command);
    getFeedback("FR2");
    delay(10);
    command = "";
  }
}

BLYNK_WRITE(VPIN_BUTTON_3) {
  if(param.asInt() == 1){
    command = "2,R3";
    Serial.println(command);
    getFeedback("FR3");
    delay(10);
    command = "";
  }
}

void checkBlynkStatus() 
{ // called every 3 seconds by SimpleTimer
  bool isconnected = Blynk.connected();
  if (isconnected == false) {
    wifiFlag = 1;
    digitalWrite(wifiLed, HIGH); //Turn off WiFi LED
  }
  if (isconnected == true) {
    wifiFlag = 0;
    digitalWrite(wifiLed, LOW); //Turn on WiFi LED
  }
}

void setup()
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(wifiLed, OUTPUT);
  pinMode(sLED, OUTPUT);
  
  pinMode(pSwitch_1, INPUT_PULLUP);
  pinMode(pSwitch_2, INPUT_PULLUP);
  pinMode(pSwitch_3, INPUT_PULLUP);

  digitalWrite(wifiLed, HIGH); //Turn off WiFi LED
  digitalWrite(sLED, HIGH);   //Turn on Status LED
  
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(3000L, checkBlynkStatus); // check if Blynk server is connected every 3 seconds
  
  delay(1500);

  
  digitalWrite(sLED, LOW);
  Blynk.virtualWrite(VPIN_BUTTON_5, "Ready...");
}

void loop()
{
  // put your main code here, to run repeatedly:
  if (Serial.available()){
    Serial.write(Serial.read());
  }
  
  Blynk.run();
  //manual_control();
  timer.run(); // Initiates SimpleTimer
}


// Send message
  ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &command, sizeof(Perintah));
  // Check If there is some problem of succesfully send
  Serial.println(rs.getResponseDescription());
}

void loop() {
	// If something available
  if (e220ttl.available()>1) {
	  // read the String message
#ifdef ENABLE_RSSI
		ResponseStructContainer rsc = e220ttl.receiveMessageRSSI(sizeof(Perintah));
#else
		ResponseStructContainer rsc = e220ttl.receiveMessage(sizeof(Perintah));
#endif

	// Is something goes wrong print error
	if (rsc.status.code!=1){
		Serial.println(rsc.status.getResponseDescription());
	}else{
		// Print the data received
		Serial.println(rsc.status.getResponseDescription());
		struct Perintah message = *(Perintah*) rsc.data;
		Serial.println(message.type);
		Serial.println(message.command);
		Serial.println(message.VPIN_BUTTON_1);
    Serial.println(message.VPIN_BUTTON_1);
    Serial.println(message.VPIN_BUTTON_1);

#ifdef ENABLE_RSSI
		Serial.print("RSSI: "); Serial.println(rsc.rssi, DEC);
#endif
	}
  }
  if (Serial.available()) {
	  struct Perintah command = {" "};
	  command.VPIN_BUTTON_1 = Serial.parseInt();
    command.VPIN_BUTTON_1 = Serial.parseInt();
    command.VPIN_BUTTON_1 = Serial.parseInt();

	  // Send message
	  ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &command, sizeof(Perintah));
	  // Check If there is some problem of succesfully send
	  Serial.println(rs.getResponseDescription());
  }
}


the structure has five members and you have six initialisers
try

struct Perintah
{
  char type[5];
  char command[8];
  int VPIN_BUTTON_1[8];
  int VPIN_BUTTON_2[8];
  int VPIN_BUTTON_3[8];
} perintah = {"", "",{0},{0},{0}};

as perintah is global it initial values will be set to 0 by default anyway

I suspct you have many errors reported by the compiler - upload the complete compiler error report??

You should use keyword struct only when you want to defene a new type.
Do not use this keyword when you define a new variable of previsly defined type Perintah as in line above.

implement a simple program to test structure initialisation, e.g. using a NodeMCU ESP8266

struct Perintah
{
  char type[5];
  char command[8];
  int VPIN_BUTTON_1[8];
  int VPIN_BUTTON_2[8];
  int VPIN_BUTTON_3[8];
} perintah = {"", "",{0},{0},{0}};

struct Perintah command = {" "};

struct Perintah test = {"tst1","test2",{1,2,3},{7,8,9},{10,1,12}};

void setup() {
  Serial.begin(115200);
  Serial.println(test.command);
  Serial.println(test.VPIN_BUTTON_1[0]);
  Serial.println(test.VPIN_BUTTON_2[2]);
  Serial.println(test.VPIN_BUTTON_2[6]);
}

void loop() {
  Serial.println(test.VPIN_BUTTON_3[2]++);
  delay(2000);
}

serial monitor displays

test2
test2
1
9
0
12
13
14
15

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