Error: invalid conversion from 'int' to 'char*' [-fpermissive] and invalid types 'int[int]' for array subscript

#include <Servo.h>

//--------------PESOS m y o----------------//

double m[16][2] = {{0.9347984666883069, 0.9347984666883069},{0.43121071833605756, 0.4512747983656072},{0.26817105236906985, 0.2163384192222833},{0.5548266212019757, 0.5590286924415926},{0.0, 0.0},{0.37611890461118197, 0.37611890461118197},{0.5448840902827496, 0.48033076237970007},{0.5633522278648986, 0.5633522278648986},{0.7342107768561732, 0.5075008206129903},{0.4716470033531131, 0.4385032327191939},{0.16831755117926628, 0.16831755117926628},{0.6967545783327062, 0.6967545783327062},{0.3867109685012193, 0.3867109685012193},{1.0, 0.5809382032279375},{0.4519760395571738, 0.4519760395571738},{0.6148832550520874, 0.47578353848855853}};

//------VARIABLES PARA LA RED NEURONAL---------//

float Xu[4];  //Dimension para datos in y conversion
int X[4];       //Dimension para datos in
float N[7];     //Numero de filas
float s;        //Variable dependiente
float p=0.0;
float y;        //Variable de salida
int r;
int pm;

//---------VARIABLES GLOBALES-------//

int contconexion = 0;
int ye = 0;
float e = 2.71828;
int value = 0;

Servo servo;
const int LDR1 = 34;
const int LDR2 = 24;
const int pot = 35;
int val1;
int val2,h,o,t;

//**PROMEDIO DE MUESTRAS**//

const int numReadings = 10;  //numero de muestras para promediar o cantidad de datos//
int readings[numReadings];   //Lectura de la entrada analogica//
int indexs = 0;              //Indice de lectura actual//
int total = 0;               //Total//
float average = 0;           //Promedio//
int thisReading = 0;

//---------------SETUP-------------//

void setup()  {
  Serial.begin(115200);
  Serial.println("");
  servo.attach(15);  //Pin número 15 del esp32 
  pinMode(LDR1, INPUT);
  pinMode(LDR2, INPUT);
  pinMode(pot, INPUT);
}
//------------LOOP--------//

void loop() {
  // LECTURAS DE LAS LDR
  int sensorluz1 = analogRead(LDR1);
  int sensorluz2 = analogRead(LDR2);
  
  //*****CONVERSION DE LOS DATOS DESNORMALIZADOS**//
  
  X[0] = sensorluz1;
  X[1] = sensorluz2;
  
  Xu[0] = X[0] / 40;
  Xu[1] = X[1] / 95;
  Xu[2] = X[2] / 50;
  Xu[3] = 1;

  sensorluz1=val1;
  dtostrf(h, 3, 0, val1);  //ldr a string //4 is mininum width, 4 is precision; float value is copied onto buff//
  for (int i = 0; i < sizeof(val1); i++) {
    sensorluz2=val2;
    dtostrf(h, 3, 0, val2);  //ldr a string //4 is mininum width, 4 is precision; float value is copied onto buff//
    for (int i = 0; i < sizeof(val2); i++) {
      
      //*****SE NORMALIZAN LOS DATOS*******//
      
      for (int n = 0; n < 7; n++) {
        s = 0.0;
        for (int i = 0; i < 3; i++) {
          s = s + (X[i] * m[n][i]);
          Serial.print(s);
        }
        N[n] = 1 / (1 + exp(-s));
        
        //Obtenemos los valores de cada una de las neuronas de la capa media//
        //N[n] =(1/(1-(pow(e,-s))));
        
        Serial.print(N[n]);
      }
      Serial.println(p);
      for (int n = 0; n<7; n++) {
        //s=s+(N[n]*o[n]);
        p=p+(N[n]*o[n]);
      }
      p=1/(1+exp(-s));  // Obtenemos el valor de salida desnormalizado//

      //p = (1/(1-(pow(e,-p))));//
      
      int Ynn = p;
      Serial.println(F(" "));
      Serial.println(F("P: "));
      Serial.println(p);
      //int Ynn = (int)y;
      Serial.println(F(" "));
      Serial.println(F("Ynn: "));
      Serial.println(y);

      //int respuesta = redNeuronal(strTemp,strLDR,strHumi);//
      
      int respuesta = redNeuronal(String(t), String(1), String(h));
      Serial.print("RED NEU:");
      Serial.println(respuesta);
    }
  }
}

Would be helpful if you indicated which code line the compiler complains about.
You also seem to have omitted some code as I cannot find the declaration of int redNeuronal().

And your code suggests you are not using a Particle devices, but this forum is for these devices only.
e.g. dtostrf() is not a function in the Particle ecosystem.

However, in systems where it exists the last parameter is supposed to be a pointer to a char buffer to hold the resulting sting not an integer as in your code. That’s the reason for your conversion error.

Your other error comes from this line

where you are trying to index a non-array int o.
With the given variable definitions you could write

  p += N[n] * o;
3 Likes