Skip to content

xdrv_92_vid6608: Advanced zero routine for analog gauges, library update#24218

Merged
arendst merged 2 commits intoarendst:developmentfrom
petrows:arduino-vid6608-fixes-2
Dec 13, 2025
Merged

xdrv_92_vid6608: Advanced zero routine for analog gauges, library update#24218
arendst merged 2 commits intoarendst:developmentfrom
petrows:arduino-vid6608-fixes-2

Conversation

@petrows
Copy link
Contributor

@petrows petrows commented Dec 12, 2025

Description:

This PR now allow to optionally skip default homing operation for Analog gauge driver. Can be used, is user wants to keep track of moving gauge and save last executed position, then call homing operation from saved position. This will avoid any send-stop bouncing and significantly increase lifetime of stepper drive.

To skip default Zero the new define VID6608_RESET_ON_INIT shoud be defined as false. Default value is true.

If gauge was moved or drifted from real position, the zero routine will perform correct homing. In case of incorrect position only few bouncing is expected, homing operation will be performed in any case.

This PR adds options:

  • Define VID6608_RESET_ON_INIT: allows to optionally enable / disable default drives zero on startup
  • The GaugeZero function now gets argument: what position is assume as base while performing gauge homing

Fixes:

  • The arduino-vid6608 library updated to version 1.0.3
  • Fixed initialization of internal variable, if zero skipped

Example of Berry Script with store position in I2C FRAM chip and restore on startup. Tested with MB85RC04V chip:

# Connect and preare i2c FRAM MB85RC04V
var fram_addr = 0x50
var wire = tasmota.wire_scan(fram_addr)
# Address in FRAM to store last gauge position
var addr_pos = 0x0000
# Check initialization
if !wire
   print("FRAM not found")
end
# Function to write FRAM memory, 2 bytes
def fram_write_u16(addr, data)
 if !wire
  return 0
 end
 # Split address and data into two bytes
 var addr_hi = (addr >> 8) & 0x7F
 var addr_lo = addr & 0xFF
 var data_hi = (data >> 8)
 var data_lo = data & 0xFF
 # ---------------- WRITE ----------------
 wire._begin_transmission(fram_addr)
 wire._write(addr_hi)
 wire._write(addr_lo)
 wire._write(data_hi)
 wire._write(data_lo)
 wire._end_transmission(true)
end
# Function to read FRAM memory, 2 bytes
def fram_read_u16(addr)
 if !wire
  return 0
 end
 # Split address and data into two bytes
 var addr_hi = (addr >> 8) & 0x7F
 var addr_lo = addr & 0xFF
 # ---------------- READ ----------------
 wire._begin_transmission(fram_addr)
 wire._write(addr_hi)
 wire._write(addr_lo)
 wire._end_transmission(true)
 wire._request_from(fram_addr, 2)
 var value_hi = wire._read()
 var value_lo = wire._read()
 var value = (value_hi << 8) | value_lo
 return value
end
# Read last gauge position from FRAM
var last_gauge_pos = fram_read_u16(addr_pos)
if last_gauge_pos
 print("FRAM gauge pos read:", last_gauge_pos)
end
# Call Reset option from saved position
tasmota.cmd("GaugeZero " + str(last_gauge_pos))
# Function to update Gauge position on CO2 change
def co2_update(value, trigger)
 var drivePos = 180 + ((int(value) - 400) * 2)
 if last_gauge_pos != drivePos
  tasmota.cmd("GaugeSet " + str(drivePos))
  last_gauge_pos = drivePos
  # Save current position into FRAM
  fram_write_u16(addr_pos, int(drivePos))
 end
end
# Add rule to monitor CO2 changes
tasmota.add_rule("S8#CarbonDioxide", co2_update)

Checklist:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works with Tasmota core ESP8266 V.2.7.8
  • The code change is tested and works with Tasmota core ESP32 V.3.1.7
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

@arendst arendst merged commit 272fd43 into arendst:development Dec 13, 2025
64 checks passed
echo-bravo-yahoo pushed a commit to echo-bravo-yahoo/Tasmota that referenced this pull request Jan 9, 2026
…ate (arendst#24218)

* VID6608: Add option to skip auto-zero rouitine

* VID6608: Update library to version 1.0.3, add Zero control for Gauge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants