[Solved] [Error] unqualified-id before token, basic data acquisition program

#include <DHT.h>
#include <math.h>
#include <stdlib.h>
#include <stdafx.h>
#include <iostream>

#define DHT1PIN 2
#define DHT1TYPE DHT11 // DHT 11
DHT dht1(DHT1PIN, DHT1TYPE); 


void setup();
void loop();

void setup(){
  Serial.begin(9600);
  Serial.println("DHT11");
  
  dht1.begin();
}

void loop() {
    
  float h1 = dht1.readHumidity();
  float t1 = dht1.readTemperature();
  
 
  
  if (isnan(t1) || isnan(h1)) {
  Serial.println("Failed to read from DHT #1");
  } else { 
    Serial.print("Humidity 1: "); 
    Serial.print(h1); 
    Serial.print(" %\t") ; 
    Serial.print("Temperature 1: "); 
    Serial.print(t1); 
    Serial.println(" *C");
   delay(1000);
  }
}


  
{  Serial.println ("Ponto 1");
   tambiente = t1+273.15;
   entalpia = 1.01*t1;
   lv = 2538.2+2.91*t1;
   hv=lv+1.88*t1;
   pfi=h1;
   x=(-27405.526+97.5413*tambiente-0.146244*(tambiente*tambiente)+0.00012558*(tambiente*tambiente*tambiente)-0.000000048502*(tambiente*tambiente*tambiente*tambiente))/(4.34903*tambiente-0.0039381*tambiente*tambiente);
   pvs=22105649.25*exp(x)/1000;
   pv=pfi*pvs/100;
   pa=101.325-pv
   va=((287,05*(tambiente))/pa)/1000;
   uabs=0.6219*pv/(pb-pv);
   vv=(461.52*tambiente)/(pv*100)/1000;
   tpo=(31.685*log10(pv*1000/613.34))/(1-0.1311*log10(pv*1000/613.34));
   hesp=4.1868*(0.24*t2+(597.3+0.441*t2)*uabs);
   
}

thats a code for school project, i'm getting this error

error: expected unqualified-id before '{' token

those steps of t1, h1 will be repeated till t6,h6. ( i will use 6 sensors) so i want to know if it will be possible also, to get the values like i programmed, as i still couldn't run the program.

any tips to make the program more compact will be well received.

Remove

void setup();
void loop();

There is a lot of code that is not in a function. All C code must be in a function. The problem is with this code:

{  Serial.println ("Ponto 1");
   tambiente = t1+273.15;
   entalpia = 1.01*t1;
   lv = 2538.2+2.91*t1;
   hv=lv+1.88*t1;
   pfi=h1;
   x=(-27405.526+97.5413*tambiente-0.146244*(tambiente*tambiente)+0.00012558*(tambiente*tambiente*tambiente)-0.000000048502*(tambiente*tambiente*tambiente*tambiente))/(4.34903*tambiente-0.0039381*tambiente*tambiente);
   pvs=22105649.25*exp(x)/1000;
   pv=pfi*pvs/100;
   pa=101.325-pv
   va=((287,05*(tambiente))/pa)/1000;
   uabs=0.6219*pv/(pb-pv);
   vv=(461.52*tambiente)/(pv*100)/1000;
   tpo=(31.685*log10(pv*1000/613.34))/(1-0.1311*log10(pv*1000/613.34));
   hesp=4.1868*(0.24*t2+(597.3+0.441*t2)*uabs);
   
}

those are the equations, you mean, i should place this in a 'void', declare the values and them run again ? but the idea is to get the values directly from the sensor.

all the equations run around t1 and h1 that are achieved by the sensors

There is no such thing as "... a 'void'...". setup() and loop() are functions that return void (meaning that they return nothing). The empty parentheses also indicate that they take no inputs.

I don't know where to put your equations, but I KNOW that they don't belong where they are. So does the compiler.

It looks like the input to the function is t1, but I can't figure out what the output is. Perhaps there is more than one output?
A function must have zero or more inputs.
A function must have zero or one output.

Can you break up the equations to obey these rules?

it was previously programmed in c++, having trouble now hahaha...

well, the output will be a series of values "tambiente,twb,va,entalpia"
like

Serial.print("\n Volume Especifico Ar            =  %.3f    [m3/kg]"); Serial.print(Va);

the idea is that

float h1 = dht1.readHumidity();
float t1 = dht1.readTemperature();

acquire the values, them it will be show on screen

then the equations enter, the values of h1 and t1 are inserted there and after the math is realized, it print the results.

(on theory it seems quite easy hahaha)

IT WOKED!!! EUREKA!!! HAHAHA thanks for your disponibility to help vaj4088, it worked, like this;

```
#include <DHT.h>
#include <math.h>
#include <stdlib.h>
#include <stdafx.h>
#include <iostream>

#define DHT1PIN 2
#define DHT1TYPE DHT11 // DHT 11
DHT dht1(DHT1PIN, DHT1TYPE); 


void setup(){
  Serial.begin(9600);
  Serial.println("DHT11 + MPX5050DP");
  
  dht1.begin();
}

void loop() {
  
  //MDPX5050 DP
  int reading = analogRead(1);
  float Pressure = 11.11 * reading - 2.2226;
  Serial.print(Pressure);
    
  float h1 = dht1.readHumidity();
  float t1 = dht1.readTemperature();
  
  float hv,tambiente,twb,va,entalpia,lv,tpo,pfi,x,pb,pa,pv,uabs,vv,hesp,c, pvs;
 
  
  if (isnan(t1) || isnan(h1)) {
  Serial.println("Failed to read from DHT #1");
  } else { 
    Serial.print("Humidity 1: "); 
    Serial.print(h1); 
    Serial.print(" %\t") ; 
    Serial.print("Temperature 1: "); 
    Serial.print(t1); 
    Serial.println(" *C");
   delay(1000);
   
   tambiente = t1+273.15;
   entalpia = 1.01*t1;
   lv = 2538.2+2.91*t1;
   hv=lv+1.88*t1;
   pfi=h1;
   x=(-27405.526+97.5413*tambiente-0.146244*(tambiente*tambiente)+0.00012558*(tambiente*tambiente*tambiente)-0.000000048502*(tambiente*tambiente*tambiente*tambiente))/(4.34903*tambiente-0.0039381*tambiente*tambiente);
   pvs=22105649.25*exp(x)/1000;
   pv=pfi*pvs/100;
   pa=101.325-pv;
   va=((287,05*(tambiente))/pa)/1000;
   uabs=0.6219*pv/(pb-pv);
   vv=(461.52*tambiente)/(pv*100)/1000;
   tpo=(31.685*log10(pv*1000/613.34))/(1-0.1311*log10(pv*1000/613.34));
   hesp=4.1868*(0.24*t1+(597.3+0.441*t1)*uabs);
  
  Serial.println ("Ponto 1");
  Serial.print("\n Volume Especifico Ar            =  %.3f    [m3/kg]"); Serial.print(va);
  Serial.print("\n Volume Especifico Vapor         =  %.3f    [m3/kg]"); Serial.print(vv);
  Serial.print("\n Entalpia do Ar                  =  %.2f    [kJ/kg]"); Serial.print(entalpia);
  Serial.print("\n Entalpia do Vapor               =  %.2f    [kJ/kg]"); Serial.print(hv);
  Serial.print("\n Entalpia Especifica             =  %.2f    [kJ/kg]"); Serial.print(hesp);
  Serial.print("\n Umidade Relativa                =  %.2f    [%]");     Serial.print(pfi);
  Serial.print("\n Pressao de Vapor Saturado       =  %.2f    [KPa]");   Serial.print(pvs);
  Serial.print("\n Pressao de Vapor                =  %.2f    [KPa]");   Serial.print(pv);
  Serial.print("\n Pressao de Ar seco              =  %.2f    [Kpa]");   Serial.print(pa);
  Serial.print("\n Umidade Absoluta                =  %.4f    [Kg/Kg]"); Serial.print(uabs);
  Serial.print("\n Temperatura de Ponto de Orvalho =  %.1f    [C]");     Serial.print(tpo);
  }
}
```

now the work continue to the pressure sensors, but for now the problems have gone.

If this project was going anywhere, I would be tempted to create 11 functions to calculate the results. This would be longer but easier to maintain.

However, as this is a school project, it probably ends here. If you are happy, I am happy!

HAHAHA, tell me more, any tips are welcome