HP303b expected type-specifier SOLVED

Im getting errors compiling the HP303b code:

hp303.yaml: In lambda function:
hp303.yaml:52:28: error: expected type-specifier before ‘HP303BSensor’
hp303.yaml:54:24: error: could not convert ‘{hp_sensor}’ from ‘’ to 'std::vector<esphome::sensor::Sensor

i2c:
  sda: D2
  scl: D1
  scan: True

sensor:
  - platform: custom
    lambda: |-
      auto hp_sensor = new HP303BSensor();
      App.register_component(hp_sensor);
      return {hp_sensor};

    sensors:
      name: "HP Barometric Pressure"
      icon: "mdi:gauge"
      unit_of_measurement: hPa
      accuracy_decimals: 1

any ideas why?
thanks
jim

where does this code come from?

Have you got the relevant libraries and .h file installed?

EDIT I think the libraries should be downloaded by esphome, but you do need the .h file.

Yes I do have them as library functions. I don’t know where to put them for use by the include

As I say the libraries should be handled by esphome. The .h file should be in the /config/esphome directory.

thank you so much - it works now. I put the hpe303b.h file in the esphome directory and it compiles now.

  name: $devicename
  platform: $platform
  board: $board
  comment: "${comment}"
  libraries:
    - "Wire"
#    - "esphome=https://github.com/dmptrluke/esphome_hp303b.git"
    - "SPI" # lib from platformio
    - "epshome=https://github.com/wemos/LOLIN_HP303B_Library.git"
  includes:
    - hp303b.h
        

the last time i tried this i did now have the - “Wire” library at the top and iirc i was generating the same error.

the Solution was:
put the line - “Wire” at the top of the libraries section
put the hp303b.h file in the esphome directory

jim

Im trying to get this sensor working - and can’t work out where this set of code is supposed to go?

  name: $devicename
  platform: $platform
  board: $board
  comment: "${comment}"
  libraries:
    - "Wire"
#    - "esphome=https://github.com/dmptrluke/esphome_hp303b.git"
    - "SPI" # lib from platformio
    - "epshome=https://github.com/wemos/LOLIN_HP303B_Library.git"
  includes:
    - hp303b.h

In the yaml file in esphome.

Thanks for the response.

I’ve got the following in the yaml for the esphome board, (the 2 other sensors with esphome support working fine.)

  name: esphome-web-dadc78
  friendly_name: Garden Sensors

esp8266:
  board: esp01_1m

libraries:
  - "Wire"
  - "esphome=https://github.com/dmptrluke/esphome_hp303b.git"
  - "SPI" # lib from platformio
  - "epshome=https://github.com/wemos/LOLIN_HP303B_Library.git"
includes:
  - hp303b.h

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "#######################"

ota:


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-Dadc78"
    password: "################"


i2c:
  sda: 4
  scl: 5
  scan: true

captive_portal:
sensor:
- platform: sgp30
  eco2:
    name: "Garden eCO2"
    accuracy_decimals: 1
  tvoc:
    name: "Garden TVOC"
    accuracy_decimals: 1
  store_baseline: yes
  address: 0x58
  update_interval: 1s

- platform: sht3xd
  temperature:
    name: "Garden Temperature"
  humidity:
    name: "Garden Humidity"
  address: 0x45
  update_interval: 30s

- platform: custom
  lambda: |-
    auto hp_sensor = new HP303BSensor();
    App.register_component(hp_sensor);
    return {hp_sensor};

  sensors:
    name: "HP Barometric Pressure"
    icon: "mdi:gauge"
    unit_of_measurement: hPa
    accuracy_decimals: 1

I’m getting the following error when I try and compile it:


libraries: [source /config/esphome/esphome-web-dadc78.yaml:9]
  
  Component not found: libraries.
  - Wire
  - esphome=https://github.com/dmptrluke/esphome_hp303b.git
  - SPI
  - epshome=https://github.com/wemos/LOLIN_HP303B_Library.git
includes: [source /config/esphome/esphome-web-dadc78.yaml:14]
  
  Component not found: includes.
  - hp303b.h

I have placed the hp303.h file in the “/config/esphome” file, which I assume is where is referred to above.