• Products
    • Isadora
    • Get It
    • ADD-ONS
    • IzzyCast
    • Get It
  • Forum
  • Help
  • Werkstatt
  • Newsletter
  • Impressum
  • Dsgvo
  • Press
  • Isadora
  • Get It
  • ADD-ONS
  • IzzyCast
  • Get It
  • Press
  • Dsgvo
  • Impressum

Navigation

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags

    [ANSWERED] Sending data from Arduino to Isadora

    How To... ?
    6
    15
    877
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      Ravenetta @Juriaan last edited by

      @juriaan this is the message i receive if i use the serial watcher- text actor this happens after about a minute, the actor itself does not show any signs of receiving data, once i have this data accurately coming into Isadora the plan is to have this data be able to be readable within the soft wear so i can send these values to edit brightness of content based on the distance of a person. 

      DusX 1 Reply Last reply Reply Quote 0
      • DusX
        DusX Tech Staff @Ravenetta last edited by

        @ravenetta

        Looking at your messages, I think you should try the 'Serial In Watcher - Text' actor.

        Troikatronix Technical Support

        • New Support Ticket Link: https://support.troikatronix.com/support/tickets/new
        • My Add-ons: https://troikatronix.com/add-ons/?u=dusx
        • Profession Services: https://support.troikatronix.com/support/solutions/articles/13000109444-professional-services

        Running: Win 11 64bit, i7, M.2 PCIe SSD's, 32gb DDR4, nVidia GTX 4070 | located in Ontario Canada.

        R 1 Reply Last reply Reply Quote 0
        • R
          Ravenetta @DusX last edited by

          @dusx 

          hi thanks for the suggestion, I'm not sure how this actor works as the error message above is when I tried the text actor, I wasn't receiving any indication that data was being received by this actor other than the error above popping up every minute or so? The message received part of the actor wasn't even triggering unlike the digital actor witch seemed to trigger this section.

          Juriaan 1 Reply Last reply Reply Quote 0
          • Juriaan
            Juriaan Tech Staff @Ravenetta last edited by

            @ravenetta

            Well, according to the error message your EOM character is not 13. Could you share the Arduino code with us?

            Isadora 3.1.1, Dell XPS 17 9710, Windows 10
            Interactive Performance Designer, Freelance Artist, Scenographer, Lighting Designer, TroikaTronix Community moderator
            Always in for chatting about interaction in space / performance design. Drop me an email at hello@juriaan.me

            R 1 Reply Last reply Reply Quote 0
            • R
              Ravenetta @Juriaan last edited by Ravenetta

              @juriaan this is the current code I have in the arduino the error message above was when using the serial in watcher - Text 

              The videos if data being 'recived' was with using the serial in watcher - binary 

              No code changes with arduino 

              S DusX Woland 3 Replies Last reply Reply Quote 0
              • S
                skuven Beta Silver @Ravenetta last edited by

                @ravenetta

                Might be most helpful to copy and paste the code than an image we can't copy the code from..? maybe upload a text file with it if thats possible?

                1 Reply Last reply Reply Quote 0
                • DusX
                  DusX Tech Staff @Ravenetta last edited by DusX

                  @ravenetta

                  Since it appears your EOL is causing the buffer to fill, you could try not using Serial.println() to automatically add a EOL (end of each text  segment), and instead use Serial.print("\r") to add an EOL that you have control of. Often "\r\n" are used, these correspond to the ASCII values 13 (CR) and 10 (LF), in this case we only need to add/find "\r" or value 13

                  EOL = 13, sets the actor to look for a carriage return (13). 
                  You can learn a bit about using these here: newline - Difference between \n and \r? - Stack Overflow

                  Once you are adding your own EOL, you can makes changes and test in Isadora until you get the output you are expecting.

                  Troikatronix Technical Support

                  • New Support Ticket Link: https://support.troikatronix.com/support/tickets/new
                  • My Add-ons: https://troikatronix.com/add-ons/?u=dusx
                  • Profession Services: https://support.troikatronix.com/support/solutions/articles/13000109444-professional-services

                  Running: Win 11 64bit, i7, M.2 PCIe SSD's, 32gb DDR4, nVidia GTX 4070 | located in Ontario Canada.

                  1 Reply Last reply Reply Quote 0
                  • Woland
                    Woland Tech Staff @Ravenetta last edited by

                    @ravenetta @skuven 

                    Here's what you had:*

                    *I think it is anyway. I cannot tell if you had
                    "Serial.printIn" with an upper-case "i" (incorrect)
                    or
                    "Serial.println" with a lower-case "L" (correct)

                    #include <SoftwareSerial.h>
                    SoftwareSerial mySerial(11,10); // RX, TX
                    unsigned char data[4]={};
                    float distance;
                    void setup()
                    {
                        Serial.begin(57600);
                        mySerial.begin(9600);
                    }
                    void loop()
                    {
                        do{
                        for(int i=0;i<4;i++)
                        {
                        data[i]=mySerial.read();
                        }
                        }while(mySerial.read()==0xff);
                        mySerial.flush();
                        if(data[0]==0xff)
                        {
                        int sum;
                        sum=(data[0]+data[1]+data[2])&0x00FF;
                        if(sum == data[3])
                        {
                        distance=(data[1]<<8)+data[2];
                        if(distance>30)
                        {
                        Serial.print("distance=");
                        Serial.print(distance/10);
                        Serial.println("cm");
                        }else
                        {
                        Serial.println("Below the lower limit");
                        }
                        }else Serial.println("ERROR");
                        }
                        delay(100);
                    }

                    I'm unable to trouble-shoot your code myself, but I've had success troubleshooting JavaScript Code with ChatGPT, so here's what it said about your code:

                    Issues Identified:

                    1. Incorrect Use of mySerial.read() in the do...while Condition:
                      1. The do...while loop reads an extra byte with mySerial.read() in the condition. This might lead to unexpected behavior as it consumes a byte that is not being processed.
                    2. mySerial.flush() Usage:
                      1. mySerial.flush() in SoftwareSerial does not flush the input buffer; instead, it waits for outgoing data to finish transmitting. Using it here is unnecessary.
                    3. Handling mySerial.read() Return Values:
                      1. mySerial.read() can return -1 if no data is available. This needs to be checked before assigning the read value to data[i].
                    4. Hardcoded Limit Check:
                      1. The condition distance > 30 is hardcoded. If this is a threshold specific to the application, it would be better to define it as a constant for clarity.
                    5. Lack of Non-blocking Delay:
                      1. The delay(100) call blocks further execution, which can be problematic if the loop needs to process data continuously or in real-time.
                    #include <SoftwareSerial.h>
                    SoftwareSerial mySerial(11, 10); // RX, TX
                    unsigned char data[4] = {};
                    float distance;
                    const int LOWER_LIMIT = 30; // Define threshold as a constant
                    void setup()
                    {
                        Serial.begin(57600);
                        mySerial.begin(9600);
                    }
                    void loop()
                    {
                        // Ensure enough data is available before proceeding
                        if (mySerial.available() >= 4)
                        {
                            // Read 4 bytes into the data array
                            for (int i = 0; i < 4; i++)
                            {
                                int byteReceived = mySerial.read();
                                if (byteReceived == -1) return; // Exit if no valid data is read
                                data[i] = byteReceived;
                            }
                            // Check the first byte for the expected header
                            if (data[0] == 0xFF)
                            {
                                // Calculate checksum
                                int sum = (data[0] + data[1] + data[2]) & 0x00FF;
                                if (sum == data[3]) // Validate checksum
                                {
                                    // Calculate distance
                                    distance = (data[1] << 8) + data[2];
                                    if (distance > LOWER_LIMIT)
                                    {
                                        Serial.print("Distance = ");
                                        Serial.print(distance / 10.0); // Divide by 10 for decimal result
                                        Serial.println(" cm");
                                    }
                                    else
                                    {
                                        Serial.println("Below the lower limit");
                                    }
                                }
                                else
                                {
                                    Serial.println("ERROR: Checksum mismatch");
                                }
                            }
                        }
                        delay(100); // Optional: Use millis() for non-blocking delays if needed
                    }

                    (Personally I'm not sure about the "</SoftwareSerial.h>" in the last line, so if this code doesn't run, try it with the last line as just "}".)


                    Claude said similar, but not identical things:

                    1. Error Handling in Serial Reading:
                      1. mySerial.read() returns -1 if no data is available, which might cause unexpected behavior
                      2. The current do-while loop may get stuck if no valid data is received
                    2. Checksum Calculation:
                      1. The checksum calculation looks correct, but ensure the sensor protocol matches exactly
                      2. The &0x00FF might be unnecessary if you're using standard 8-bit arithmetic

                    Key changes:

                    • Check mySerial.available() before reading
                    • Use bitwise OR | instead of addition for distance calculation
                    • Added decimal to distance division for float precision
                    • Simplified error handling

                    Potential debugging steps:

                    1. Verify sensor protocol matches this exact format
                    2. Check physical connections
                    3. Use Serial Monitor to verify data reception
                    #include <SoftwareSerial.h>
                    SoftwareSerial mySerial(11, 10); // RX, TX
                    unsigned char data[4] = {};
                    float distance;
                    void setup() {
                        Serial.begin(57600);
                        mySerial.begin(9600);
                    }
                    void loop() {
                        if (mySerial.available() >= 4) {
                            for (int i = 0; i < 4; i++) {
                                data[i] = mySerial.read();
                            }
                            if (data[0] == 0xFF) {
                                int sum = (data[0] + data[1] + data[2]) & 0xFF;
                                if (sum == data[3]) {
                                    distance = (data[1] << 8) | data[2];
                                    if (distance > 30) {
                                        Serial.print("Distance = ");
                                        Serial.print(distance / 10.0);
                                        Serial.println(" cm");
                                    } else {
                                        Serial.println("Below lower limit");
                                    }
                                } else {
                                    Serial.println("Checksum error");
                                }
                            }
                        }
                        delay(100);
                    }

                    TroikaTronix Technical Support
                    New Support Ticket: https://support.troikatronix.com/support/tickets/new
                    Support Policy: https://support.troikatronix.com/support/solutions/articles/13000064762
                    Add-Ons: https://troikatronix.com/add-ons/ & https://troikatronix.com/add-ons/?u=woland
                    Professional Services: https://support.troikatronix.com/support/solutions/articles/13000109444

                    | Isadora Version: all of them | Mac Pro (Late 2013), macOS 10.14.6, 3.5GHz 6-core, 1TB SSD, 64GB RAM, Dual AMD FirePro D700s |

                    R 1 Reply Last reply Reply Quote 0
                    • R
                      Ravenetta @Woland last edited by Ravenetta

                      @woland @Juriaan @DusX here is a video i have of the full set up i am doing in isadora at the moment, i now have the data i am looking or coming in at the end as you can see, however this data does not keep receiving for an extended period as you'll see if you skip to the end of the video, the actor also now shows no indication that it is receiving input? i have used "msg:string={00-FF}" within the actor itself and from using the code suggested above the speed is now 57600 instead of 9600




                       
                      DusX 1 Reply Last reply Reply Quote 0
                      • DusX
                        DusX Tech Staff @Ravenetta last edited by

                        @ravenetta

                        Using this ascii chart: upload.wikimedia.org/wikipedia/commons/d/dd/ASCII-Table.svg

                        I can see that when you receive a Distance, you are getting the value followed by cm and a carrage return and a line feed. so "\r\n"

                        You get the same EOL for your errors, so you should be able to use the Serial In Watcher - Text actor with a EOL of 13. You can use this same msg:string={00-FF} to allow all character thru.

                        Troikatronix Technical Support

                        • New Support Ticket Link: https://support.troikatronix.com/support/tickets/new
                        • My Add-ons: https://troikatronix.com/add-ons/?u=dusx
                        • Profession Services: https://support.troikatronix.com/support/solutions/articles/13000109444-professional-services

                        Running: Win 11 64bit, i7, M.2 PCIe SSD's, 32gb DDR4, nVidia GTX 4070 | located in Ontario Canada.

                        1 Reply Last reply Reply Quote 2
                        • First post
                          Last post