Tuya PIR sensor

This sensor used yaml used to compile as well again arduino_version: 2.5.1 but in this case removing it doesn’t solve the issue replacing it 2.7.1 neither.

Here’s my configuration file

substitutions:
  devicename: "pir_wc"
  wifi_ssid: "iot.ofloo.net"
  wifi_pass: !secret iot_wifi_password
  fallback_pass: !secret fallback_wifi_password
  api_pass: !secret esp_api_password
  ota_pass: !secret esp_ota_password

esphome:
  name: ${devicename}
  platform: ESP8266
  board: esp01_1m
  arduino_version: 2.5.1
  board_flash_mode: dout
  includes:
    - sb1_uart.h

wifi:
  ssid: ${wifi_ssid}
  password: ${wifi_pass}
  fast_connect: true

mqtt:
  broker: !secret mqtt_hostname
  username: !secret mqtt_username
  password: !secret mqtt_password
  birth_message:
  shutdown_message:
  will_message:

# Enable Home Assistant API
api:
  password: "${api_pass}"

# Enable over the air updates
ota:
  password: "${ota_pass}"

uart:
  - tx_pin: 1
    rx_pin: 3
    baud_rate: 9600
    id: uart0

logger:
  level: INFO
  hardware_uart: UART1

sensor:
  - platform: wifi_signal
    name: "${devicename} WiFi Signal"
    update_interval: 300s
    expire_after:
    filters: []
  - platform: adc
    name: "${devicename} Battery"
    update_interval: 300s
    expire_after:
    pin: VCC
    filters: []

binary_sensor:
  - platform: template
    id: motion
    name: "${devicename} Motion"
    filters: []
    device_class: motion
    lambda: "return {};"

custom_component:
  - id: sb1_uart
    lambda: |-
      auto component = new SB1UARTComponent(id(uart0), id(motion));
      return {component};

Here’s the compile log:

INFO Reading configuration /config/esphome/pir_wc.yaml...
WARNING The selected Arduino framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
WARNING 'pir_wc': Using the '_' (underscore) character in the hostname is discouraged as it can cause problems with some DHCP and local name services. For more information, see https://esphome.io/guides/faq.html#why-shouldn-t-i-use-underscores-in-my-device-name
WARNING The selected Arduino framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
INFO Generating C++ source...
INFO Compiling app...
Processing pir_wc (board: esp01_1m; framework: arduino; platform: platformio/espressif8266 @ 2.6.3)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.3
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266WiFi> 1.0
|-- <AsyncMqttClient-esphome> 0.8.6
|   |-- <ESPAsyncTCP-esphome> 1.2.3
|   |   |-- <ESP8266WiFi> 1.0
|-- <ArduinoJson-esphomelib> 5.13.3
|-- <ESP8266mDNS> 1.2
|   |-- <ESP8266WiFi> 1.0
|-- <noise-c> 0.1.4
|   |-- <libsodium> 1.10018.1
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/adc/adc_sensor.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/api/api_connection.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/api/api_frame_helper.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/api/api_pb2.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/api/api_pb2_service.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/api/api_server.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/api/list_entities.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/api/proto.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/api/subscribe_state.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/api/user_services.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/api/util.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/binary_sensor/automation.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/binary_sensor/binary_sensor.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/binary_sensor/filter.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/esp8266/core.cpp.o
Compiling /data/pir_wc/.pioenvs/pir_wc/src/esphome/components/esp8266/gpio.cpp.o
src/esphome/components/esp8266/core.cpp:11:20: error: expected initializer before 'yield'
 void IRAM_ATTR HOT yield() { ::yield(); }
                    ^
src/esphome/components/esp8266/core.cpp:12:24: error: expected initializer before 'millis'
 uint32_t IRAM_ATTR HOT millis() { return ::millis(); }
                        ^
src/esphome/components/esp8266/core.cpp:13:20: error: expected initializer before 'delay'
 void IRAM_ATTR HOT delay(uint32_t ms) { ::delay(ms); }
                    ^
src/esphome/components/esp8266/core.cpp:14:24: error: expected initializer before 'micros'
 uint32_t IRAM_ATTR HOT micros() { return ::micros(); }
                        ^
src/esphome/components/esp8266/core.cpp:15:20: error: expected initializer before 'delayMicroseconds'
 void IRAM_ATTR HOT delayMicroseconds(uint32_t us) { ::delayMicroseconds(us); }
                    ^
src/esphome/components/esp8266/core.cpp:23:20: error: expected initializer before 'arch_feed_wdt'
 void IRAM_ATTR HOT arch_feed_wdt() {
                    ^
*** [/data/pir_wc/.pioenvs/pir_wc/src/esphome/components/esp8266/core.cpp.o] Error 1
src/esphome/components/esp8266/gpio.cpp: In member function 'virtual void esphome::esp8266::ESP8266GPIOPin::attach_interrupt(void (*)(void*), void*, esphome::gpio::InterruptType) const':
src/esphome/components/esp8266/gpio.cpp:43:51: error: 'attachInterruptArg' was not declared in this scope
   attachInterruptArg(pin_, func, arg, arduino_mode);
                                                   ^
src/esphome/components/esp8266/gpio.cpp: At global scope:
src/esphome/components/esp8266/gpio.cpp:88:16: error: expected initializer before 'ISRInternalGPIOPin'
 bool IRAM_ATTR ISRInternalGPIOPin::digital_read() {
                ^
src/esphome/components/esp8266/gpio.cpp:92:16: error: expected initializer before 'ISRInternalGPIOPin'
 void IRAM_ATTR ISRInternalGPIOPin::digital_write(bool value) {
                ^
src/esphome/components/esp8266/gpio.cpp:96:16: error: expected initializer before 'ISRInternalGPIOPin'
 void IRAM_ATTR ISRInternalGPIOPin::clear_interrupt() {
                ^
*** [/data/pir_wc/.pioenvs/pir_wc/src/esphome/components/esp8266/gpio.cpp.o] Error 1
========================== [FAILED] Took 6.68 seconds ==========================

Hello friend @Ofloo , this has been a while but I’m trying to do the same thing and I have the same problem as you.
Did you manage to solve it?

Very thankful

Actually don’t use that sensor anymore still got it though, so … adjusted configuration to see if I could make it compile:

Clean build files & edit sb1_uart.h make sure you find the correct sb1_uart.h as for me for some reason there where files in 3 locations but been upgrading esphome for years so …

This will compile, … just tried it however didn’t test and update it. So that’s your part :stuck_out_tongue:

--- ./pir_sensor/src/sb1_uart.h
+++ ./sb1_uart.h
@@ -227,7 +227,7 @@
 
     void setup() override {
       ESP_LOGCONFIG(TAG, "Setting up SB1 UART...");
-      this->rtc_ = global_preferences->make_preference<bool>(this->sensor_->get_object_id_hash());
+      this->rtc_ = global_preferences.make_preference<bool>(this->sensor_->get_object_id_hash());
       this->rtc_.load(&this->ota_mode_);
 
       if (!this->ota_mode_) {

Use config:

substitutions:
  devicename: "pir_sensor"
  wifi_ssid: "your wifi network"
  wifi_pass: !secret iot_wifi_password
  fallback_pass: !secret fallback_wifi_password
  api_pass: !secret esp_api_password
  ota_pass: !secret esp_ota_password

esphome:
  name: ${devicename}
  platform: ESP8266
  board: esp01_1m
  #arduino_version: 2.5.1
  board_flash_mode: dout
  includes:
    - sb1_uart.h

wifi:
  ssid: ${wifi_ssid}
  password: ${wifi_pass}
  fast_connect: true

mqtt:
  broker: !secret mqtt_hostname
  username: !secret mqtt_username
  password: !secret mqtt_password
  birth_message:
  shutdown_message:
  will_message:

# Enable Home Assistant API
api:
  #password: "${api_pass}"
  encryption:
    key: "${api_pass}"

# Enable over the air updates
ota:
  password: "${ota_pass}"

uart:
  - tx_pin: 1
    rx_pin: 3
    baud_rate: 9600
    id: serial

logger:
  level: INFO
  hardware_uart: UART1

sensor:
  - platform: wifi_signal
    name: "${devicename} WiFi Signal"
    update_interval: 300s
    expire_after:
    filters: []
  - platform: adc
    name: "${devicename} Battery"
    update_interval: 300s
    expire_after:
    pin: VCC
    filters: []

binary_sensor:
  - platform: template
    id: motion
    name: "${devicename} Motion"
    filters: []
    device_class: motion
    lambda: "return {};"

custom_component:
  - id: sb1_uart
    lambda: |-
      auto component = new SB1UARTComponent(id(serial), id(motion));
      return {component};

I just noticed in my diff is the other way around

--- ./pir_sensor/src/sb1_uart.h
+++ ./sb1_uart.h
@@ -227,7 +227,7 @@
 
     void setup() override {
       ESP_LOGCONFIG(TAG, "Setting up SB1 UART...");
-      this->rtc_ = global_preferences.make_preference<bool>(this->sensor_->get_object_id_hash());
+      this->rtc_ = global_preferences->make_preference<bool>(this->sensor_->get_object_id_hash());
       this->rtc_.load(&this->ota_mode_);
 
       if (!this->ota_mode_) {

The “.” needs to be replaced with “->”