I have a number of error messages popping up and I’m wondering somebody could give me a pointer to solving them.
Error | Build | error: expected primary-expression before ‘)’ tokene | 127:12 |
---|---|---|---|
Error | GCC | expected primary-expression before ‘)’ token | 127:12 |
Error | Build | error: expected primary-expression before ‘;’ tokene | 149:39 |
Error | GCC | expected primary-expression before ‘;’ token | 149:39 |
Error | Build | error: expected unqualified-id before ‘{’ tokene | 341:3 |
Error | GCC | expected unqualified-id before ‘{’ token | 341:3 |
Error | Build | error: expected unqualified-id before ‘)’ tokene | 348:17 |
Error | GCC | expected unqualified-id before ‘)’ token | 348:17 |
Compiling .pioenvs\esp32dev\src\main.o
src\main.cpp:339:54: error: macro “dewPointFast” passed 2 argum
ents, but takes just 0
double dewPointFast(double celsius, double humidity)
I have tried adding
#define dewPointFast() that helped but didn’t work so then tried
#define dewPointFast(temp,humid) didn’t work so then tried
#define dewPointFast(celsius,humidity) that was a bit better but put up an error in the code
dPt = dewPointFast(celsius,humidity);
error: expected primary-expression before ‘;’ token
I have done similar things with the error bmp_read and getting very frustrated not knowing exactly what it’s asking for.
I will try uploading the whole programme
#include <Arduino.h>
#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <Wire.h>
#include <Adafruit_BMP280.h>
#include <DHT.h>
#define bmp_read
#define dewPointFast(celsius,humidity)
//#define bmp_read
#define LED_BUILTIN 15
Adafruit_BMP280 bme;
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
const char* ssid = “BTHub5-RKSM”;
const char* password = “**********”;
WiFiServer server(80);
String theme = “darkly”;
#define LED_BUILTIN2 2
int val=0;
// DHT Sensor
const int DHTPin = 16;
// Initialize DHT sensor.
DHT dht(DHTPin, DHTTYPE);
// Temporary variables
static char celsiusTemp[7];
static char fahrenheitTemp[7];
static char humidityTemp[7];
// Client variables
char linebuf[80];
int charcount=0;
float dht_t,dht_h,dht_f;
float bmp_p,bmp_t,bmp_a;
float hif,hic,h,f,dPt;
float temp2;
int lightpin = A0;
int lightv = 0;
int light2;
float humid,temp,fahr;
void setup() {
dht.begin();
Serial.begin(115200);
Serial.println(“Booting”);
//WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
//delay(1000);
//IPAddress Ip(192, 168, 1, 202);
// IPAddress NMask(255, 255, 255, 0);
//WiFi.softAPConfig(Ip, Ip, NMask);
//IPAddress myIP = WiFi.softAPIP();
//Serial.print("IP address: ");
//Serial.println(myIP);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println(“Connection Failed! Rebooting…”);
delay(1500);
ESP.restart();
}
server.begin();
// Port defaults to 3232
// ArduinoOTA.setPort(3232);
// Hostname defaults to esp3232-[MAC]
// ArduinoOTA.setHostname(“myesp32”);
// No authentication by default
// ArduinoOTA.setPassword(“admin”);
// Password can be set with it’s md5 value as well
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
// ArduinoOTA.setPasswordHash(“21232f297a57a5a743894a0e4a801fc3”);
ArduinoOTA
.onStart( {
String type;
if (ArduinoOTA.getCommand() == U_FLASH)
type = “sketch”;
else // U_SPIFFS
type = “filesystem”;
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
Serial.println("Start updating " + type);
})
.onEnd([]() {
Serial.println("\nEnd");
})
.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
})
.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
});
ArduinoOTA.begin();
Serial.println(“Ready”);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
pinMode(LED_BUILTIN, OUTPUT);
pinMode(LED_BUILTIN2, OUTPUT);
if (!bme.begin()) {
Serial.println(“Could not find a valid BMP280 sensor, check wiring!”);
while (1);
}
}
void loop() {
// ArduinoOTA.handle();
ArduinoOTA.handle();
for(int i = 0; i< 15; i++){
delay(200);
ArduinoOTA.handle();}
bmp_read();
lightv=analogRead(lightpin);
light2=lightv/10;
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds ‘old’ (its a very slow sensor)
humid = dht.readHumidity();
// Read temperature as Celsius (the default)
temp = dht.readTemperature();
temp2=temp*2;
// Read temperature as Fahrenheit (isFahrenheit = true)
fahr = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(humid) || isnan(temp) || isnan(fahr)) {
Serial.println(“Failed to read from DHT sensor!”);
return;
}
// Compute heat index in Fahrenheit (the default)
hif = dht.computeHeatIndex(fahr, humid);
// Compute heat index in Celsius (isFahreheit = false)
hic = dht.computeHeatIndex(temp, humid, false);
dPt = dewPointFast(celsius,humidity);
Serial.println(“*************************”);
Serial.print("Dew PointFast (°C): ");
Serial.println(dPt);
Serial.print("Temperature (°C) : ");
Serial.println(temp, 2);
Serial.print("Temperature (°F) : ");
Serial.println((float)fahr, 2);
Serial.print("Humidity (%) : ");
Serial.println(humid, 2);
Serial.print(“Heat Index : “);
Serial.print(hic);
Serial.print(” (C) “);
Serial.print(hif);
Serial.println(” (F)”);
Serial.print(“Light (%) : “);
Serial.println(lightv);
Serial.println(””);
Serial.print("T: “);
Serial.print(bmp_t,2);
Serial.print(” P: “);
Serial.print(bmp_t,2);
Serial.print(” A: ");
Serial.print(bmp_a,2);
WiFiClient client = server.available();
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println(“Connection: close”); // the connection will be closed after completion of the response//
client.println();
client.println(“”);
client.println(“”);
client.println(“”);
client.println(“”);
client.println(“ESP8266 & DHT22 Sensor LoRa ”);
client.println(“\n”);
client.println(“
client.println(“
client.println(“
client.println(“
ESP8266 & DHT22 Sensor LoRa
”);client.println(“
client.println(“
”);”);
client.print(“Humidity (%) : “);
client.println(humid, 2);
client.print(“Temperature (C) : “);
client.println(temp, 2);
client.print(“Temperature (F) : “);
client.println((float)fahr, 2);
client.print(“Heat Index : “);
client.print(hic);
client.print(” (C) “);
client.print(hif);
client.println(” (F)”);
client.print(“Dew PointFast (C) : “);
client.println(dPt);
client.print(“Light (%) : “);
client.println(lightv);
client.println(”
client.println(”
client.println(”
client.println(”
client.println(””);
client.println(“”);
client.println(“”);
client.println(“”);
client.println(“* {box-sizing: border-box}”);
client.println(“.container {”);
client.println(“width: 100%;”);
client.println(“background-color: #1c1c23;”);
client.println(“}”);
client.println(“.skills {”);
client.println(“text-align: center;”);
client.println(“padding-right: 20px;”);
client.println(" line-height: 20px;“);
//client.println(“color: white;”);
client.println(”}");
client.print(“.html {width: “);
client.print(humid, 2);
client.println(”%; background-color: #4CAF50;}”);
client.print(“.css {width: “);
client.print(temp2, 2);
client.println(”%; background-color: #2196F3;}”);
client.print(“.js {width: “);
client.print(light2);
client.println(”%; background-color: #f44336;}”);
client.println(“”);
client.println(“”);
client.println(“”);
client.println(“
Humidity
”);client.println(“
client.print(“
client.print(humid, 2);
client.println(“%
client.println(“
client.println(“
Temperature
”);client.println(“
client.print(“
client.print(temp, 2);
client.println(“C
client.println(“
client.println(“
Light
”);client.println(“
client.print(“
client.print(lightv);
client.println(“%
client.println(“
/*
//client.println(“{”);
//client.println(“<background-color: lightblue;”);
//client.println(“}”);
client.println(“”);
client.println(“#myProgress {”);
client.println(“width: 100%;”);
client.println(“background-color: #ddd;”);
client.println(“}”);
client.println(“#myBar {”);
client.print(“width: “);
client.print(temp2, 2);
client.println(”%;”);
client.println(“height: 30px;”);
client.println(“background-color: #4CAF50;”);
client.println(“text-align: center;”);
client.println(“line-height: 30px;”);
client.println(“color: white;”);
client.println(“}”);
client.println(“”);
client.println(“”);
client.println(“
JavaScript Progress Bar
”);client.println(“
client.print("
client.print(temp,2);
client.println(” C
client.println(”
*/
client.print(”\n");
}
double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double t = (a * celsius) / (b + celsius) + log(humidity*0.01);
double Td = (b * t) / (a - t);
return Td;
}
void bmp_read(){
// delay (500);
if (!bme.begin()) {
Serial.println(“Could not find a valid BMP280 sensor, check wiring!”);
while (1);
}
bmp_t=(bme.readTemperature());
bmp_t=bmp_t-1.65;
bmp_p =(bme.readPressure());
bmp_p=bmp_p/100;
bmp_a=(bme.readAltitude());
//Serial.print("T: ");
}