logo elektroda
logo elektroda
X
logo elektroda

[OPL1000] Sonoff DW2 door/window opening sensor - teardown, firmware

p.kaczmarek2 8313 83
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • Sonoff DW2-Wi-Fi door sensor on a wooden surface with a user manual.
    Recently, a reader sent a rather unusual Sonoff door opening sensor. This sensor is built on a WiFi microcontroller, which we have not yet discussed on the forum. Here I will present its interior, backup it's Flash memory via SPI and consider the potential of changing the firmware of this gadget.

    Purchasing the sensor
    The sensor turned out to be very cheap, less than 30PLN. That's odd. Equally strange is the fact that the RF433 keyword is inserted in the title of the bids, even though radio communication this gadget does not have, there is only WiFi:
    Sonoff DW2 door sensor with WiFi and packaging on product page
    In the description, the seller explains that the earlier version, DW1, relied on RF433MHz, while the one in the offer uses WiFi:
    Sonoff DW2 WiFi door opening sensor mounted on a door.
    Dimensions:
    White door opening sensor with dimensions in millimeters and inches.
    Here's what I got:
    Box with Sonoff DW2 Wi-Fi door/window sensor. Sonoff DW2-Wi-Fi sensor packaging on a wooden surface.
    Contents:
    Sonoff DW2-Wi-Fi sensor set with user guide on a wooden table.
    Case information:
    - Quiescent current: <=40uA
    - Emission current: <=15mA
    - Model: DW2-Wi-Fi
    - FCC ID: 2APN5DW2-WIFI
    The sensor can be paired with the eWeLink app, then it works flawlessly, but this I already described in the case of the first reviewed door sensor:
    Wifi door/window sensor - test, interior, integration with the rest of the devices so here I skip it.

    Inside of the sensor
    You have to pull off the battery cover first:
    Interior of an opened Sonoff door sensor showing the PCB and battery compartment.
    PCB is held on by two hooks. Just undermine these hooks, then you can remove the board:
    Sonoff DW2-WiFi door sensor PCB on a wooden background Close-up of the PCB of the Sonoff DW2-WiFi door sensor on a wooden background.

    PCB designation:
    DW2-WiFi V1.2
    2021.01.13
    You can see the WiFi module separately, and the Flash memory chip separately:
    Interior of the Sonoff DW2-WiFi door sensor with visible PCB and components.
    H1 is the Hall sensor, Q1 is the transistor.
    Close-up of the Sonoff door sensor circuit board with visible electronic components.
    The Hall sensor is designated as 6131.
    The SPI bone is TH25Q80UA.
    The microcontroller is OPL1000 - manufactured by Opulink. It offers connectivity via WiFi and Bluetooth.
    A fragment of the OPL1000 microcontroller documentation describing its functions.
    Block diagram of the OPL1000 microcontroller.
    There is no open source software for IoT devices for this microcontroller yet. Documentation, however, is available:
    https://github.com/Opulinks-Tech/OPL1000-HDK/tree/master
    A few more photos:
    Interior of Sonoff DW2-Wi-Fi sensor with OPL1000 microcontroller. Close-up of a PCB from the Sonoff DW2-WiFi door sensor. Interior of DW2-WiFi sensor with OPL1000 microcontroller Close-up of the PCB of a Sonoff door sensor with visible electronic components. Close-up of Sonoff DW2-WiFi sensor PCB. .

    Dumping the Flash [/size]
    For a start, I decided to dump flash memory, So I started by desoldering the Flash chip (I don't trust the clip method):
    Close-up of a circuit board with an OPL1000 microcontroller. Small integrated circuit on a wooden table.
    Then I loaded its content with a CH341 programmer:
    Sonoff DW2-WiFi sensor PCB and USB programmer on a wooden surface. USB Flash programmer with connected adapter board.
    Programmer tool (NeoProgrammer 2.2.0.3) recognized the chip (SPI ID: EB6014):
    Screenshot of NeoProgrammer software during Flash memory detection. Screenshot of NeoProgrammer 2.2.0.3 showing a list of SPI memory chips.
    I was able to read the data, and I even found some SDK-related character strings inside:
    Screenshot of NeoProgrammer displaying memory data read from a Flash chip. Screenshot of NeoProgrammer displaying flash memory readout.
    I posted a copy of the firmware here:
    https://github.com/openshwprojects/FlashDumps/commit/a4d13b2bee408249def6e3797748db6a45ddaee7

    [b] Programmable OPL1000
    SDK is available and in at least several versions:
    https://github.com/Opulinks-Tech/OPL1000A2-SDK
    https://github.com/Opulinks-Tech/OPL1000A1-SDK
    Even English-language documentation is available:
    https://github.com/Opulinks-Tech/OPL1000A1-SDK/tree/master/Doc/en
    At this point I have not taken further steps to get it up and running, but maybe that will change soon.

    Summary
    This product is very cheap, but at this point it can not be easily cut off from the cloud. There is the potential to prepare firmware for it (it will probably be a port OpenBeken ), but so far I know of only one device where it exists (just that door opening sensor from the topic), so I don't know if it would make much sense to do all the porting for one device.... and maybe you guys can tell me
    Have any of you perhaps encountered any devices based on OPL1000?
    I invite you to share information.[/b]

    Cool? Ranking DIY
    Helpful post? Buy me a coffee.
    About Author
    p.kaczmarek2
    Moderator Smart Home
    Offline 
    p.kaczmarek2 wrote 11960 posts with rating 9995, helped 572 times. Been with us since 2014 year.
  • ADVERTISEMENT
  • #2 20767649
    pitsa
    Level 12  
    I have seen reviews for this sensor that "the signal is sent only when opening. When closing it does not", is this true?
  • #3 20767671
    p.kaczmarek2
    Moderator Smart Home
    Hello, where did you see such an opinion? A friend has several of these sensors with the original app and has no such problems. Anyway, there are also reviews on the web where you can see live how it looks like with the manufacturer's app (which I also tested, but years ago - I don't test it in reviews anymore because it would be boring):
    [youtube]
    https://www.youtube.com/watch?v=bgEUciLVPEE
    [/youtube]

    As for me it's a sensor like a sensor, all in all quite cheap, only worse that the firmware can't be changed at this point.
    Helpful post? Buy me a coffee.
  • #4 20938792
    Jacekmiel1
    Level 7  
    Hi, has there been any progress regarding the development of Open Beaken for this system? The price is certainly encouraging. Unless you have some other, equally cheap, battery-powered WiFi opening sensor?

    I see the potential to convert such a module into, for example, a mailbox sensor, where it is best to solve it with something that will last a long time on battery power.
  • #5 20938882
    p.kaczmarek2
    Moderator Smart Home
    We haven`t touched OPL1000 yet due to its very low popularity. We recently ported OpenBeken to LN882.

    Some door opening sensors were discussed on the forum, there is a DoorSensor controller in OBK, although you can also buy a sensor based on TuyaMCU, which is a bit problematic
    Helpful post? Buy me a coffee.
  • #6 21174018
    silvestro_gatto
    Level 7  
    >>20767159

    I found this device, based on OPL1000, that might be a good candidate to prepare a firmware for it (of course a port OpenBeken) to cut it off from the cloud:

    Tuya Outdoor 95dB Siren with solar and USB power supply (cost 20/30 euro)

    [OPL1000] Sonoff DW2 door/window opening sensor - teardown, firmware [OPL1000] Sonoff DW2 door/window opening sensor - teardown, firmware[OPL1000] Sonoff DW2 door/window opening sensor - teardown, firmware [OPL1000] Sonoff DW2 door/window opening sensor - teardown, firmware

    AliExpress Link

    Feature and Specifications:
    Power: 5V/1A Type-C USB;
    Battery type: 18650 rechargeable batter
    Wireless protocol: WIFI
    Wireless range: 45m
    Standby current: 2.5mA
    Alarm ringtone: 3
    Maximum alarm sound: 1m-100dB
    Waterproof rate: IPX5
    Main body size: 200x150x66mm
    Solar panel size: 132x62mm

    Here are some pictures of the inside and the main board

    Interior of a solar-powered siren with visible circuit board and speakers.

    Image of the interior motherboard of a solar-powered siren, featuring an OPL1000 chip on a white board.

    and of the OPL1000 module

    OPL1000 module with PUYA P25Q80H memory on a blue PCB

    with the OPL1000 A2SA2121 chip and the PUYA P25Q80H SOIC-8 NOR Flash memory
  • ADVERTISEMENT
  • #7 21174777
    divadiow
    Level 34  
    that's cool. I do not have an OPL1000 device so will try a Sonoff DW2 in the hope they are still based on OPL1000
  • #8 21175497
    p.kaczmarek2
    Moderator Smart Home
    First we would need to check is there an UART bootloader and is the SDK mentioned in the first post able to compile a working binary.
    Helpful post? Buy me a coffee.
  • #9 21176338
    divadiow
    Level 34  
    @p.kaczmarek2 are you inclined to see if OBK can be ported to the OPL1000 or does its rarity still mean it's not worth the time?
  • #10 21176434
    p.kaczmarek2
    Moderator Smart Home
    It depends. Is anyone here able to help?

    Currently, I still have more ESP8266 support requests than the OPL1000 ones.
    Helpful post? Buy me a coffee.
  • #11 21176974
    divadiow
    Level 34  
    yes, fair enough. I can help with testing of course, but I imagine you're after someone who could work on the code.
  • #12 21177020
    p.kaczmarek2
    Moderator Smart Home
    You can also try searching for flash tools and just check if that OPL SDK compiles
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #15 21185471
    p.kaczmarek2
    Moderator Smart Home
    Nice, can you dump the flash chip first?
    Helpful post? Buy me a coffee.
  • #16 21185473
    divadiow
    Level 34  
    of course. I intend to try all the things. May not get to it today though

    Added after 4 [hours] 36 [minutes]:

    I've ordered a CH341a but will probably try bit-banging with FTDI before it arrives. I'd forgotten about this vid https://www.youtube.com/watch?v=z9uLPo9QAY8

    Sadly the Opulinks UART download tool doesn't seem to have a flash read function.
  • #17 21185809
    p.kaczmarek2
    Moderator Smart Home
    Helpful post? Buy me a coffee.
  • #18 21186407
    divadiow
    Level 34  
    DW2 boot output from GPIO8. Pad is available on PCB.

    Close-up of a circuit board with a visible OPL1000 chip.

    Code: Text
    Log in, to see the code


    and at boot GPIO0 outputs this

    Code: Text
    Log in, to see the code
  • #21 21188048
    p.kaczmarek2
    Moderator Smart Home
    I wonder if those OPL1000 binaries from Github are similiar to that flash dump?

    Not much under "boot" and "uart" keywords in strings...

    But... we have "at+ota" and
    
    OTA_DATA_URL: %s?deviceid=%s&ts=%u&sign=%s
    

    and
    
    [%s]:http ota task message send fail 
    [%s]:http ota task message allocate fail 
    

    and:
    
    http://192.168.0.100/ota.bin
    

    Is there an AT command line?
    Helpful post? Buy me a coffee.
  • #24 21188105
    divadiow
    Level 34  
    will solder flash back. assuming I don't kill it, I'll try AT commands next.

    Added after 59 [minutes]:

    success

    Close-up of a green circuit board with a soldered integrated circuit.

    and it pairs
    App screen showing DW2-Wi-Fi-L device offline. Screenshot of SONOFF device settings on a smartphone showing options for Smart Scene, push message, logs, and arming schedule.
  • #25 21188325
    p.kaczmarek2
    Moderator Smart Home
    Yes, now check UART. It may respond only if you send a correct welcome sequence.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #26 21189210
    divadiow
    Level 34  
    hmm. no luck so far getting any AT response. trying welcome +++ sends too.

    not helped by the fact that this device doesn't seem to be able to talk to the coolkit.cc servers, it just loops this in the log and device remains offline in the eWelink app even though pairing was successful.

    Code: Text
    Log in, to see the code


    there doesn't appear to be an AP mode

    anyway. wouldn't building something from the SDK be more meaningful? Apart from cutting off from the cloud with OTA, like Magic Home BL602, what else could be achieved or gained from AT command response? OTA still needs a working firmware from SDK...
  • #27 21190297
    divadiow
    Level 34  
    I've fiddled a bit more and flashed opl1000_at.bin using the latest OPL1000 Download Tool I can find - 3.9.3.7012

    Flash start is the same as Beken - reconnect power when flash tool is waiting on COM port.

    Screenshot of the OPL1000 Download Tool showing UART settings and download progress.
    Screenshot of OPL1000 download tool showing UART settings and flash process.
    Screenshot of OPL1000 Download Tool with settings and a log.

    and then some AT commands including AT+RST to show boot log (from flashing/AT UART GPIO0, not GPIO8)

    Screenshot of RealTerm program with extended boot log. Screenshot of RealTerm program showing AT+SYSRAM command and response 24760.

    Added after 8 [hours] 37 [minutes]:

    I've flashed back my TH25Q-80UA dump and the one from https://github.com/openshwprojects/FlashDumps/commit/a4d13b2bee408249def6e3797748db6a45ddaee7 and they both boot and are pairable in the eWelink app.
    Screen view of the eWelink app showing two offline devices.

    both output this on GPIO0 (APS_DBG_UART_TX)

    Code: Text
    Log in, to see the code


    Added after 45 [minutes]:

    The opl1000_ali_sensor_003_020_2436_2004.bin binary gives this on GPIO0 at boot

    Code: Text
    Log in, to see the code


    and accepts AT commands
    Screenshot from RealTerm showing a log of communication with a device via a serial port.

    Added after 6 [minutes]:

    the "Get Version" button queries the OPL for patch firmware version value. This is the return from opl1000_ali_sensor_003_020_2436_2004.bin

    Screenshot of OPL1000 download tool displaying firmware version information.
  • #28 21190517
    p.kaczmarek2
    Moderator Smart Home
    Great progress, so it's possible to flash the Flash chip dumps directly via UART?

    Btw, did you check the original dump for open ports?

    Ok, so the next step is to compile something... can we compile our own opl1000_ali_sensor_003_020_2436_2004 or similiar?
    Helpful post? Buy me a coffee.
  • #29 21190525
    divadiow
    Level 34  
    p.kaczmarek2 wrote:
    Great progress, so it's possible to flash the Flash chip dumps directly via UART?

    yes. both dumps and the OPL AT and Ali door sensor binaries flash and boot
    p.kaczmarek2 wrote:
    Btw, did you check the original dump for open ports?

    started to but the connection was too unstable. can do again with smaller ranges
    p.kaczmarek2 wrote:
    Ok, so the next step is to compile something... can we compile our own opl1000_ali_sensor_003_020_2436_2004 or similiar?

    this is the bit im most scared about as im not yet sure how to approach it. I have MYSYS2 installed from something ages ago and I have a mental note you demonstrated something somewhere, maybe it was the XR809 original build. I'm a little bit not excited given how rare it is. but it would be a good learning exercise.
  • #30 21190566
    p.kaczmarek2
    Moderator Smart Home
    Ok so which SDK would you like to try together? Which repository has binaries that you confirmed are working?
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around the Sonoff DW2 door/window opening sensor, which utilizes the OPL1000 WiFi microcontroller. Users explore the sensor's capabilities, including firmware modification and potential applications. Initial concerns about the sensor's functionality, particularly regarding its signal transmission during opening and closing events, are addressed. The conversation shifts to the development of OpenBeken firmware for the OPL1000, with participants sharing insights on flashing the device, compiling firmware, and troubleshooting issues related to OTA (Over-The-Air) updates. The group also discusses the differences between OPL1000, OPL1200, and OPL1600 chips, and the compatibility of various SDKs. Progress is made in getting the device to connect to WiFi and in implementing OTA functionality, while challenges remain in establishing an AP (Access Point) mode for configuration.
Summary generated by the language model.
ADVERTISEMENT