Newbie starting problems

hi all
sorry but as a newb i am trying to compile my first project and have what must be some errors with a very simple solution
i have modified the ini file to contain monitor_speed = 115200 but am still getting ‘identifier Serial is not defined’ and added the Arduino include at the top of the main.cpp
it is interesting to note that Serial.begin(115200) in setup does not report an error just wherever i try to use Serial.print()
i also have the same errors with ‘millis()’ and ‘String’ in a string definition
please help me to start using pio properly, as i said before this has to be a very basic thing
thanks in advance

Please show your code and your platformio.ini file.

hi Manuel… are you always that quick, thank you
the ini file is:
platform = espressif32
board = fm-devkit
framework = arduino
monitor_speed = 115200

and the code is one of Nick Kolbans client sw for esp32 which compiles ok in arduino i have slightly modified it for readability if you want me to show the code in the includes as well please say and i will

#include <Arduino.h>

 * A BLE client example that is rich in capabilities.
 * There is a lot new capabilities implemented.
 * author unknown
 * updated by chegewara
#include "BLEDevice.h"
//#include "BLEScan.h"

static BLEUUID serviceUUID("d4d18515-37b6-4895-968f-664720297249");
static BLEUUID    charUUID1("0561b5a3-d557-4f12-b044-11c9b65b4d05");
static BLEUUID    charUUID2("ebc550e1-b776-43ac-aa95-36399b46eae1");

// The remote service we wish to connect to.
static BLEUUID serviceUUID("d4d18515-37b6-4895-968f-664720297249");
// The characteristics
static BLEUUID    charUUID1("0561b5a3-d557-4f12-b044-11c9b65b4d05");
static BLEUUID    charUUID2("ebc550e1-b776-43ac-aa95-36399b46eae1");
// variables
static bool                  doConnect = false;
static bool                  connected = false;
static bool                  doScan    = false;

static BLEAdvertisedDevice*     myDevice;
static BLERemoteCharacteristic* RCharac1;
//static BLERemoteCharacteristic* RCharac2;


#include "callbacks.h"
#include "doConnect.h"

void setup() {
  Serial.print("\n\nBLE Client application... ready\n");

  // Retrieve a Scanner and set the callback we want to use to be informed when we
  // have detected a new device.  Specify that we want active scanning and start the
  // scan to run for 5 seconds.
  BLEScan* pBLEScan = BLEDevice::getScan();
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->start(5, false);    // start scanning
} // End of setup.

long tmr = millis() + 10000;
void loop() {
  if (doConnect == true) {
    if (connectToServer()) {
      Serial.println("We are now connected to the BLE Server.");
    } else {
      Serial.println("Failed to connect to server; Nothing more we will do.");
    doConnect = false;

  // If we are connected to a peer BLE Server, update the characteristic each time we are reached
  // with the current time since boot.
  if (connected) {
    if(millis() > tmr) {
      String newValue = "Time since boot: " + String(millis()/1000);
      RCharac1->writeValue(newValue.c_str(), newValue.length());
      tmr = millis() + 10000;
  }else if(doScan){
    // this is just eample to start scan after disconnect, 
    // most likely there is better way to do it in arduino
} // End of loop

thanks again

1 Like

hi @manuelbl
once again thank you for your help it looks as though i did not have a problem
all i did was closed pio, restarted my computer and everything now seems to be working ok
i dont pretend to understand it … yet but at least its working

I did not find the doConnect.h library …

The above code example is incomplete since this file is not given. Closest match I could find was ESP32_BLE_Arduino/BLE_client.ino at master · nkolban/ESP32_BLE_Arduino · GitHub.