Relays control with...
 
Notifications
Clear all

Relays control with arduino and NCalc Formula

3 Posts
3 Users
0 Reactions
1,119 Views
(@bettosauro)
New Member
Joined: 2 years ago
Posts: 1
Topic starter  

Hi everyone, from the title i want to command one or more relays using arduino by specific NCalc Formula value.

I'm making my own 3D Printed dashboard for ETS 2 with some WS2812B leds, buttons, segments display and some 3,5 - 7 inchs screen

I want to turn on a Relay if the value [GameRawData.TruckValues.CurrentValues.DashboardValues.WarningValues.AirPressureEmergency] is true

to activate in real life a beeper

I have to use Custom Arduino Hardware Support and SHCustomProtocol.h right?

Anyone can tell me how to do it?

 

Update, i see that using a WS2811 controller i can control one or more Relays via WS2812B protocol as if they were adressable LEDs but it's more complex

Thanks so much and sorry for my bad english

This topic was modified 2 years ago 2 times by Bettosauro

   
Quote
(@issacsim)
New Member
Joined: 1 year ago
Posts: 2
 

Hello,

Did you ever figure this out?

Looking to do something similar...


   
ReplyQuote
(@dadima)
Active Member
Joined: 2 years ago
Posts: 12
 

Posted by: @bettosauro

Hi everyone, from the title i want to command one or more relays using arduino by specific NCalc Formula value.

I'm making my own 3D Printed dashboard for ETS 2 with some WS2812B leds, buttons, segments display and some 3,5 - 7 inchs screen

I want to turn on a Relay if the value [GameRawData.TruckValues.CurrentValues.DashboardValues.WarningValues.AirPressureEmergency] is true

Hello. I'm not fully understand your requirements, but in order to make some if statement and return the value 1 if true, and 0 if false, it should be something like this. 

Set in simhub ncalc binding

if([GameRawData.TruckValues.CurrentValues.DashboardValues.WarningValues.AirPressureEmergency], 1,0)

Then to control your hardware device(i.e arduino), set in your ShcustomProtocol.h file something like this

int myLed =FlowSerialReadStringUntil('\n').toINT()

This is as far as I remembered. Sorry, this code were not tested, as I'm not in front of my pc. You can try to see example 2 in the ShcustomProtocol.h script as your reference. 

For the beeper, I've only use it in the dash. I am mapping a trigger event that will make a beep sounds on my pc whenever some requirements are met. I need to set the requirements in the sample.ini script as an "ExportEvent". 

It will look something like this. 

[ExportEvent]
value = myBeep
trigger =[GameRawData.TruckValues.CurrentValues.DashboardValues.WarningValues.AirPressureEmergency]

Try to adjust trigger code as needed.

Next, in the "control and events" tab on left side of simhub, your new event will be recognised as ExternalScript.myBeep. 

Ensure that you restart simhub after saving your sample.ini files. 

Good luck, have fun

 

 


   
ReplyQuote
Share: