Smart Home Automation Forum
Kincony A16 - PIR motion sensor - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-A16 (https://www.kincony.com/forum/forumdisplay.php?fid=25)
+--- Thread: Kincony A16 - PIR motion sensor (/showthread.php?tid=2484)

Pages: 1 2


Kincony A16 - PIR motion sensor - sonalikaatc@gmail.com - 01-02-2023

HI,

I have used the KC686 A16 board for pir motion sensor model HC-SR501,

my config is
- platform: gpio
    name: "a16-input5"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 4
      mode: INPUT
      inverted: true
    device_class: motion


My output is stuck at clear and no motion is detected.

Please help ..
THANKS


RE: Kincony A16 - PIR motion sensor - admin - 01-03-2023

do you want output trigger by input PIR sensor?


RE: Kincony A16 - PIR motion sensor - sonalikaatc@gmail.com - 01-03-2023

Hi admin,
No I Just want input to be detected..
I just want to detect the input (clear and detected) in home assistant.

Thanks


RE: Kincony A16 - PIR motion sensor - admin - 01-03-2023

you can try these code for KC868-A16:
--------------------------------------------------------
esphome:
name: relay1
platform: ESP32
board: esp32dev


# Example configuration entry for ESP32
i2c:
sda: 4
scl: 5
scan: true
id: bus_a


# Example configuration entry
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO17_OUT
phy_addr: 0

# Example configuration entry
pcf8574:
- id: 'pcf8574_hub_out_1' # for output channel 1-8
address: 0x24

- id: 'pcf8574_hub_out_2' # for output channel 9-16
address: 0x25

- id: 'pcf8574_hub_in_1' # for input channel 1-8
address: 0x21

- id: 'pcf8574_hub_in_2' # for input channel 9-16
address: 0x22

# Individual outputs
switch:
- platform: gpio
name: "light1"
pin:
pcf8574: pcf8574_hub_out_1
# Use pin number 0
number: 0
# One of INPUT or OUTPUT
mode: OUTPUT
inverted: false

- platform: gpio
name: "light9"
pin:
pcf8574: pcf8574_hub_out_2
# Use pin number 0
number: 0
# One of INPUT or OUTPUT
mode: OUTPUT
inverted: false

binary_sensor:
- platform: gpio
name: "input1"
pin:
pcf8574: pcf8574_hub_in_1
# Use pin number 0
number: 0
# One of INPUT or OUTPUT
mode: INPUT
inverted: false

- platform: gpio
name: "input9"
pin:
pcf8574: pcf8574_hub_in_2
# Use pin number 0
number: 0
# One of INPUT or OUTPUT
mode: INPUT
inverted: false

# Enable logging
logger:

# Enable Home Assistant API
api:


RE: Kincony A16 - PIR motion sensor - sonalikaatc@gmail.com - 01-03-2023

Hi admin,

I tried above config but it was stuck not working...the motion is not detected..but when I connect the same sensor with ESP 32 mcu board it works.

Do I need to change the Input_IIC_address 0x39
as per your below post?

some of KC868-A16 V1.5 hardware version, PCF8574 address is changed. (if you have seen PCB is V1.5 and have GREEN label, you need to use new address value)
before is :

Relay_IIC_address 0x24
Relay_IIC_address 0x25

Input_IIC_address 0x21
Input_IIC_address 0x22


new is :

Relay_IIC_address 0x3C
Relay_IIC_address 0x3D

Input_IIC_address 0x39
Input_IIC_address 0x3A

[Image: attachment.php?aid=1256]   

if you don't know your PCF8574 address, you can use this "I2C scan" arduino IDE source code to scan address, it will print value by serial port.

here is source code: 
[Image: zip.png]   i2c-scan-a16.zip (Size: 645 bytes / Downloads: 61)


RE: Kincony A16 - PIR motion sensor - admin - 01-03-2023

yes, just replace with the new IIC address value. I think it's just IIC address value problem.


RE: Kincony A16 - PIR motion sensor - sonalikaatc@gmail.com - 01-03-2023

I tried to change the pin address.. but unfortunately the all board is not working.

So I put the old pin address and the board is working but the pir sensor is not working.

What is the problem?

Why esp32 nodemcu board is detecting the motion and your board is not working?


RE: Kincony A16 - PIR motion sensor - admin - 01-03-2023

if you are using ESPHome, after you download firmware, you can see the LOG output, ESPHome will scan IIC bus, check which IIC address have scaned? i think maybe input address is not correct.


RE: Kincony A16 - PIR motion sensor - sonalikaatc@gmail.com - 01-03-2023

Hi
Please find the below log of esphome..

I think the iic bus is correct.

HARDWARERE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- AsyncTCP-esphome @ 1.2.2
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 2.1.0
| |-- AsyncTCP-esphome @ 1.2.2
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- noise-c @ 0.1.4
| |-- libsodium @ 1.10018.1
|-- Wire @ 2.0.0
Compiling /data/a16/.pioenvs/a16/src/main.cpp.o
Linking /data/a16/.pioenvs/a16/firmware.elf
RAM: [= ] 12.6% (used 41224 bytes from 327680 bytes)
Flash: [===== ] 51.8% (used 950745 bytes from 1835008 bytes)
Building /data/a16/.pioenvs/a16/firmware.bin
Creating esp32 image...
Successfully created esp32 image.
esp32_create_combined_bin(["/data/a16/.pioenvs/a16/firmware.bin"], ["/data/a16/.pioenvs/a16/firmware.elf"])
Wrote 0xf9860 bytes to file /data/a16/.pioenvs/a16/firmware-factory.bin, ready to flash to offset 0x0
========================= [SUCCESS] Took 6.71 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of a16.local
INFO -> 192.168.x.xx
INFO Uploading /data/a16/.pioenvs/a16/firmware.bin (956512 bytes)
Uploading: [============================================================] 100% Done...

INFO Waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from a16.local using esphome API
INFO Successfully connected to a16.local
[19:51:21][I][app:102]: ESPHome version 2022.12.3 compiled on Jan 3 2023, 19:50:52
[19:51:21][C][wifi:504]: WiFi:
[19:51:21][C][wifi:362]: Local xx.xx.xxxx.xx
[19:51:21][C][wifi:363]: SSID: [redacted]
[19:51:21][C][wifi:364]: IP Address: 192.168.x.xxx
[19:51:21][C][wifi:366]: BSSID: [redacted]
[19:51:21][C][wifi:367]: Hostname: 'a16'
[19:51:21][C][wifi:369]: Signal strength: -81 dB ▂▄▆█
[19:51:21][C][wifi:373]: Channel: 11
[19:51:21][C][wifi:374]: Subnet: 255.255.255.0
[19:51:21][C][wifi:375]: Gateway: 192.168.1.1
[19:51:21][C][wifi:376]: DNS1: 192.168.1.1
[19:51:22][C][wifi:377]: DNS2: 192.168.1.1
[19:51:22][C][logger:293]: Logger:
[19:51:22][C][logger:294]: Level: DEBUG
[19:51:22][C][logger:295]: Log Baud Rate: 115200
[19:51:22][C][logger:296]: Hardware UART: UART0
[19:51:22][C][i2c.arduino:052]: I2C Bus:
[19:51:22][C][i2c.arduino:053]: SDA Pin: GPIO4
[19:51:22][C][i2c.arduino:054]: SCL Pin: GPIO5
[19:51:22][C][i2c.arduino:055]: Frequency: 50000 Hz
[19:51:22][C][i2c.arduino:058]: Recovery: bus successfully recovered
[19:51:22][I][i2c.arduino:068]: Results from i2c bus scan:
[19:51:22][I][i2c.arduino:074]: Found i2c device at address 0x21
[19:51:22][I][i2c.arduino:074]: Found i2c device at address 0x22
[19:51:22][I][i2c.arduino:074]: Found i2c device at address 0x24
[19:51:22][I][i2c.arduino:074]: Found i2c device at address 0x25
[19:51:22][C][pcf8574:021]: PCF8574:
[19:51:22][C][pcf8574:022]: Address: 0x24
[19:51:22][C][pcf8574:023]: Is PCF8575: NO
[19:51:22][C][pcf8574:021]: PCF8574:
[19:51:22][C][pcf8574:022]: Address: 0x25
[19:51:22][C][pcf8574:023]: Is PCF8575: NO
[19:51:22][C][pcf8574:021]: PCF8574:
[19:51:22][C][pcf8574:022]: Address: 0x21
[19:51:22][C][pcf8574:023]: Is PCF8575: NO
[19:51:22][C][pcf8574:021]: PCF8574:
[19:51:22][C][pcf8574:022]: Address: 0x22
[19:51:22][C][pcf8574:023]: Is PCF8575: NO
[19:51:22][C][switch.gpio:076]: GPIO Switch 'a16-output1'
[19:51:22][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:22][C][switch.gpio:031]: Pin: 0 via PCF8574
[19:51:22][C][switch.gpio:033]: Interlocks:
[19:51:22][C][switch.gpio:037]: a16-output2
[19:51:22][C][switch.gpio:076]: GPIO Switch 'a16-output2'
[19:51:22][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:22][C][switch.gpio:031]: Pin: 1 via PCF8574
[19:51:22][C][switch.gpio:033]: Interlocks:
[19:51:22][C][switch.gpio:037]: a16-output1
[19:51:22][C][switch.gpio:076]: GPIO Switch 'a16-output3'
[19:51:22][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:22][C][switch.gpio:031]: Pin: 2 via PCF8574
[19:51:22][C][switch.gpio:076]: GPIO Switch 'a16-output4'
[19:51:22][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:22][C][switch.gpio:031]: Pin: 3 via PCF8574
[19:51:22][C][switch.gpio:076]: GPIO Switch 'a16-output5'
[19:51:22][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:22][C][switch.gpio:031]: Pin: 4 via PCF8574
[19:51:22][C][switch.gpio:076]: GPIO Switch 'a16-output6'
[19:51:22][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:22][C][switch.gpio:031]: Pin: 5 via PCF8574
[19:51:22][C][switch.gpio:076]: GPIO Switch 'a16-output7'
[19:51:22][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:22][C][switch.gpio:031]: Pin: 6 via PCF8574
[19:51:22][C][switch.gpio:076]: GPIO Switch 'a16-output8'
[19:51:22][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:22][C][switch.gpio:031]: Pin: 7 via PCF8574
[19:51:22][C][switch.gpio:076]: GPIO Switch 'a16-output9'
[19:51:22][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:22][C][switch.gpio:031]: Pin: 0 via PCF8574
[19:51:22][C][switch.gpio:076]: GPIO Switch 'a16-output10'
[19:51:22][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:22][C][switch.gpio:031]: Pin: 1 via PCF8574
[19:51:22][C][switch.gpio:076]: GPIO Switch 'a16-output11'
[19:51:22][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:22][C][switch.gpio:031]: Pin: 2 via PCF8574
[19:51:22][C][switch.gpio:076]: GPIO Switch 'a16-output12'
[19:51:22][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:22][C][switch.gpio:031]: Pin: 3 via PCF8574
[19:51:22][C][switch.gpio:076]: GPIO Switch 'a16-output13'
[19:51:22][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:22][C][switch.gpio:031]: Pin: 4 via PCF8574
[19:51:22][C][switch.gpio:076]: GPIO Switch 'a16-output14'
[19:51:22][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:23][C][switch.gpio:031]: Pin: 5 via PCF8574
[19:51:23][C][switch.gpio:076]: GPIO Switch 'a16-output15'
[19:51:23][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:23][C][switch.gpio:031]: Pin: 6 via PCF8574
[19:51:23][C][switch.gpio:076]: GPIO Switch 'a16-output16'
[19:51:23][C][switch.gpio:099]: Restore Mode: restore defaults to OFF
[19:51:23][C][switch.gpio:031]: Pin: 7 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input1'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 0 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input2'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 1 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input3'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 2 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input4'
[19:51:23][C][gpio.binary_sensor:015]: Device Class: 'motion'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 3 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input5'
[19:51:23][C][gpio.binary_sensor:015]: Device Class: 'motion'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 4 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input6'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 5 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input7'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 6 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input8'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 7 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input9'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 0 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input10'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 1 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input11'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 2 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input12'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 3 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input13'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 4 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input14'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 5 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input15'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 6 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'a16-input16'
[19:51:23][C][gpio.binary_sensor:016]: Pin: 7 via PCF8574
[19:51:23][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'pir'
[19:51:23][C][gpio.binary_sensor:015]: Device Class: 'motion'
[19:51:23][C][gpio.binary_sensor:016]: Pin: GPIO32
[19:51:23][C][adc:087]: ADC Sensor 'analog-1'
[19:51:23][C][adc:087]: Device Class: 'voltage'
[19:51:23][C][adc:087]: State Class: 'measurement'
[19:51:23][C][adc:087]: Unit of Measurement: 'V'
[19:51:23][C][adc:087]: Accuracy Decimals: 2
[19:51:23][C][adc:097]: Pin: GPIO39
[19:51:23][C][adc:112]: Attenuation: 11db
[19:51:23][C][adc:126]: Update Interval: 10.0s
[19:51:23][C][captive_portal:088]: Captive Portal:
[19:51:23][C][mdns:103]: mDNS:
[19:51:23][C][mdns:104]: Hostname: a16
[19:51:23][C][ota:093]: Over-The-Air Updates:
[19:51:23][C][ota:094]: Address: a16.local:3232
[19:51:23][C][ota:097]: Using Password.
[19:51:24][C][api:138]: API Server:

The 3 wire no -nc-com door sensor is working but pir sensor is not working


RE: Kincony A16 - PIR motion sensor - admin - 01-04-2023

these are 4 IIC address of your PCF8574 chips:
[19:51:22][I][i2c.arduino:074]: Found i2c device at address 0x21
[19:51:22][I][i2c.arduino:074]: Found i2c device at address 0x22
[19:51:22][I][i2c.arduino:074]: Found i2c device at address 0x24
[19:51:22][I][i2c.arduino:074]: Found i2c device at address 0x25

you can test use a wire short with your digital input and GND, if home assistant input state changed, that mean work well.
if your door sensor is work well, PIR can't work, i think it's no problem with home assistant, that's maybe need set for your PIR, open your PIR sensor, there have a jumper for output signal type, usually will set to NO, maybe yours if NC. I think you can change it.