ERR Arduino ESP32 MESH

claudio nizza's picture

Offline

Joined: May 14, 2021

Replies: 0
ERR Arduino ESP32 MESH
May 14, 2021 - 9:52am

help
I tried to upload the site code to ESp32 to create a MESH network. it gives me back a series of errors that I don't know how to get out of it .. can you help me.

below the err.code

In file included from C:\Users\xsf4\Documents\Arduino\libraries\Painless_Mesh\src/painlessmesh/ntp.hpp:16,
                 from C:\Users\xsf4\Documents\Arduino\libraries\Painless_Mesh\src/painlessmesh/mesh.hpp:6,
                 from C:\Users\xsf4\Documents\Arduino\libraries\Painless_Mesh\src/painlessMeshConnection.h:17,
                 from C:\Users\xsf4\Documents\Arduino\libraries\Painless_Mesh\src/painlessMesh.h:21,
                 from C:\Users\xsf4\Documents\arduino\myMesh_test\myMesh_test.ino:1:
C:\Users\xsf4\Documents\Arduino\libraries\Painless_Mesh\src/painlessmesh/router.hpp: In function 'void painlessmesh::router::handleNodeSync(T&, painlessmesh::protocol::NodeTree, std::shared_ptr<_Tp>)':
C:\Users\xsf4\Documents\Arduino\libraries\Painless_Mesh\src/painlessmesh/router.hpp:162:26: warning: lambda capture initializers only available with -std=c++14 or -std=gnu++14
     mesh.addTask([&mesh, remoteNodeId = newTree.nodeId]() {
                          ^~~~~~~~~~~~
C:\Users\xsf4\Documents\Arduino\libraries\Painless_Mesh\src/painlessmesh/router.hpp:189:26: warning: lambda capture initializers only available with -std=c++14 or -std=gnu++14
     mesh.addTask([&mesh, nodeId = newTree.nodeId]() {
                          ^~~~~~
In file included from C:\Users\xsf4\Documents\Arduino\libraries\Painless_Mesh\src/painlessMesh.h:24,
                 from C:\Users\xsf4\Documents\arduino\myMesh_test\myMesh_test.ino:1:
C:\Users\xsf4\Documents\Arduino\libraries\Painless_Mesh\src/arduino/wifi.hpp: In member function 'void painlessmesh::wifi::Mesh::eventHandleInit()':
C:\Users\xsf4\Documents\Arduino\libraries\Painless_Mesh\src/arduino/wifi.hpp:252:22: error: 'SYSTEM_EVENT_SCAN_DONE' is not a member of 'arduino_event_id_t'
         WiFiEvent_t::SYSTEM_EVENT_SCAN_DONE);
                      ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\xsf4\Documents\Arduino\libraries\Painless_Mesh\src/arduino/wifi.hpp:261:22: error: 'SYSTEM_EVENT_STA_START' is not a member of 'arduino_event_id_t'
         WiFiEvent_t::SYSTEM_EVENT_STA_START);
                      ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\xsf4\Documents\Arduino\libraries\Painless_Mesh\src/arduino/wifi.hpp:272:22: error: 'SYSTEM_EVENT_STA_DISCONNECTED' is not a member of 'arduino_event_id_t'
         WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED);
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\xsf4\Documents\Arduino\libraries\Painless_Mesh\src/arduino/wifi.hpp:282:22: error: 'SYSTEM_EVENT_STA_GOT_IP' is not a member of 'arduino_event_id_t'
         WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP);
                      ^~~~~~~~~~~~~~~~~~~~~~~
C:\Users\xsf4\Documents\arduino\myMesh_test\myMesh_test.ino: In function 'void sendMessage()':
myMesh_test:12:16: error: 'construnct_json' was not declared in this scope
   String msg = construnct_json();
                ^~~~~~~~~~~~~~~
myMesh_test:14:3: error: 'taskSendMessage' was not declared in this scope
   taskSendMessage.setInterval( random( TASK_SECOND * 1, TASK_SECOND * 5 ));
   ^~~~~~~~~~~~~~~
C:\Users\xsf4\Documents\arduino\myMesh_test\myMesh_test.ino:14:3: note: suggested alternative: 'sendMessage'
   taskSendMessage.setInterval( random( TASK_SECOND * 1, TASK_SECOND * 5 ));
   ^~~~~~~~~~~~~~~
   sendMessage
Più di una libreria trovata per "WiFi.h"
Usata: C:\Users\xsf4\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0-alpha1\libraries\WiFi
Non usata: C:\Program Files (x86)\Arduino\libraries\WiFi
Non usata: C:\Users\xsf4\Documents\Arduino\libraries\WiFi

below the arfuino code

#include <painlessMesh.h>
#include <Arduino_JSON.h>
//#define BME_280
#define DHT22
//#define DS18B20
//#define ENABLE_LOG
String nodeName = "NODE_4"; // Name needs to be unique
float temp(NAN), hum(NAN), pres(NAN);
//########################## Init_BME280 ##########################
#ifdef BME_280
#include <BME280I2C.h>
#include <Wire.h>
BME280I2C bme;
BME280::TempUnit tempUnit(BME280::TempUnit_Celsius);
BME280::PresUnit presUnit(BME280::PresUnit_Pa);
#endif
//__________________________ End of _BME280 __________________________
//########################## Init_DHT22 ##########################
#ifdef DHT22
#include "DHT.h"
#define DHTPIN 4
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
#endif
//__________________________ End of DHT22 __________________________
//########################## Init_Ds18B20 ##########################
#ifdef DS18B20
#include <OneWire.h>
#include <DallasTemperature.h>
const int oneWireBus = 4;
OneWire oneWire(oneWireBus);
DallasTemperature ds18b20(&oneWire);
#endif
//__________________________ End of DHT22 __________________________
#define   MESH_PREFIX     "whateverYouLike"
#define   MESH_PASSWORD   "somethingSneaky"
#define   MESH_PORT       5555
Scheduler userScheduler; // to control your personal task
painlessMesh  mesh;
JSONVar myVar;
void sendMessage() {
  String msg = construnct_json();
  mesh.sendBroadcast( msg );
  taskSendMessage.setInterval( random( TASK_SECOND * 1, TASK_SECOND * 5 ));
}
Task taskSendMessage( TASK_SECOND * 1 , TASK_FOREVER, &sendMessage );
// Needed for painless library
void receivedCallback( uint32_t from, String &msg ) {
  Serial.printf("startHere: Received from %u msg=%s\n", from, msg.c_str());
}
void newConnectionCallback(uint32_t nodeId) {
  Serial.printf("--> startHere: New Connection, nodeId = %u\n", nodeId);
}
void changedConnectionCallback() {
  Serial.printf("Changed connections\n");
}
void nodeTimeAdjustedCallback(int32_t offset) {
  Serial.printf("Adjusted time %u. Offset = %d\n", mesh.getNodeTime(), offset);
}
void setup()
{
  Serial.begin(115200);
  Serial.println(nodeName);
//  mesh.setDebugMsgTypes( ERROR | STARTUP | MESH_STATUS | CONNECTION | SYNC | COMMUNICATION | GENERAL | MSG_TYPES | REMOTE ); // all types on
  mesh.setDebugMsgTypes( ERROR | STARTUP );  // set before init() so that you can see startup messages
  mesh.init( MESH_PREFIX, MESH_PASSWORD, &userScheduler, MESH_PORT );
  mesh.onReceive(&receivedCallback);
  mesh.onNewConnection(&newConnectionCallback);
  mesh.onChangedConnections(&changedConnectionCallback);
  mesh.onNodeTimeAdjusted(&nodeTimeAdjustedCallback);
  userScheduler.addTask( taskSendMessage );
  taskSendMessage.enable();
#ifdef BME_280
  Wire.begin();
  while (!bme.begin())
  {
    Serial.println("Could not find BME280 sensor!");
    delay(1000);
  }
  // bme.chipID(); // Deprecated. See chipModel().
  switch (bme.chipModel())
  {
    case BME280::ChipModel_BME280:
      Serial.println("Found BME280 sensor! Success.");
      break;
    case BME280::ChipModel_BMP280:
      Serial.println("Found BMP280 sensor! No Humidity available.");
      break;
    default:
      Serial.println("Found UNKNOWN sensor! Error!");
  }
#endif
#ifdef DHT22
  Serial.println(F("DHTxx test!"));
  dht.begin();
#endif
#ifdef DS18B20
  ds18b20.begin();
#endif
}
void loop()
{
  mesh.update();
  // construnct_json();
}
String construnct_json()
{
#ifdef BME_280
  bme.read(pres, temp, hum, tempUnit, presUnit); // update with new values
  pres = pres / 100;
  myVar["Sensor Type"] = "BME280";
  myVar["Node Name"] = nodeName;
  myVar["Temperature"] = serialized(String(temp, 2)); // serialized need to conver flot values
  myVar["pres"] = serialized(String(pres, 2));// serialized need to conver flot values
#ifdef ENABLE_LOG
  Serial.println(JSON.stringify(myVar)); //stringify converts the arry to a string
#endif
  return JSON.stringify(myVar);
#endif
#ifdef DHT22
  temp = dht.readTemperature();
  hum = dht.readHumidity();
  myVar["Sensor Type"] = "DHT22";
  myVar["Node Name"] = nodeName;
  myVar["Temperature"] = serialized(String(temp));
  myVar["Humidity"] = serialized(String(hum));
#ifdef ENABLE_LOG
  Serial.println(JSON.stringify(myVar));
#endif
  return JSON.stringify(myVar);
#endif
#ifdef DS18B20
  ds18b20.requestTemperatures();
  temp = ds18b20.getTempCByIndex(0);
  myVar["Sensor Type"] = "DS18B20";
  myVar["Node Name"] = nodeName;
  myVar["Temperature"] = serialized(String(temp));
#ifdef ENABLE_LOG
  Serial.println(JSON.stringify(myVar));
#endif
  return JSON.stringify(myVar);
#endif
}

 

Sourav Gupta's picture

Offline

Joined: Feb 12, 2018

Replies: 628

Check this two library if it is installed properly or not -

 

#include <painlessMesh.h>
#include <Arduino_JSON.h>