logo elektroda
logo elektroda
X
logo elektroda

[Solved] Automatic Fish Feeder, BL602

Virnik0 3744 23
Best answers

How can I make an OpenBeken BL602 fish feeder stop the motor automatically after one feed cycle and get a DS18B20 temperature sensor working over MQTT?

Use an OpenBeken startup script instead of Tasmota-style PulseTime: create a change handler for the motor channel and trigger a delayed `setChannel 1 0` with `addRepeatingEvent`, so the feeder turns itself off after it is switched on [#20864952] If you need multiple startup commands on BL602, wrap them in `backlog`; the working pattern shown was `backlog startDriver DS1820 5; waitFor WiFiState 4; waitFor MQTTState 1; addRepeatingEvent 60 -1 publishFloat DS1820Temp $CH5;` [#21291298][#21291312] DS18B20 support is now available in OpenBeken for BL602/Beken, and the sensor driver must be started explicitly with `startDriver DS1820` (or `startDriver DS1820 5` for a custom interval) [#21075277][#21267631][#21290478] A `boot incompletes 1` message is not a problem; it can appear before boot completion is marked [#20864952] Once configured, the sensor publishes to MQTT, and Home Assistant can consume the value with a template/MQTT sensor setup [#21290478][#21291606]
Generated by the language model.
ADVERTISEMENT
  • Helpful post
    #1 20859669
    Virnik0
    Level 5  
    Posts: 16
    Help: 1
    Rate: 1
    Hello,

    I have recently purchased Automatic Fish Feeder from eBay.

    It has XT-BL12 chiplet inside. Inside this chiplet, it has BL602. I have successfully soldered my UART jig to it, and flashed OpenBelken firmware.

    Wi-Fi, MQTT works. I can also turn LED on/off, and rotate the drum.

    I have few questions:
    I have soldered DS18B20 temperature sensor to GPIO17. I have put 150k rezistor between data (GPIO17) and VCC, GND to GND.

    But I haven't found out how to configure it properly. GPIO mapper wizzard from the web doesn't help. Toggling the drum doesn't turn it off after one rotation, it keeps rotating. I have to turn it off manually. I know that with Tasmota, identical problem is solved by setting pulsetime1. How can I do the same thing here, ie: Turning the drum will toggle-off automatically after it finishes its single rotation.

    Second issue is that the default template doesn't know anything about temp sensor. I can't pick pin type from pre-defined list.
    It doesn't read correct values.
    Close-up of a circuit board with an XT-BL12 Wi-Fi module in an automatic fish feeder..

    And last, if I'll exclude HomeAssistant for now, how can I automate or mimic behavior of stock firmware, eg: When the drum rotates, LED blinks. When the button is pressed, it turns the drum once. If long-press is used, it forces an action (Pairing on stock, but I would prefer either reboot or safe mode).

    PCB with Wi-Fi module and soldered wires.

    To summ things up, I have so far identified GPIO03 as a button, GPIO04 as a LED, and GPIO05 as a drum rotation. Setting it to PWM allows me to rotate it through button on board's GUI. GPIO17 has a temp sensor connected.

    I was able to put button and drum rotation to one group, so by pressing the button, the drum rotates (and never stop until pressed again). Toggle in the UI thinks it is a light.
    Screenshot showing GPIO configuration for an automatic fish feeder.

    I am sorry if it was already discussed elsewhere....I tried to search for either BL602 controlling a motor, or BL602 used in fish feeder units, but haven't found anything. Most feeders uses different chiplets which usually work well with Tasmota.

    I have also tried to use gui flasher app to parse tuya mcu gpio config, but the app tells me that there was an error (tried both on Linux and Windows) while choosing tuyamcu dump binary file. The app refuses to download or read from BL602, because it was made for different chip. But it is able to verify connectivity from the unit over network, reads its chip, firmware version, etc. Is there a better or other way for BL602 to convert/parse tuyaMCU GPIO config?

    Also, the unit prints "boot incompletes 1" in its gui. Should I be worried?

    Update: I've read a bit more about drivers to start. I have tried to work with autoexec.bat, letting it start TuyaMCU, but there is no mention of this driver in logs, even though I set them to debug level verbosity. And if I'll try to start it manually, I'll get this:
    Info:MAIN:Driver TuyaMCU is not known in this build.
    Info:MAIN:Available drivers: 
    Info:MAIN:NTP
    Info:MAIN:, RN8209
    Info:MAIN:, BL0942
    Info:MAIN:, BL0937
    Info:MAIN:, CSE7766
    Info:MAIN:, DDP
    Info:MAIN:, SSDP
    Info:MAIN:, DGR
    Info:MAIN:, Wemo
    Info:MAIN:, SM2135
    Info:MAIN:, BP5758D
    Info:MAIN:, BP1658CJ
    Info:MAIN:, SM2235
    Info:CMD:[WebApp Cmd 'startDriver TuyaMCU' Result] OK


    Technically, this feeder was sorta no-name, came with specific app (Vanters), and while it does work similarly to other tuya devices (pairing mode, etc), it used some other noname vendor's cloud. I was looking to achieve two goals:
    a) cut it off from chinese cloud services and allow direct LAN control (apart from endless drum rotation, this was achieved. I can control and automate the feeding using HA
    b) Read temperature values from connected sensor. So far, I haven't found a way how, although the same procedure with Tasmota wasn't a problem.

    I am attaching TuyaConfig dump made using web client.

    Update2:
    Bellow button config works, eg: rotates the drum only once, both toggle and the button:
    {
      "vendor": "Vanters",
      "bDetailed": "0",
      "name": "Automatic Fish Feeder",
      "model": "ANT325 V0",
      "chip": "BL602",
      "board": "XT-BL12",
      "flags": "-2080373664",
      "keywords": [
        "Feed",
        "Fish"
      ],
      "pins": {
        "2": "Btn_n;1",
        "3": "Btn;2",
        "4": "WifiLED_n;0",
        "5": "PWM;3"
      },
      "command": "waitFor WiFiState 4;waitFor MQTTState 1",
      "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
      "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }


    Screenshot of GPIO configuration for a BL602-based board

    In General/Flags, I had to enable "Flag 6 - [BTN] Instant touch reaction instead of waiting for release (aka SetOption 13)"

    Apart from it thinking about the toggle being a LED light, it works. Only thing remaining is the temp sensor. To me, it seems like device class isn't defined in OpenBeken.



    ========================================================================================================
    Update3:
    As for HA integration, I did this:
    configuration.yaml
      - platform: template
        sensors:
           fish_feed_time_tabs:
            friendly_name: "Last Fish Feeding - Tabs"
            value_template: >
              {%- set time = (as_timestamp(now()) - as_timestamp(states.counter.number_of_feedings_tabs.last_changed)) | int  %}
              {%- set minutes = ((time % 3600) // 60) %}
              {%- set minutes = '{}minutes'.format(minutes) if minutes > 0 else '' %}
              {%- set hours = ((time % 86400) // 3600) %}
              {%- set hours = '{}hours '.format(hours) if hours > 0 else '' %}
              {%- set days = (time // 86400) %}
              {%- set days = '{}days '.format(days) if days > 0 else '' %}
              {{ 'Less than 1 minute' if time < 60 else days + hours + minutes }} ago


    mqtt:
      switch:
      - unique_id: "feeder1.iot.lan_switch"
        name: Feed
        command_topic: "cmnd/Feeding/led_enableAll"
        state_topic: "Feeding/led_enableAll/get"
        availability_topic: "Feeding/connected"
        payload_on: 1
        payload_off: 0
    
      - unique_id: "feeder1.iot.lan_reboot"
        name: Reboot
        command_topic: "cmnd/Feeding/restart"
        availability_topic: "Feeding/connected"
        payload_on: 1
        payload_off: 0
        state_off: "Feeding/online"
        state_on: "Feeding/offline"


    I have added helpers to serve as a counter(s), and input boolean toggles to serve as a virtual on-off switch. I have two feeders, one based off of WBR3 - so used with TuyaLocal, and second one with BL602 I am playing with now, named Feeder1 (Tabs).
    Aquarium control panel with various options and counters.

    Aquarium LED Strip as seen in the dash panel screenshot is different controller entity not related to BL602
    Attachments:
    • BL602_TuyaConfig_Feeder1.bin (72 KB) You must be logged in to download this attachment.
  • ADVERTISEMENT
  • Helpful post
    #2 20864952
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14622
    Help: 655
    Rate: 12637
    I haven't seen that kind of device yet, thanks for submitting it.
    The boot incompletes 1 is okay, because boot is marked as complete after some time and you may catch the counter before its completion.
    The DS18B20 support is planned, I can look into it sooner if you need that
    For PulseTime, you need to see:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md
    In case of BL602, you can put those scripts in short startup command. Maybe something like this:
    
    // This aliased command will turn off relay on CH1 after 10 seconds
    // addRepeatingEvent	[IntervalSeconds][RepeatsOr-1][CommandToRun]
    alias turn_off_after_time addRepeatingEvent 10 1 setChannel 1 0
    // this will run the turn off command every time that CH1 becomes 1
    addChangeHandler Channel1 == 1 turn_off_after_time 
    

    We don't get BL602 devices often so we haven't ported LFS to this platform yet.
    Helpful post? Buy me a coffee.
  • #3 20867273
    Virnik0
    Level 5  
    Posts: 16
    Help: 1
    Rate: 1

    Hi,

    Thanks for the tip! This MCU (not Tuya apparently) has a break relay, which breaks/disconnects right after turning it on. So, I mapped it like this:
    Screenshot of Pin Configuration settings with four different configurations.


    And it does work correctly. So one turn only. If I'll toggle PWM, then it will do two rotations. From this perspective, I achieve what I wanted - the feeder is remotely controllable without a Chinese cloud provider. But the temperature I wanted to get....I can live without it, but it is sad.

    As for the temp sensor, I would really appreciate that support. After managing to finally flash this chip, I was hoping to use it, as WBR3 I have in the other feeder couldn't be flashed (iLonda - should be L88, but it is not - they have changed the chip from ESP to a clone from Tuya) and the sensor intended for it couldn't be used. That is why I thought that because OpenBeken is so similar, the same approach would work. And it does, up till software support, which is not yet present. But it is maybe the cheapest sensor you can get, and it is produced on a long cable suitable for tank temp measurement.

    As for LFS, I thought it to be a bug when I noticed that the FS browsing from the web browser doesn't work.

    If you'd need any logs or dumps, I will happily provide what I have. As a one wish if I could have it - could the next release be a bit modified so it wouldn't think I am controlling an LED strip with it? PWM controls an electric DC motor, instead of LEDs. So added controls for color temperature couldn't be used as such (but I have noticed it can control the speed of rotation apparently).
  • Helpful post
    #4 20867348
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14622
    Help: 655
    Rate: 12637
    I will try to look into it for you, the little problem is just that BL602 is not very popular and there are few devices using this chip, so Beken takes the priority. Do you have some basic C skills to help with enabling LFS on BL602, maybe?
    Helpful post? Buy me a coffee.
  • #5 20867360
    Virnik0
    Level 5  
    Posts: 16
    Help: 1
    Rate: 1

    Sadly, my coding skills aren't usable (compared to someone who really does develop the code). Last time I coded something in C, it was for the M@ngos project over 20 years ago.

    So I try to avoid it if possible because I know I am a much better platform engineer than a developer. I can apply patches and sometimes debug what went wrong. I do not have any issues rebuilding software from sources, and in specific cases, alter the code to suit either my needs or to simply work, but all those are relatively easy tasks for someone who really knows how to code. It is no wonder that BL602 is not so popular. It is possibly the cheapest module you can get. And honestly, I thought that the feeder has either an ESP proper or RTL clone, not a completely alien, minority-used chip. But I'm trying to get the most from little, if you know what I mean ;-)

    So if LFS enablement means to review certain diffs, apply them, and try to rebuild, yes, I can do that. But please do not expect truly developer kind of work, as I am not a developer myself.

    Anyway, I am not rushing, certainly not a maintainer of a bigger project for which my use-case is truly a minority. But I also won't stop you, if you know what I mean ;-) To that end, I consider myself lucky to be able to achieve the primary goal for that feeder. The first try failed due to WBR3 in the first feeder, so having success (although partial) on the second try wasn't that bad an experience.

    That said, if there would be something I can test, provide, run, build/compile....I am open to help (myself).
  • Helpful post
    #6 20940687
    Jinaria
    Level 8  
    Posts: 21
    Help: 1
    Rate: 3

    Virnik0 wrote:
    As WBR3, I have the other feeder that couldn't be flashed (iLonda - should be L88, but it is not - they have changed the chip from ESP to a clone from Tuya)


    ESPHome now has partial support for WBR3 (no OTA at the moment). I have the same iLonda feeder with WBR3 modules and managed to flash mine successfully.
    
    rtl87xx:
      board: wbr3
      family: rtl8720c
      framework:
        version: 0.0.0
        source: https://github.com/libretiny-eu/libretiny.git#feature/realtek-update

  • ADVERTISEMENT
  • #7 20945217
    Virnik0
    Level 5  
    Posts: 16
    Help: 1
    Rate: 1

    Thanks. As for iLonda, I left it where it was - integrated through TuyaLocal.

    As it works as it should now, I am more concerned about that no-name one,
    which uses BL602. It works correctly, but my concern was temperature sensor.

    So far, I have downloaded the sources, did basic configuration, but haven't found
    the time to actually build it and test, namely VFS. To be honest, I was fighting
    off one more resilient WINE build and then forgot about beken feeder.
  • ADVERTISEMENT
  • #8 21059631
    Tilator
    Level 12  
    Posts: 133
    Help: 2
    Rate: 13

    Virnik0 wrote:
    Hello,

    I have few questions:
    I have soldered DS18B20 temperature sensor to GPIO17. I have put 150k resistor between data (GPIO17) and VCC, GND to GND.

    But I haven't found out how to configure it properly. GPIO mapper wizard from the web doesn't help. Toggling the drum doesn't turn it off after one rotation, it keeps rotating. I have to turn it off manually. I know that with Tasmota, identical problem is solved by setting pulsetime1. How can I do the same thing here, i.e.: Turning the drum will toggle-off automatically after it finishes its single rotation.

    Second issue is that the default template doesn't know anything about temp sensor. I can't pick pin type from pre-defined list.
    It doesn't read correct values.


    Did you get any values from this DS18B20?

    I would like to add these sensors too, but can it be used? There seems to be some LibreTiny to allow it in Beken devices, but it sounds a bit complicated.
  • #9 21075275
    Virnik0
    Level 5  
    Posts: 16
    Help: 1
    Rate: 1

    Hi, no. No data from it. There is no support for it in OpenBeken. I haven't had a time to play with the source code, to be honest, as I am working and quite a lot of things simultaneously now, so tinkering is out of my capacity for the time being (probably till Fall).
  • ADVERTISEMENT
  • Helpful post
    #10 21075277
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14622
    Help: 655
    Rate: 12637
    I can look into supporting DS18B20 in OBK
    Helpful post? Buy me a coffee.
  • Helpful post
    #11 21075516
    Tilator
    Level 12  
    Posts: 133
    Help: 2
    Rate: 13
    p.kaczmarek2 wrote:
    I can look into supporting DS18B20 in OBK


    Excellent!
  • #12 21075758
    Virnik0
    Level 5  
    Posts: 16
    Help: 1
    Rate: 1

    >>21075277

    That would be awesome! I can easily flash for testing, not worried about bricking the unit - it is just an aquarium feeder after all.

    Added after 2 [minutes]:

    >>20940687

    Wired flash? I have it hooked up over TuyaLocal now. So once I'll have the time to open it and solder pins, I'll flash it too. If it is possible wirelessly (I think it is not with WBR3, that flaw was fixed last summer), even better. But I guess it's not.
  • #13 21089522
    BorgMcz
    Level 1  
    Posts: 1

    I think DS18B20 support would be a cool thing to have.
  • #14 21095600
    Tilator
    Level 12  
    Posts: 133
    Help: 2
    Rate: 13

    Does DHT11 need some kind of pullup resistor, or should it simply be power to VDD, ground to ground and GPIO to SDA?
  • #15 21095625
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14622
    Help: 655
    Rate: 12637
    Here is our DHT11 + OBK tutorial, including connection:


    Helpful post? Buy me a coffee.
  • #16 21267631
    divadiow
    Level 38  
    Posts: 5065
    Help: 438
    Rate: 893
    BorgMcz wrote:
    I think DS18B20 support would be a cool thing to have.


    a DS18B20 driver has since been developed and is available for use on BL602 and Beken platforms

    Added after 3 [minutes]:

    Virnik0 wrote:
    As for LFS, I thought it to be a bug when I noticed that the FS browsing from the web browser doesn't work.

    LFS is also available on BL602 now, but only on the older partition layout (this would be the case if flashed with BL DevCube 1.4.8 with the stock partition_cfg_2M.toml file)
  • #17 21290478
    Virnik0
    Level 5  
    Posts: 16
    Help: 1
    Rate: 1
    divadiow wrote:
    BorgMcz wrote:
    I think DS18B20 support would be a cool thing to have.


    a DS18B20 driver has since been developed and is available for use on BL602 and Beken platforms

    Added after 3 [minutes]:

    Virnik0 wrote:
    As for LFS, I thought it to be a bug when I noticed that the FS browsing from the web browser doesn't work.

    LFS is also available on BL602 now, but only on the older partition layout (this would be the case if flashed with BL DevCube 1.4.8 with the stock partition_cfg_2M.toml file)


    Sorry for too many edits. I was able to make it work after reading the manual again....I had to specify the driver to start:
    startDriver DS1820

    Now I can read the sensor, although the value was initially off. But now it looks like it is reading correct value. So it works. thanks a lot and again, sorry for confusion!
  • Helpful post
    #18 21290549
    divadiow
    Level 38  
    Posts: 5065
    Help: 438
    Rate: 893
    -1.27°C? that usually means it's not talking to the sensor. definitely got the right pin assigned?
  • #19 21290559
    Virnik0
    Level 5  
    Posts: 16
    Help: 1
    Rate: 1
    divadiow wrote:
    -1.27°C? that usually means it's not talking to the sensor. definitely got the right pin assigned?


    It shows this value some 30s after reboot. But then it switches to proper value, currently 24.37˚C

    Verified across few reboots.
  • #20 21290566
    divadiow
    Level 38  
    Posts: 5065
    Help: 438
    Rate: 893
    ah OK. there's also an interval value you get add to the end of the startdriver command - eg "startDriver DS1820 5" otherwise it's 15s by default
  • #21 21290593
    Virnik0
    Level 5  
    Posts: 16
    Help: 1
    Rate: 1
    >>21290566 I think I got it:

    startDriver DS1820 5; waitFor WiFiState 4;waitFor MQTTState 1; addRepeatingEvent 10 -1 publishFloat DS1820Temp $CH5


    Sensor works, I can see its values in the log. But I am unable to make sure it is published via MQTT. Well, I can, if I'll run the command by hand, but it doesn't work after reboot. What am I doing wrong?


    What is strange is that I do get a lot of bellow errors in logs:
    Info:SENSOR:DS1820[17] - Starting conversion
    Error:SENSOR:DS1820[17] - Read CRC=ff != calculated:c9 (errcount=1)
    Error:SENSOR:DS1820[17] - Scratchpad Data Read: ff ff ff ff ff ff ff ff ff
    Error:SENSOR:DS1820[17] - Read CRC=ff != calculated:c9 (errcount=2)
    Error:SENSOR:DS1820[17] - Scratchpad Data Read: ff ff ff ff ff ff ff ff ff
    Error:SENSOR:DS1820[17] - Read CRC=89 != calculated:30 (errcount=3)
    Error:SENSOR:DS1820[17] - Scratchpad Data Read: 87 1 55 5 7f a5 a5 66 89
    Error:SENSOR:DS1820[17] - Read CRC=2d != calculated:cb (errcount=4)
    Error:SENSOR:DS1820[17] - Scratchpad Data Read: 87 11 55 5 7f a5 a5 66 2d
    Error:SENSOR:DS1820[17] - Read CRC=7a != calculated:41 (errcount=5)
    Error:SENSOR:DS1820[17] - Scratchpad Data Read: 87 1 55 5 7f a5 b5 76 7a
    Info:SENSOR:DS1820[17] - Temp=24.43



    OK, so if I'll run the command to add repeating event, I do get the values from the sensor over MQTT. But it is not in json format, just raw value.

    I am trying to add it to my Home Assistant cluster, but sadly I am unable to get the value from it:
    mqtt:
     sensor:
        - state_topic: “Feeding/DS18B20Temp/get”
          availability_topic: "Feeding/connected"
          name: "FishTank Water Temperature"
          unique_id: “feeder1.iot.lan_water-temp”
          unit_of_measurement: "°C"
          device_class: temperature
          state_class: measurement
          icon: mdi:coolant-temperature
          force_update: true
          encoding: ""
          value_template: "{{ value | int * 0.01 }}"


    I also tried with integer switch, but while HA does see mqtt messages, I seem to be unable to define the sensor properly.
    Never had similar issues with mqtt, and I do use object detection from my cameras and binary sensors over it. But I do have to be missing something, that I am unable to get any meaningful value from the sensor in HA.

    Any ideas?
  • #22 21291298
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14622
    Help: 655
    Rate: 12637
    If you want to run multiple commands in the short startup line, you need to use "backlog":
    Screenshot of a user interface for setting startup command line for BK7231T device.
    Helpful post? Buy me a coffee.
  • #23 21291312
    Virnik0
    Level 5  
    Posts: 16
    Help: 1
    Rate: 1
    Thanks!

    Didn't noticed this to be honest.

    Using bellow fixed the issue, now it correctly starts the repeating event:
    backlog startDriver DS1820 5; waitFor WiFiState 4;waitFor MQTTState 1; addRepeatingEvent 60 -1 publishFloat DS1820Temp $CH5;


    OpenBelken FW does what it promissed to do. Data is output to proper MQTT queue/topic. Processing it correctly is another story, because it prints this:
    Feeding/DS18B20Temp/get:
    2487

    Is there a way to add decimal point to the value before it is going to be exported? To show like 24.87 in mqtt instead of 2487 it does now?
    Screenshot of an MQTT console showing various topics and values, including DS18B20Temp.

    If anyone is interested, bellow yaml snippet works in HA to collect the temperature and move decimal split to proper place:
    
    sensor:
    - platform: template
      sensors:
        fishtank_water_temperature-filtered:
          name: "FishTank Water Temperature"
          unique_id: "feeder1.iot.lan_water-temp-filtered"
          device_class: temperature
          unit_of_measurement: '°C'
          state_class: measurement
          icon: mdi:coolant-temperature
          entity_id:
            - sensor.fishtank_water_temperature-filtered
          value_template: >
            {% set unknown = 'unknown' %}
            {% set value = states('sensor.fishtank_water_temperature') %}
            {% set prev_value = states('sensor.fishtank_water_temperature-filtered') %}
            {% if prev_value == unknown %}
              {{ value }}
            {% else %}
              {% set def_deviation = 3.0 %}
              {% set cur_deviation = states('input_number.fishtank_water_temperature-deviation') %}
              {% set deviation = def_deviation if cur_deviation == unknown else float(cur_deviation) %}
              {{ prev_value if value == unknown or (value | float - prev_value | float)|abs > deviation else value }}
            {% endif %}
    
    mqtt:
      sensor:
        - state_topic: "Feeding/DS18B20Temp/get"
          name: "FishTank Water Temperature"
          unique_id: "feeder1.iot.lan_water-temp"
          unit_of_measurement: "°C"
          device_class: temperature
          state_class: measurement
          icon: mdi:coolant-temperature
          force_update: true
          availability_template: "{{ 'online' if (10.0 <= value|float(0)/100 <= 40.0) else 'offline' }}"
          value_template: >-
            {%- if value|float(0)/100 >= 10.0 and value|float(0)/100 <= 40.0 -%}
            {{ (value | float(0)) / 100 }}
            {%- else -%}
            {{ states('sensor.fishtank_water_temperature_filtered') }}
            {%- endif -%}
    


    The sensor reports back values in bellow format (so the same as OpenBelken itself report) in HA:
    24,35°C

    Above MQTT sensor definition for HA takes care of sometimes imaginary values the sensor throws out (like temperature being -1500˚C or +90˚C). It is random, but annoying. Since this is aquarium, I set the temperature range between 10˚C and 40°C being reasonable. The sensor will switch offline for one measurement which returns invalid value, and also will skip recording such a value to statistics, retaining prior value for the time being. Since the measuring happens every 60s (at least the feeder unit pushes value from DS18B20 to MQTT every 60 seconds in my case), it has no ill impact.

    This thread could be possibly closed, as basically everything I started it with was either answered, corrected, or otherwise done.

    Thanks a lot guys! Your nudging towards right direction and information I needed was really helpful.
  • #24 21291606
    Virnik0
    Level 5  
    Posts: 16
    Help: 1
    Rate: 1
    The problem is solved:
    - OpenBelken for BL602 does support DS18B20 temp sensor now
    - Correction made thanks to advices of others to configure Fish Feeder unit with proper startup sequence
    - The feeder itself was added as a template to BL602 FW (will need an update in regard to Temp sensor maybe).
    - Data from sensor is being published over MQTT and also consumed by local install of HA

    Again, thanks a lot!

Topic summary

✨ The discussion revolves around the Automatic Fish Feeder utilizing the BL602 chip, where the user successfully flashed OpenBelken firmware and integrated a DS18B20 temperature sensor. The user encountered issues with configuring the temperature sensor and automating the drum rotation to stop after one cycle. Responses included suggestions for scripting commands to manage the drum's operation and inquiries about the DS18B20 sensor's support in OpenBeken. The community expressed interest in adding support for the temperature sensor and discussed the challenges of working with the less common BL602 chip. Recent developments indicated that a DS18B20 driver is now available for BL602, and LFS support has been implemented.
Generated by the language model.

FAQ

TL;DR: With GPIO17, a 150kΩ pull-up, and the startup line wrapped in "backlog", this BL602 fish feeder can do one-shot feeding and publish water temperature locally. "The problem is solved" once DS1820 is started explicitly and MQTT publishing is scheduled. [#21291606]

Why it matters: This setup shows how to replace a low-cost feeder's cloud dependency with local OpenBeken control while keeping single-rotation feeding and aquarium temperature reporting.

Option Hardware/firmware path in thread What worked Main limitation mentioned
OpenBeken on BL602 XT-BL12 / BL602 feeder Wi‑Fi, MQTT, one-shot drum control, DS1820 later working Motor appears as PWM/light UI, extra startup scripting needed
Tasmota Mentioned as reference PulseTime behavior was the model for one rotation Not used on this BL602 feeder
TuyaLocal Used on a different WBR3 feeder Kept the other feeder working locally Did not solve the BL602 temperature-sensor path

Key insight: On this BL602 feeder, the fix was not a hardware redesign. The working formula was correct GPIO mapping, instant button mode, explicit startDriver DS1820, and a backlog startup sequence that waits for Wi‑Fi and MQTT before publishing.

Quick Facts

  • Working feeder mapping used GPIO03 = button, GPIO04 = Wi‑Fi LED, GPIO05 = PWM drum motor, and later GPIO17 = DS18B20/DS1820 data. [#20859669]
  • The DS18B20 was wired with GND to GND, data to GPIO17, and a 150kΩ pull-up resistor between data and VCC. [#20859669]
  • DS1820 polling defaults to 15s, but the thread shows startDriver DS1820 5 to reduce the interval to 5s. [#21290566]
  • A stable MQTT startup line used backlog ... addRepeatingEvent 60 -1 ..., so the feeder published temperature every 60 seconds after Wi‑Fi and MQTT were ready. [#21291312]
  • The Home Assistant filter treated 10°C to 40°C as the valid aquarium range and ignored spikes such as -1500°C or 90°C. [#21291312]

How do I make an Automatic Fish Feeder with a BL602 stop the drum automatically after one rotation in OpenBeken, similar to Tasmota PulseTime?

Use an event-based auto-off script instead of a persistent toggle. The working idea was to let the motor channel turn on, then schedule one delayed off command, just like a PulseTime-style one-shot. The maintainer suggested alias turn_off_after_time addRepeatingEvent 10 1 setChannel 1 0 plus addChangeHandler Channel1 == 1 turn_off_after_time, which gives a single timed run after activation. [#20864952]

What pin mapping and button settings worked for the Vanters ANT325 V0 Automatic Fish Feeder on the XT-BL12 BL602 module?

The working map was GPIO2 = Btn_n;1, GPIO3 = Btn;2, GPIO4 = WifiLED_n;0, and GPIO5 = PWM;3. The user also enabled Flag 6, described as instant touch reaction instead of waiting for button release. That combination made both the on-device button and the UI trigger one drum rotation reliably on the Vanters ANT325 V0 template. [#20859669]

Why does OpenBeken show the fish feeder motor control as an LED or PWM light output instead of a motor control?

Because this feeder was mapped to a PWM output, OpenBeken exposed it through the generic light-style PWM controls rather than a motor-specific class. The user explicitly noted that the UI "thinks" the toggle is an LED light and even shows color-temperature style controls, although the output actually drives a small DC motor on GPIO05. [#20867273]

How can I configure a DS18B20 temperature sensor on GPIO17 of a BL602 device running OpenBeken?

Wire it to GPIO17 with power, ground, and a 150kΩ pull-up, then start the DS1820 driver explicitly. 1. Connect data to GPIO17, GND to GND, and the resistor from data to VCC. 2. Assign the correct GPIO in OpenBeken. 3. Run startDriver DS1820, or add it to startup. The final report confirmed that BL602 OpenBeken now reads this sensor correctly after the driver is started. [#21290478]

What does the startup command need to look like in OpenBeken if I want to start the DS1820 driver, wait for Wi-Fi and MQTT, and then publish readings periodically?

Use one backlog line so OpenBeken keeps the sequence together. The working example was backlog startDriver DS1820 5; waitFor WiFiState 4;waitFor MQTTState 1; addRepeatingEvent 60 -1 publishFloat DS1820Temp $CH5;. That starts DS1820 with a 5s interval, waits for Wi‑Fi state 4 and MQTT state 1, then publishes every 60s. [#21291312]

Why does a DS18B20 on BL602 briefly report values like -1.27°C or show CRC errors before settling to the correct temperature?

Because the sensor may need one or more read cycles to synchronize after reboot. In the thread, -1.27°C appeared about 30 seconds after restart, followed by valid readings such as 24.37°C. CRC errors and scratchpad reads of ff ff ff... were also shown before a correct value appeared, which matches an unstable initial communication phase rather than a permanently dead sensor. [#21290559]

How do I publish DS18B20 temperature readings from OpenBeken to MQTT and read them correctly in Home Assistant?

Publish the raw OBK value, then scale it in Home Assistant. OpenBeken sent Feeding/DS18B20Temp/get: 2487, and the working HA template divided by 100 to display 24.87°C. The final YAML also filtered impossible aquarium readings and kept the previous good value. That made MQTT ingestion stable even when the sensor occasionally emitted bad spikes. [#21291312]

What's the reason multiple commands in the BL602 short startup line fail unless they are wrapped with backlog in OpenBeken?

Because the BL602 short startup field does not reliably execute a semicolon chain as one queued command set unless you prefix it with backlog. The maintainer explicitly said to use backlog when running multiple startup commands. After that change, the repeating DS1820 publish event survived reboot and started correctly. [#21291298]

What is LFS in OpenBeken, and why was file system browsing unavailable on some BL602 builds and partition layouts?

"LFS" is a lightweight flash file system that stores small files in device flash, with a layout that depends on the firmware partition scheme. On BL602, it was missing in earlier builds because the platform had not yet received that port. Later, the thread clarified that LFS became available on BL602, but only with the older partition layout. [#21267631]

What is the XT-BL12 module, and how is it related to the BL602 chip used in low-cost smart devices like fish feeders?

XT-BL12 is the module fitted inside this feeder, and the module contains the BL602 chip. The original post described the feeder as a low-cost eBay unit with an XT-BL12 "chiplet" and confirmed successful UART access and OpenBeken flashing. In this thread, XT-BL12 is the board-level module, while BL602 is the actual Wi‑Fi MCU inside it. [#20859669]

How does OpenBeken on BL602 compare with Tasmota or TuyaLocal for controlling a Wi-Fi fish feeder without using the vendor cloud?

OpenBeken was the only path in this thread that delivered direct BL602 control with local Wi‑Fi, MQTT, button logic, and later DS1820 support. Tasmota appeared only as a behavioral reference for PulseTime. TuyaLocal stayed in use on a different WBR3 feeder because that device already worked, but the BL602 goal was specifically to cut off the vendor cloud and keep LAN control. [#20859669]

Which BL602 partition layout is needed if I want LittleFS support, and how does BL DevCube 1.4.8 affect that setup?

Use the older BL602 partition layout if you want LittleFS. The thread states that LFS works on BL602 only on the older layout, specifically when the device was flashed with BL DevCube 1.4.8 using the stock partition_cfg_2M.toml file. If you use a different layout, web-based file browsing may not be available. [#21267631]

What is the best way to parse or convert a TuyaMCU GPIO config dump for a BL602-based device when the usual GUI flasher tools don't support reading the chip directly?

In this thread, the practical answer was manual GPIO discovery, not automatic TuyaMCU conversion. The usual GUI flasher could verify network connectivity and firmware details, but it refused to read BL602 directly and did not parse the dump for this device. The user solved the feeder by identifying GPIO03, GPIO04, GPIO05, and later building a custom template instead. [#20859669]

How should I wire a DS18B20 or DHT11 to an OpenBeken device, including pull-up resistor considerations and GPIO assignment pitfalls?

For DS18B20 here, connect data to GPIO17, GND to GND, and add a 150kΩ pull-up from data to VCC. The main pitfall was wrong pin assignment, which can produce -1.27°C or CRC faults before valid readings appear. For DHT11, the thread only asked whether a pull-up was needed and pointed to the project tutorial for the wiring example, without adding a resistor value in text. [#20859669]

What Home Assistant MQTT templates or filtering methods help ignore bad aquarium temperature readings like -1500°C or 90°C from a DS18B20?

Use a validity window and keep the last good value. The working Home Assistant setup accepted only 10.0°C to 40.0°C, marked out-of-range readings offline, and reused the previous filtered sensor state instead of recording junk values like -1500°C or 90°C. That method matched aquarium use and avoided corrupting temperature history with random spikes. [#21291312]
Generated by the language model.
ADVERTISEMENT