ECU Temperature to LUA script

It's all about the code!
Post Reply
i_s_64
Posts: 13
Joined: Tue Mar 14, 2023 1:15 am

ECU Temperature to LUA script

Post 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
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: ECU Temperature to LUA script

Post 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.
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
mck1117
running engine in first post
running engine in first post
Posts: 1493
Joined: Mon Jan 30, 2017 2:05 am
Location: Seattle-ish

Re: ECU Temperature to LUA script

Post 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')
i_s_64
Posts: 13
Joined: Tue Mar 14, 2023 1:15 am

Re: ECU Temperature to LUA script

Post 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
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: ECU Temperature to LUA script

Post by AndreyB »

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
i_s_64
Posts: 13
Joined: Tue Mar 14, 2023 1:15 am

Re: ECU Temperature to LUA script

Post 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.
Post Reply