0

im trying to make a small sensor cluster (bmp180 and si7021) connected to a esp-01. im using atom and platformIO. i created classes for each sensor starting from examples for arduino with header and source files for each sensor. created class for mqtt communication to a mqtt broker on a ubuntu server. i want to creat a setup page that can be accessed only if when i have low voltage on the adc pin that i use to monitor the batery voltage (adding a jumper to ground the input) the page wil be used to set the ssid and password where to connect when in normal mode and also the mqtt broker and topics to use.

the problem id i cant make the class to work:

header file:

 #ifndef WEB_h
 #define WEB_h

 #include <ESP8266WiFi.h>
 #include <WiFiClient.h>
 #include <ESP8266WebServer.h>

 #ifndef APSSID 
 #define APSSID "ESPap"
 #define APPSK  "1234"
 #endif
 class My_web
 {
   ESP8266WebServer server;

 private:

     /* Set these to your desired credentials. */
     const char *ssid = APSSID;
     const char *password = APPSK;

 public:

   My_web(): server(80){}
   void handleRoot();
   void setup();
   void loop();

 };

 #endif

cpp file:

#include "main.h"  (<= all header files are included in main)

/* Just a little test message.  Go to http://192.168.4.1 in a web browser
   connected to this access point to see it.
*/
void My_web::handleRoot() {
  server.send(200, "text/html", "<h1>You are connected</h1>");
}

void My_web::setup() {
  delay(1000);
  Serial.begin(115200);
  Serial.println();
  Serial.print("Configuring access point...");
  /* You can remove the password parameter if you want the AP to be open. */
  WiFi.softAP(ssid, password);

  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  server.on("/", handleRoot);        <---  this line gives error 
  server.begin();
  Serial.println("HTTP server started");
}

void My_web::loop() {
  server.handleClient();
}



the

server.on("/", handleRoot); 

from cpp gives error :

invalid use of non-static member function 'void My_web::handleRoot()'

had a prooblem with the server definition in header file:

ESP8266WebServer server(80);

not working but changed to:

ESP8266WebServer server;

public:
My_web(): server(80){}

sergiu
  • 1
  • 4

0 Answers0