• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Visual studio problem

Q&A Forum › Category: ESP32 › Visual studio problem
0 Vote Up Vote Down
Marcos Silva asked 2 years ago

Hi Sara !! Hope they are ok.
I’m having trouble when I implement the item 3.3 – Send Data to the Database: Sensor Readings with DHT22 sensor, as the following concatenation error has appeared:

Serial.println(“PATH: ” + fbdo.dataPath());

more than one operator “+” matches these operands:C/C++(350)

main.cpp(77, 25): function “operator+(const StringSumHelper &lhs, const String &rhs)” (declared at line 174 of “C:\Users\Sucen-DCV\.platformio\packages\framework-arduinoespressif32\cores\esp32\WString.h”)
main.cpp(77, 25): function “operator+(MB_String &&lhs, const MB_String &rhs)” (declared at line 2048 of “C:\Users\Sucen-DCV\Documents\PlatformIO\Projects\Firebase_Send\.pio\libdeps\heltec_wifi_lora_32_V2\Firebase Arduino Client Library for ESP8266 and ESP32\src\json\MB_String.h”)
main.cpp(77, 25): operand types are: const char [7] + String

Thanks

Look the full skech

#include <Arduino.h>
#include <WiFi.h>
#include <Wire.h>
#include <Firebase_ESP_Client.h>
#include <DHT.h>

// Provide the token generation process info.
#include “addons/TokenHelper.h”

// Provide the RTDB payload printing info and other helper functions.
#include “addons/RTDBHelper.h”

// Insert your network credentials
#define WIFI_SSID “”
#define WIFI_PASSWORD “”

// Insert Firebase project API Key
#define API_KEY “”

// Insert Authorized Email and Corresponding Password
#define USER_EMAIL “”
#define USER_PASSWORD “”

// Insert RTDB URLefine the RTDB URL
#define DATABASE_URL “”

// Define Firebase objects
FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig config;

// Variable to save USER UID
String uid;

// Variables to save database paths
String databasePath;
String tempPath;
String humPath;
String presPath;

//define GPIO do DHT22
#define pinDHT 16
#define tipoDHT DHT22

// DHT22 sensor
DHT dht(pinDHT, tipoDHT);

float temperatura;
float umidade;
float pressure;

// Timer variables (send new readings every three minutes)
unsigned long sendDataPrevMillis = 0;
unsigned long timerDelay = 180000;

// Initialize WiFi
void initWiFi() {
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print(“Connecting to WiFi ..”);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(‘.’);
delay(1000);
}
Serial.println(WiFi.localIP());
Serial.println();
}

// Write float values to the database
void sendFloat(String path, float value){
if (Firebase.RTDB.setFloat(&fbdo, path.c_str(), value)){
Serial.print(“Writing value: “);
Serial.print (value);
Serial.print(” on the following path: “);
Serial.println(path);
Serial.println(“PASSED”);
Serial.println(“PATH: ” + fbdo.dataPath());
Serial.println(“TYPE: ” + fbdo.dataType());
}
else {
Serial.println(“FAILED”);
Serial.println(“REASON: ” + fbdo.errorReason());
}
}

void setup() {
Serial.begin(115200);
// Initialize DHT22 sensor
dht.begin();
initWiFi();
// Assign the api key (required)
config.api_key = API_KEY;
// Assign the user sign in credentials
auth.user.email = USER_EMAIL;
auth.user.password = USER_PASSWORD;
// Assign the RTDB URL (required)
config.database_url = DATABASE_URL;
Firebase.reconnectWiFi(true);
fbdo.setResponseSize(4096);
// Assign the callback function for the long running token generation task */
config.token_status_callback = tokenStatusCallback; //see addons/TokenHelper.h
// Assign the maximum retry of token generation
config.max_token_generation_retry = 5;
// Initialize the library with the Firebase authen and config
Firebase.begin(&config, &auth);
// Getting the user UID might take a few seconds
Serial.println(“Getting User UID”);
while ((auth.token.uid) == “”) {
Serial.print(‘.’);
delay(1000);
}
// Print user UID
uid = auth.token.uid.c_str();
Serial.print(“User UID: “);
Serial.println(uid);
// Update database path
databasePath = “/UsersData/” + uid;
// Define database path for sensor readings
// –> UsersData/<user_uid>/sensor/temperature
tempPath = databasePath + “/sensor/temperature”;
// –> UsersData/<user_uid>/sensor/humidity
humPath = databasePath + “/sensor/humidity”;
// –> UsersData/<user_uid>/sensor/pressure
presPath = databasePath + “/sensor/pressure”;
}
void loop(){
// Send new readings to database
if (Firebase.ready() && (millis() – sendDataPrevMillis > timerDelay || sendDataPrevMillis == 0)){
sendDataPrevMillis = millis();
// Get latest sensor readings
temperatura = dht.readTemperature();
umidade = dht.readHumidity();
// Send readings to database:
sendFloat(tempPath, temperatura);
sendFloat(humPath, umidade);
}
}

🇧🇷

13 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi.
Can you please share your code using github gist or pastebin?
So that the formatting is not messed up and I can test the code.
Thank you.
Regards,
Sara

0 Vote Up Vote Down
Marcos Silva answered 2 years ago

Hi Sara,
I upload the same sketch into the arduino IDE and it worked fine. I think the problem is in my visual studio. Do you have any tips to fix it. Follow the github link of the files: Your Repositories (github.com)

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

I’m not sure what might be the issue.
What does your platformio.ini file look like?
Regards
Sara

0 Vote Up Vote Down
Marcos Silva answered 2 years ago

[env:heltec_wifi_lora_32_V2]
platform = espressif32
board = heltec_wifi_lora_32_V2
framework = arduino
monitor_speed = 115200
lib_deps =
    mobizt/Firebase Arduino Client Library for ESP8266 and ESP32@^4.2.7
    adafruit/Adafruit Unified Sensor@^1.1.7
    adafruit/DHT sensor library@^1.4.4

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Are you using the same library versions in Arduino IDE?
Maybe there is some incompatibility between library versions…

0 Vote Up Vote Down
Marcos Silva answered 2 years ago

Yes, I do. Did you get run the sketch that i sent?

0 Vote Up Vote Down
Marcos Silva answered 2 years ago

Go to Firebase_DHT22 in  Your Repositories (github.com)

0 Vote Up Vote Down
Marcos Silva answered 2 years ago

Sorry. The libraries Firebase is same, but adafruit libraries aren’t equals versions. How to put the same version in the VS.

0 Vote Up Vote Down
Marcos Silva answered 2 years ago

Ok. All libraries are the same version, but they don’t solved the problem.

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi again.
I tried your code, and even though Intelisense marks the “+” as an error, the code compiles just fine.
Did you try compiling the code?
Regards,
Sara

0 Vote Up Vote Down
Marcos Silva answered 2 years ago

Good News!! I will try
Thank you 

0 Vote Up Vote Down
Marcos Silva answered 2 years ago

Hi again.
My code is working fine
Regards.
Marcos
 

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Great.
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.