Realdash UI that will also include the air conditioner

Hi: I’m working on a new project. I want to build a new UI that will also include the air conditioner. I currently have an analog air conditioner and I want to make it digital. I have no problem doing it with Arduino, two stepper motors and PWM. To my question, is it possible to include a button command that will be transmitted to another model that will bridge the OBD to the head unit or send a command via Bluetooth to arduino

Sure, you can use RealDash CAN protocol to communicate with any kind of custom device. See manual here:

RealDash-extras/RealDash-CAN at master · janimm/RealDash-extras · GitHub

1 Like

I can see how you receive the data via the example. How do you initiate the communication from RealDash? Say I want to hit a button on my dash and send a command/data to my micro controller.

Can it also send the data over the same serial connection it is using to receive the data from the micro controller?

thanks,
david

I’m just working on it as far as I understand the code must be embedded in the arduino to know it’s getting a command to which pins to send them to

I don’t understand how to have RealDash initiate a command to the microcontroller which in turn will take action on that message.

For example:

  1. On the dash you hit the AC button to turn on the AC.
  2. This button triggers an action to send the command over bluetooth/serial/wifi/? to the microcontroller.
  3. Microcontroller receives the command and turns on the AC via whatever mechanism is required. Turn on a relay, pwm to a servo, etc.

I don’t understand Step 2. How do you assign the action to RealDash to send the message to the microcontroller.

thanks
david

This is exactly what I’m checking right now to send a command to the Arduino, it’s not a problem because it works like a mechanical button and the code is defined that the button is pressed, the motor will rotate 50 degrees (for example) from what I understand the command in REALDASH must be a type of string, meaning that if I press a button it must send the the string to the arduino and from there it will translate it into a command

btw, now I see that it is necessary to write an XML file as well
This makes it much more complicated

I came across this thing

First, define a CAN frame that has your ‘virtual buttons’ defined:

<frame id="0xFEFE">
    <value name="My Virtual Button 1" offset="0" length="1"></value>
</frame>

To make this as simple as possible, we use entire byte of the frame for one button. In reality, you should pack button states into individual bits.

Now, when you use a XML file that has above frame defined, and your are connected to a RealDash CAN device, RealDash will automatically send this CAN frame to the device when value contained in CAN frame is changed by an Action:

  • Add a button to your dashboard
  • Add an Action to your button
  • Use Action ‘Toggle Value’ and link it to input ‘My Virtual Button 1’ (Same as XML)
  • Save your dashboard.

Now every time you press the button, RealDash sends the entire CAN frame with updated values.

1 Like

Thanks for the answer
But the truth is that I could not understand the code

  1. What is the code for the connection protocol to the Arduino in a serial connection
  2. You set a button that sends 0 or 1. What do I set on the Arduino if you received a command from “My Virtual Button 1” take 50 steps forward I didn’t understand how the Arduino knows who is. “My Virtual Button 1”
    I have the following codes can you please tell me if it is in the right direction
> <?xml version="1.0" encoding="utf-8"?>
> <RealDashCAN version="2">
>   <frames baseId="3200">
>     <frame id="3200" writeInterval="1000">
>       <value name="Stepper1_Forward" units="bit" offset="0" length="1" />
>       <value name="Stepper1_Backward" units="bit" offset="1" length="1" />
>       <value name="Stepper2_Forward" units="bit" offset="2" length="1" />
>       <value name="Stepper2_Backward" units="bit" offset="3" length="1" />
>     </frame>
>   </frames>
> </RealDashCAN>
#include <CAN.h>
#include <AccelStepper.h>


AccelStepper stepper1(AccelStepper::FULL4WIRE, 2, 3, 4, 5);
AccelStepper stepper2(AccelStepper::FULL4WIRE, 6, 7, 8, 9);

void setup() {
  Serial.begin(9600);
  while (!Serial);

  if (!CAN.begin(500E3)) {
    Serial.println("Starting CAN failed!");
    while (1);
  }

  
  stepper1.setMaxSpeed(1000);
  stepper1.setAcceleration(500);
  stepper2.setMaxSpeed(1000);
  stepper2.setAcceleration(500);
}

void loop() {
  int packetSize = CAN.parsePacket();

  if (packetSize) {
    while (CAN.available()) {
      int command = CAN.read();
      switch (command) {
        case 1:
          stepper1.moveTo(stepper1.currentPosition() + 200); 
          break;
        case 2:
          stepper1.moveTo(stepper1.currentPosition() - 200); 
          break;
        case 3:
          stepper2.moveTo(stepper2.currentPosition() + 200); 
          break;
        case 4:
          stepper2.moveTo(stepper2.currentPosition() - 200); 
          break;
      }
    }
  }

  
  stepper1.run();
  stepper2.run();
}

Here is the Arduino example on how to send & receive RealDash CAN frames:

RealDash-extras/RealDash-CAN/Arduino-examples at master · janimm/RealDash-extras · GitHub

There is a multitude of issues in your XML snippet:

  • You use baseId and id for CAN frames. That would make your CAN frame id to 3200+3200 (6400 dec). Its ok, but probably not what you want.
  • On values you use units=“bit”, but your Arduino code suggest that you want to receive values other than 0 or 1. When units=“bit” is set, value is determined only from least significant bit of the byte making it 0 or 1.

Also, your code does not show how you transmit/receive the CAN frames over serial to RealDash. That indicates that you have 3rd CAN device on your setup and RealDash is not connected to your Arduino code in any way. Don’t know how your setup is, but seems complicated to troubleshoot remotely.

Thanks for the answer
I tried the example in the link you gave, it works great, I connected the Arduino to the multimedia via USB, everything works, RX TX flashes, RPM and everything else works
The problem is that the explanations and the code there are too complicated
A new example needs to be uploaded on how to connect REALDASH to Arduino, how to read simple information and how to send a command