Declaration errors

I get a few errors in following file I'm including in the .yaml file in ESPHome:

#include "esphome.h"

class MyCustomComponent : public Component, public UARTDevice {
 public:
  MyCustomComponent(UARTComponent *parent) : UARTDevice(parent) {}

  void setup() override {
    // nothing to do here
  }
  void loop() override {
    // Use Arduino API to read data, for example
    String line = readString();
    int i = parseInt();
    while (available()) {
      char c = read();
    }
    // etc
  }
};

Can't upload to my Wemos D1 mini because of:

A) error : 'readString' is not declared in scope
B) ParseInt is not declared in scope

Can anyone help me with this ?

Thanks !

Kr,

BArt

Welcome to the forum

Your topic was MOVED to its current forum category as it is more suitable than the original

Did you mean to use Serial.readString() and Serial.parseInt() ?

No, I got this code from the ESPhome website and says this code :-/

To use Arduino features you need an Arduino sketch. Does your source file have the .ino extension?

If this is a .cpp file separate from the sketch, add #include <Ardiuno.h> at the top to define the Arduino functions.

Please post a link to the page that you got the code from

HI UKHeliBob,

This is the link to the page. I'm trying to get a UART Ultrasonic sensor to communicate with my Wemos D1 mini

Kr,

Bart Weemaels

Hi Joh,

This is probably where I'm lost. I'm using ESPHome, where I have a yaml file that refers to a .h file. This .h file is located in my esphome folder. Like you said, the .h file is not using the arduino specific functions properly

Kr,

Bart

I see no link

Apologies,

Here's the link : Custom UART Device — ESPHome

Kr,

Bart

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.