Page 1 of 1

ECU Temperature to LUA script

Posted: Fri Mar 17, 2023 8:12 pm
by i_s_64
Hey guys,

I have my ECU positioned in a pretty tight and potentially warm area and would like to occasionally use a fan to get air circulating in that area as a precaution. I thought about using a Temp input, running a sensor and using a LUA script to switch on the fan if it gets too warm in there.

But then I realized Rusefi actually can show and log the MCU temp. So I thought about running a LUA script to activate the fan based on the MCU temp and not using up an extra Temp input and cut down on the bulk of wiring. It looks like I can't get Internal MCU temps with LUA using the getSensor function since it's not a defined sensor name.

I was wondering if there's another function that I can use to access this info. I plan to set it up with a basic script curve, or even if I just set it up as a switch in the LUA script, that would work too.

Alex

Re: ECU Temperature to LUA script

Posted: Fri Mar 17, 2023 10:55 pm
by AndreyB
https://github.com/rusefi/rusefi/wiki/Lua-Scripting#basics

All outputs from the firmware can be read via the universal getOutput() hook

https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/generated/output_lookup_generated.cpp looks weird because https://github.com/rusefi/rusefi/issues/4867 needs to be finished to make this usable. Are you a software developer by any chance to help? If not we are waiting for a software developer who could help, pretty basic change since very much similar generator already works for calibration, or something like that.

Re: ECU Temperature to LUA script

Posted: Fri Mar 17, 2023 10:58 pm
by mck1117
AndreyB wrote:
Fri Mar 17, 2023 10:55 pm
All outputs from the firmware can be read via the universal getOutput() hook
we can at least hand 'em a fish this time, the relevant output to read in this case is called internalMcuTemperature, so you'd call

Code: Select all

getOutput('internalMcuTemperature')

Re: ECU Temperature to LUA script

Posted: Sat Mar 18, 2023 12:17 am
by i_s_64
AndreyB wrote:
Fri Mar 17, 2023 10:55 pm
https://github.com/rusefi/rusefi/wiki/Lua-Scripting#basics

All outputs from the firmware can be read via the universal getOutput() hook

https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/generated/output_lookup_generated.cpp looks weird because https://github.com/rusefi/rusefi/issues/4867 needs to be finished to make this usable. Are you a software developer by any chance to help? If not we are waiting for a software developer who could help, pretty basic change since very much similar generator already works for calibration, or something like that.
I used to develop software in the past on a professional basis, but I can no longer call myself a software developer. We're probably talking about 15+ years since my last professional software development work. Pre-Github, which is close to being over my head. I have been wrenching on cars for too long.


mck1117 wrote:
Fri Mar 17, 2023 10:58 pm
AndreyB wrote:
Fri Mar 17, 2023 10:55 pm
All outputs from the firmware can be read via the universal getOutput() hook
we can at least hand 'em a fish this time, the relevant output to read in this case is called internalMcuTemperature, so you'd call

Code: Select all

getOutput('internalMcuTemperature')
Thank you. I didn't spot it in the official list of outputs seen here https://github.com/rusefi/rusefi/blob/master/firmware/controllers/sensors/sensor_type.h so I didn't think to try it.
But thank you

Re: ECU Temperature to LUA script

Posted: Sat Mar 18, 2023 1:26 am
by AndreyB

Re: ECU Temperature to LUA script

Posted: Sat Mar 18, 2023 2:12 am
by i_s_64
Thanks guys. I've implemented it and it works as intended. It saves me some time since I don't have to wire up another sensor for ECU Temp.