logo elektroda
logo elektroda
X
logo elektroda

[BK7231N] [CBU] Tuya Light + PIR Motion Sensor (FH_PIR_400A)

auntlydia 6045 50
ADVERTISEMENT
  • #31 20741282
    auntlydia
    Level 10  
    Not sure if this is helpful but I just found this in the device's instructions manual:

    Page from a manual showing a light level graph on a device.

    So, apparently only (?) lux value is reported upon short button press with original Tuya firmware. Would it be possible to sniff some useful data during this process?

    It is also said that a long button press reports both battery level and illuminance.

    It actually CAN be helpful to read those manuals every now and then.. 😅 I usually leave them in the package because most of the time they seem useless.

    Furthermore, the manual states that the lux sensor range is 0-10000. If this represents the actual sensor's range, it could help narrowing down the search for the SMD component.

    I wonder if the button press and the sensors are actually connected physically, independent from the firmware, or if the firmware does the job of connecting them and initialise the sensor read and send of the value report... if I have time, I will use GPIO doctor to see if there is any reaction on P26, P7 or P6 if I press the button.

    Added after 1 [hours] 39 [minutes]:

    ....and.. one more thing. a while ago I had found some datasheet during my research for this light sensor (I think it was actually through google picture results).. the sensor looks similar from the product picture on the PDF.. the name is "Ambient Light Sensor with I2C Interface EAALSDIC2020A2" (Everlight Americas)

    Cover of the datasheet for the EAALSDIC2020A2 ambient light sensor with I²C interface from Everlight Americas.

    Now with scrolling through the sheet, I found that the Slave Address is 0x38!!!

    Snippet of technical documentation with the Slave address 0x38 highlighted.

    And the pinout seems to match as well, at least SDA and SCL have the same position as we found here in our analysis, and the middle pin (--> P26) is labelled as INT ("Interrupt pin")

    Top view of an electronic component pin layout with labels VDD, NC, GND, SCL, INT, SDA.

    I'll attach the PDF here for those of you who understand more about electronics. Maybe we are very close to a solution now!

    EAALSDIC2..A2.pdf Download (828.75 kB)
  • ADVERTISEMENT
  • #32 20741344
    dgel27
    Level 7  
    >>20741207
    Hi @auntlydia, this is not my idea. Evrehyng depend on @p.kaczmarek2 and firmware. from HW point, I2C bus is very simple: all devices attached to bus with 2 lines in parralell: data and clock (plus 2 lines power). Each device must have 7bit uniquie address (manufcturer give it, but may a bit configure with hw pins). Access to device - via this address. So, MCU theoretically serve till 128 devices on 2 GPIO pins.
    Exept HW, we need SW, that:
    1. Detect device on the bus (scan all 128 addresses, and see on which we have answer) - now it works in OBK!
    2. Can work with that devices (need configure device, read data from it, reset, if need - all via I2C commands, and every device different). So we need code per device. The known devices have this code, just need implement it in OBK. Each cote take space on the MCU flash, so need to think about build system, to user will compile code with modules he need.
    3. FW have input/output data to MQTT for automation
    These implemented in Tasmota (ESP chips), but these devises more expencive, less populary (used eWelink app), and not always used ESP chip (i have order device, that instaed ESP, installed exotic Altobeam chip)
    Tasmota FW exellent for those people, who can make device from the scratch with ESP modules, or specially find devices with ESP.

    For Tuya devices:
    1. cheaper
    2. already come with exellent case, no need 3d print it
    3. order on aliexpress small board with sensor you need, glue it, that fit in case and solder 4 wires
    4. compile FW with driver, if it not included by default, and flash it.

    @p.kaczmarek2: yes, it possible to see what happens on the bus(with logic i collected) and try to implement.
    But do you think it better to spend time for this special device (with maybe some chineese undocumented chip), or implement universally concept for I2C devices?

    I'm not programmer, but i can download tasmota and look how it implemented.
    Anyway, i will help with any my possibilities!

    Thanks!

    Added after 6 [minutes]:

    >>20741282

    Exellent! i think this is our device! Looks like registers addresses same!

    And GPIO doctor cannot help with I2C devices. It possible update it, to choose clock and data GPIO, scan the bus for this 2 GPIO and print results. But we need to know clock and data lines, otherwise it will take a lot of time to select and scan each GPIO combinations

    Thanks!
  • #33 20741731
    auntlydia
    Level 10  
    OK! @dgel27 thanks for your information regarding steps to add I2C devices. As compiling driver in firmware is required, maybe this is a task for programmer, but it sounds interesting to me and I want to learn more about it. It is also a good idea to get cheap known devices on breakout boards. But for this one, I think it would be perfect if we can use directly the sensor U4, as the material is already there and we don't need to waste it.

    Now we wait and see if @p.kaczmarek2 can use the information of the datasheet to add support to OpenBK for this I2C sensor - and then, we only can hope it is actually the device we are looking for.

    Thanks all for help and cooperation!
  • #34 20742255
    dgel27
    Level 7  
    It seems strange company EVERLIGHT.
    For american market it uses different chip name. On everlight suite (not american), I found this datasheet. It seems same, also with product number in registers, but chip name is different. Maybe this name could find ready libraries.

    Thanks!
  • #35 20789236
    auntlydia
    Level 10  
    Hi there,

    @p.kaczmarek2 I just wanted to check in quickly, if there is any chance that you can implement a driver for this light sensor into the firmware? Is the information of the datasheet enough to do that, or is more analysis and work required for creating a driver? I don't have an oscilloscope or other advanced equpment but if you point out what still could be done, I'm happy to try to get some more equipment and collect data.

    Or if anyone else can still help with putting the driver in the firmware, it would be awesome!

    Thanks!
  • #36 20790252
    p.kaczmarek2
    Moderator Smart Home
    Hello @auntlydia , it is certainly possible for me to write a driver for this chip, but it's protocol seems a bit more complicated than a one of, let's say, TC74 or SM2135. I would need to do a bit more tests, it's hard to get everything right at the first time.
    There are few approaches we can take:
    - someone could ship me one piece of this device so I can do testing on my side quickly
    - maybe we could try getting me a remote access to one of such devices, if you have a public IP or reverse proxy, or maybe even something like VPN/Hamachi could do if configured correctly, I don't know
    - I could also try writing the driver "blindly" with you testing yourself on your side, but that could be slower
    I will note here that, however, I am actively working on other devices right now, for example:
    https://www.elektroda.com/rtvforum/topic4009272.html#20789559
    So that one would need to wait in queue for its time.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #37 20790281
    auntlydia
    Level 10  
    Hey there! That all sounds very good. I am very happy to cooperate.

    I could ship you one of my spare devices if you like. I assume you are in Poland? However, I also assume that it would be cheaper to order a new one and have it shipped to your address directly from AliExpress. I can pay for it, in any case I would need your shipping address.

    I am also open to other options. I am flexible, I have DynDNS, so my network is easily accessible. I also have some VPN servers running (best options are OpenVPN or WireGuard), for which I would need to send you key or profile files. In any way, we would need to connect in a different channel or send the confidential information via PM or Email.

    I also totally understand that you are busy with other projects, no pressure.

    Let me know your favorite approach, and let's do it when you're ready!

    =)
  • #38 20790290
    p.kaczmarek2
    Moderator Smart Home
    So you're from Germany? That's very close, shipping should not be hard that way. Testing is always fasted when I have device on site.

    I can send you my data via PM, the only question would be, will they send the exactly the same model if you order it again? We can try, it already worked once before, but there is no certainty.
    Helpful post? Buy me a coffee.
  • #39 20790298
    auntlydia
    Level 10  
    Yes, Germany. I'll look into the best option and have this device sent to you. See you further in PM =)
  • #40 20970184
    p4nd0ra
    Level 3  
    Hello,

    are there any updates regarding this ?
  • #41 20970189
    p.kaczmarek2
    Moderator Smart Home
    I have this device, it's waiting in the queue, I can try to look into it faster soon. I got distracted by LN882H port and later by WS2812B fix that was pending for a year or so.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #42 20970264
    auntlydia
    Level 10  
    cool, that would be awesome, I sure would appreciate it! 😀
  • #43 21091082
    silvestro_gatto
    Level 7  
    >>20970189
    Hi @p.kaczmarek2
    Just checking in to see if there is any update about writing I2C driver for this chip.
    I got a few Light_and_PIR_Motion_Sensor_FH_PIR_400A and wish to cut them from Tuya cloud to freely use with my HA.
    Thank you.
  • #44 21092055
    auntlydia
    Level 10  
    Hi, thanks for keeping this post alive! I would also be very interested in updates regarding this. Cheers!
  • #45 21092247
    silvestro_gatto
    Level 7  
    Thank you @auntlydia for all the work you did so far with this device, including shipping one to @p.kaczmarek2 for testing and further analysis.

    I hope @p.kaczmarek2 will write the I2C driver soon and with minimal troubleshooting he will add the FH_PIR_400A Light&Motion Sensor to the list of supported modules!

    Take care!
  • ADVERTISEMENT
  • #46 21092654
    auntlydia
    Level 10  
    Sure, no problem! For those who don't want to wait, I can recommend the Zigbee devices that have the same or similar functions and are about the same price, if not even a little cheaper. They work perfectly well with a cheap USB-Zigbee Coordinator plugged into a HomeAssistant server and work out-of-the-box with Zigbee2MQTT in HA. No flashing or advanced setup is required and they consume less power.

    But nevertheless, it would be awesome at some point to get these Wifi-motion-light-sensors to fully work with OpenBK, since they are versatile in use and come with both battery compartment and USB-port for mains power supply.

    ;)
  • #47 21104166
    Black_SN
    Level 1  
    I have bought a Zigbee PIR sensor like this - HW-510A-A001. How do I decrease the update time, its about 5 seconds for now?
  • #48 21118745
    silvestro_gatto
    Level 7  
    Hi there, any updates regarding I2C driver?
  • #49 21118811
    p.kaczmarek2
    Moderator Smart Home
    Not yet, but device has moved up in the queue, because I recently processed:
    - BK7231M modules sent by anonymous donator: https://www.elektroda.com/rtvforum/topic4058227.html
    - SM15155 lamp sent by @HalliHallo : https://www.elektroda.com/rtvforum/topic4009272-30.html#21115906
    So, soon I may be able to address this device as well.
    Helpful post? Buy me a coffee.
  • #50 21118837
    silvestro_gatto
    Level 7  
    Thank you @p.kaczmarek2, I appreciate your swift reply.
    Looking forward to hearing good news about I2C driver.
    Cheers!
  • #51 21213296
    silvestro_gatto
    Level 7  
    >>21118811

    Hi @p.kaczmarek2
    Just checking in if there is any update about writing I2C driver for bk7231 chip and support this device.

Topic summary

The discussion revolves around the teardown and user experience of the Tuya Light + PIR Motion Sensor (FH_PIR_400A). Participants analyze the internal components, particularly focusing on the light sensor (U4) and its connections to the CBU module. They explore the possibility of the light sensor being an I2C device, with discussions on pin configurations and data lines. Various users share their findings on the sensor's connections, including PWM pins and I2C data lines, and express interest in developing a driver for the sensor to enable its functionality with OpenBK firmware. The conversation also touches on the challenges of identifying the specific I2C device and the need for reverse engineering to understand its communication protocol. Additionally, there are suggestions for alternative Zigbee devices that offer similar functionalities without the need for complex setups.
Summary generated by the language model.
ADVERTISEMENT