helllo, im trying to get tps and rpm from my nissan titan into a rusefi uaefi to use it as an electronic bypass valve as a standalone unit. ive only been able to get the signals working as luagauges but i cant figure out how to send them as signals to the ecu. tunerstudio version 3.3.01 and uaefi firmware 20251018. is this possible? im sure im missing something. im very new to this lua stuff so cut me some slack.
thanks for any and all help.
this is my lua script that makes the gauges work if it helps.
-- Titan VK56 CAN -> uaEFI via Lua
-- TPS & RPM from CAN go into LuaGauge1/2
-- and are read back with getSensor("LuaGauge1/2")
setTickRate(50)
-- subscribe to Titan CAN IDs
canRxAdd(0x231) -- TPS
canRxAdd(0x23D) -- RPM
-- helper: 16-bit little-endian
local function u16le(data, offset0)
local lo = data[offset0 + 1] or 0
local hi = data[offset0 + 2] or 0
return lo + hi * 256
end
function onCanRx(bus, id, dlc, data)
-- TPS: ID 0x231, byte index 2 (0-based) = data[3]
if id == 0x231 and dlc >= 3 then
local raw = data[3] or 0
local tps = raw * 0.5 -- 0–100 %
-- drive LuaGauge1
setLuaGauge(1, tps)
-- print("TPS raw=" .. raw .. " tps=" .. tps)
end
-- RPM: ID 0x23D, bytes 3 & 4 (0-based) = data[4], data[5]
if id == 0x23D and dlc >= 5 then
local raw = u16le(data, 3)
local rpm = raw * 3.09 -- your scaling
-- drive LuaGauge2
setLuaGauge(2, rpm)
-- print("RPM raw=" .. raw .. " rpm=" .. rpm)
end
end
function onTick()
-- use CAN TPS/RPM as your "primary inputs" for uaEFI logic
local tps = getSensor("LuaGauge1") -- CAN TPS (%)
local rpm = getSensor("LuaGauge2") -- CAN RPM
-- Example: sanity debug
-- if tps and rpm then
-- print("CAN TPS=" .. tps .. " RPM=" .. rpm)
-- end
-- TODO: later, use tps/rpm here to drive the Hellcat bypass valve
end
uaefi pps and rpm over can bus as primary signals
-
SidewayzSkybaru
- Posts: 3
- Joined: Thu Nov 27, 2025 2:22 am
uaefi pps and rpm over can bus as primary signals
Last edited by SidewayzSkybaru on Thu Nov 27, 2025 9:58 pm, edited 1 time in total.
- AndreyB
- Site Admin
- Posts: 14778
- Joined: Wed Aug 28, 2013 1:28 am
- Location: Jersey City
- Github Username: rusefillc
- Slack: Andrey B

Re: uaefi tps and rpm over can bus as primary signals
you are 80% there!!!
https://github.com/rusefi/rusefi/wiki/Lua-Scripting#set-sensor-value
https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/examples/honda-bcm.txt
https://github.com/rusefi/rusefi/wiki/Lua-Scripting#set-sensor-value
https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/examples/honda-bcm.txt
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
-
SidewayzSkybaru
- Posts: 3
- Joined: Thu Nov 27, 2025 2:22 am
Re: uaefi tps and rpm over can bus as primary signals
I've tried the sensor.new commands and it ends up breaking the script and I lose the lua gauge function. I'm curious if there is some settings I need to change in order to properly use the can signals as the inputs. As I don't see any lua or can based inputs in the engine trigger or tps settings.
-
SidewayzSkybaru
- Posts: 3
- Joined: Thu Nov 27, 2025 2:22 am
Re: uaefi tps and rpm over can bus as primary signals
i was able to get rpm working but i get this error for tps 2025-11-27_10_41_11_246: EngineState: LUA: invalid calibration key [Tps1Primary]
-- rusEFI CAN Injection Script: Titan VK56
--
-- This script uses your verified decoding logic.
-- Attempts to inject RPM (working) and TPS (using alternative key).
--
setTickRate(50)
-- --- User-Defined CAN IDs and Setup ---
local CAN_ID_TPS = 0x231
local CAN_ID_RPM = 0x23D
-- Subscribe to the required CAN IDs
canRxAdd(CAN_ID_TPS)
canRxAdd(CAN_ID_RPM)
-- Globals populated by CAN receive function
canTps = 0
canRpm = 0
-- Helper: 16-bit little-endian
local function u16le(data, offset0)
local lo = data[offset0 + 1] or 0
local hi = data[offset0 + 2] or 0
return lo + hi * 256
end
-- --- 1. CAN RECEIVE HOOK (Decoding) ---
function onCanRx(bus, id, dlc, data)
-- TPS Decoding (ID 0x231, Byte Index 2)
if id == CAN_ID_TPS and dlc >= 3 then
local raw = data[3] or 0
local tps = raw * 0.5 -- Raw byte * 0.5 = TPS percentage
canTps = tps
setLuaGauge(1, tps) -- Debug Gauge 1: TPS Value
end
-- RPM Decoding (ID 0x23D, Bytes 3 & 4)
if id == CAN_ID_RPM and dlc >= 5 then
local raw = u16le(data, 3)
local rpm = raw * 3.09 -- Nissan scaling for RPM
canRpm = rpm
setLuaGauge(2, rpm) -- Debug Gauge 2: RPM Value
end
end
-- --- 2. PERIODIC INJECTION HOOK (Injecting values into the ECU) ---
function onTick()
--
RPM Injection (Confirmed working)
if canRpm and canRpm > 0 then
local rpm_int = math.floor(canRpm)
selfStimulateRPM(rpm_int)
end
--
TPS Injection (Attempting with the 'Tps1Primary' key)
if canTps then
-- This attempts to inject using the primary TPS sensor key.
setCalibration("Tps1Primary", canTps, false)
-- Fallback to the generic key, just in case:
-- setCalibration("Tps1", canTps, false)
end
end
-- rusEFI CAN Injection Script: Titan VK56
--
-- This script uses your verified decoding logic.
-- Attempts to inject RPM (working) and TPS (using alternative key).
--
setTickRate(50)
-- --- User-Defined CAN IDs and Setup ---
local CAN_ID_TPS = 0x231
local CAN_ID_RPM = 0x23D
-- Subscribe to the required CAN IDs
canRxAdd(CAN_ID_TPS)
canRxAdd(CAN_ID_RPM)
-- Globals populated by CAN receive function
canTps = 0
canRpm = 0
-- Helper: 16-bit little-endian
local function u16le(data, offset0)
local lo = data[offset0 + 1] or 0
local hi = data[offset0 + 2] or 0
return lo + hi * 256
end
-- --- 1. CAN RECEIVE HOOK (Decoding) ---
function onCanRx(bus, id, dlc, data)
-- TPS Decoding (ID 0x231, Byte Index 2)
if id == CAN_ID_TPS and dlc >= 3 then
local raw = data[3] or 0
local tps = raw * 0.5 -- Raw byte * 0.5 = TPS percentage
canTps = tps
setLuaGauge(1, tps) -- Debug Gauge 1: TPS Value
end
-- RPM Decoding (ID 0x23D, Bytes 3 & 4)
if id == CAN_ID_RPM and dlc >= 5 then
local raw = u16le(data, 3)
local rpm = raw * 3.09 -- Nissan scaling for RPM
canRpm = rpm
setLuaGauge(2, rpm) -- Debug Gauge 2: RPM Value
end
end
-- --- 2. PERIODIC INJECTION HOOK (Injecting values into the ECU) ---
function onTick()
--
if canRpm and canRpm > 0 then
local rpm_int = math.floor(canRpm)
selfStimulateRPM(rpm_int)
end
--
if canTps then
-- This attempts to inject using the primary TPS sensor key.
setCalibration("Tps1Primary", canTps, false)
-- Fallback to the generic key, just in case:
-- setCalibration("Tps1", canTps, false)
end
end

