Asked — Edited

Roboquad Resurrection With ESP-32 And ARC

@DJ Sures, @Athena,

Back in the day with the EZ-B V3, I modified my RoboQuad to control it based on a tutorial or guidance from you. The basic idea was to intercept the IR receiver, hardwire it into the EZ-B, and send the codes to the robot via output from the EZ-B V3. When the EZ-B V4 was released, there was an issue you mentioned that prevented it from working correctly. It had something to do with the string codes needing to be sent over Wi-Fi instead of Bluetooth, but I can't recall the details.

Now, using the Flipper Zero, I should be able to retrieve the action and movement codes. What if I used an ESP32 with modified firmware to store the codes onboard the ESP32, with ARC sending various bit combinations to represent specific IR code outputs?

Do you have any pointers or ideas on how to get started? I plan to use the Flipper Zero to capture the IR codes first. Do you still have the old codes and strings you used to send? Is there anything specific I need to know before attempting this?

User-inserted image


Related Controls firebase WebSocket Server

ARC Pro

Upgrade to ARC Pro

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.

PRO
Synthiam
#1   — Edited

That was a million years ago lol. Here's the code that you could modify for arduino but I don't remember much bout the commands. they were byte values, so you could play with commands to figure it out.

Essentially, to convert this arduino you'd need to convert the output_low and output_high to digitalWrite(). The delay_us, whatever the Arduino equitant is, etc... The code below was for a different compiler on the eZB microchip pic, not arduino.

// Send roboquad command
void RoboQuadSendCommand(int command) {

  int i;

  output_drive(PIN_D1);
  
  disable_interrupts(int_timer2);      

  // 1
  output_low(PIN_D1);
  delay_us(7213);

  // 2
  output_high(PIN_D1);
  delay_us(994);

  // 3
  output_low(PIN_D1);
  delay_us(722);

  // 4
  output_high(PIN_D1);
  delay_us(3692);

  // 5
  output_low(PIN_D1);
  delay_us(722);

  // 6
  output_high(PIN_D1);
  delay_us(3692);

  // 7
  output_low(PIN_D1);
  delay_us(722);
  
  // 8
  output_high(PIN_D1);
  delay_us(994);

  // 9
  output_low(PIN_D1);
  delay_us(722);

  for (i=0;i<8;i++) {
  
    output_high(PIN_D1);
       
    if ((command & 128) == 0) 
      delay_us(994);
    else
      delay_us(3692);
              
    output_low(PIN_D1);
    
    delay_us(722);
    
    command <<= 1;
  }

  output_high(PIN_D1);
  
  enable_interrupts(int_timer2);
}

// Send robosapien command
void RSSendCommand(int command) {

  int i;

  output_drive(PIN_D1);

  disable_interrupts(int_timer2);      
  
  output_low(PIN_D1);
  delay_us(6394);
  
  for (i=0;i<8;i++) {
  
    output_high(PIN_D1);
    
    delay_us(900);
    
    if ((command & 128) !=0) 
      delay_us(1800);
      
    output_low(PIN_D1);
    
    delay_us(900);
    
    command <<= 1;
  }
 
  output_high(PIN_D1);
  
  enable_interrupts(int_timer2);        
}

#2  

@DJ Sures, I have been hanging out here with you since your started!  Thanks for the code, I will look to decipher it and show you what I am attempting to do along the way.   I love engineering puzzles! The pro subscription helps keep my brain sharp by dreaming up things to do and try.

BTW - Here is your original post! 

PRO
Synthiam
#3  

@athena can you rewrite that code to work with arduino. Also do you have any idea what the commands are for the wowee roboquad?

#4  

Here is what the flipper zero created from the remote learning session. Note sure what to do with this, but its interesting!  I named the commands each time it received a new sequence from the remote.

Filetype: IR signals file
Version: 1
# 
name: Fwd
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 6972 905 744 3521 742 3525 760 911 743 923 739 903 760 923 739 897 765 906 744 905 757 902 761 3510 713
# 
name: Left
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 6966 931 744 3524 740 3525 712 963 739 910 713 947 715 947 742 919 744 911 735 937 742 3514 762 3509 743
# 
name: Right
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 6970 932 742 3523 741 3527 710 958 744 909 714 948 715 947 742 921 742 910 737 3537 744 918 744 912 711
# 
name: Reverse
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 6973 932 794 3472 793 3483 740 912 712 960 794 851 812 850 812 857 793 859 712 961 793 3464 811 858 793
# 
name: Stop
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 7053 900 759 3521 743 3516 757 912 740 912 760 911 742 923 739 924 739 902 760 911 740 908 715 948 741
# 
name: Fwd_left
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 6993 905 745 3522 742 3526 759 910 744 922 741 903 760 902 761 897 765 906 744 3515 762 907 742 3538 738
# 
name: Fwd_right
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 6972 906 744 3522 742 3527 709 958 745 923 740 902 761 900 763 899 763 907 743 3514 762 3519 745 924 738
# 
name: Rev_left
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 6973 904 745 3521 743 3525 711 960 743 905 767 897 716 946 744 920 743 908 765 3511 742 3521 715 3559 746
# 
name: Rev_right
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 6926 955 794 3473 791 3483 794 859 713 960 794 872 791 850 813 848 807 3465 716 948 793 871 792 857 714
# 
name: Turn_right
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 6927 956 792 3472 792 3484 793 860 713 962 790 853 810 849 814 848 736 3537 715 949 791 871 791 3487 789
# 
name: Turn_left
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 6977 903 745 3523 741 3533 743 910 712 957 746 923 739 899 763 905 745 3537 740 923 739 3507 716 946 744
# 
name: Demo
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 7058 900 761 3519 746 3537 738 905 747 912 762 909 743 923 740 3514 762 907 744 3514 763 3507 716 946 744
# 
name: Head_up
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 6991 948 746 3530 714 3566 744 912 764 3513 717 952 741 921 745 909 767 896 718 952 714 949 745 3543 740
# 
name: Head_down
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 6961 951 741 3529 714 3564 745 913 764 3524 746 903 762 900 765 910 743 906 769 900 715 3566 744 910 714
# 
name: Head_right
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 7142 911 714 3567 745 3527 714 962 744 3517 765 906 746 908 716 948 718 3566 744 908 716 947 719 3565 745
# 
name: Head_left
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 7124 910 714 3566 745 3523 718 946 746 3528 764 896 717 947 718 949 744 3523 769 897 717 3564 745 907 717

PRO
Canada
#5  

Certainly! Let's fill in the entire program with example IR code for the ESP32. This example will use the IRremoteESP8266 library to send IR commands. Make sure you have this library installed in your Arduino IDE.

Complete Arduino Program for ESP32 with UDP and IR Code

#include <WiFi.h>
#include <WiFiUdp.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>

const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";

WiFiUDP udp;
unsigned int localUdpPort = 12345;  // Local port to listen on
char incomingPacket[255];  // Buffer for incoming packets

IRsend irsend(4);  // Set the GPIO pin for the IR LED

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }

  Serial.println("Connected to WiFi");
  Serial.print("IP Address: ");
  Serial.println(WiFi.localIP());  // Display the IP address

  udp.begin(localUdpPort);
  irsend.begin();  // Initialize the IR sender
}

void loop() {
  int packetSize = udp.parsePacket();
  if (packetSize) {
    int len = udp.read(incomingPacket, 255);
    if (len > 0) {
      incomingPacket[len] = 0;
    }
    Serial.printf("Received packet: %s\n", incomingPacket);

    // Process the command
    switch (incomingPacket[0]) {
      case 'F':
        sendIRCommandFwd();
        break;
      case 'L':
        sendIRCommandLeft();
        break;
      case 'R':
        sendIRCommandRight();
        break;
      case 'B':
        sendIRCommandReverse();
        break;
      case 'S':
        sendIRCommandStop();
        break;
      // Add more cases for additional commands
    }
  }
}

void sendIRCommandFwd() {
  Serial.println("Sending IR command: Forward");
  irsend.sendNEC(0x00FF18E7, 32);  // Example NEC code for Forward
}

void sendIRCommandLeft() {
  Serial.println("Sending IR command: Left");
  irsend.sendNEC(0x00FF10EF, 32);  // Example NEC code for Left
}

void sendIRCommandRight() {
  Serial.println("Sending IR command: Right");
  irsend.sendNEC(0x00FF5AA5, 32);  // Example NEC code for Right
}

void sendIRCommandReverse() {
  Serial.println("Sending IR command: Reverse");
  irsend.sendNEC(0x00FF4AB5, 32);  // Example NEC code for Reverse
}

void sendIRCommandStop() {
  Serial.println("Sending IR command: Stop");
  irsend.sendNEC(0x00FF38C7, 32);  // Example NEC code for Stop
}

Notes:

  • Replace your_SSID and your_PASSWORD with your WiFi credentials.
  • Replace the example NEC codes with the actual IR codes for your RoboQuad. You can capture these using your Flipper Zero or another IR receiver.
  • Ensure the IR LED is connected to the correct GPIO pin (GPIO 4 in this example).
  • Make sure the IRremoteESP8266 library is installed in your Arduino IDE.

Feel free to ask if you have any questions or need further assistance!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
PRO
Synthiam
#6  

@athena now show how to use the ARC Net.sendUDP() to send the commands in a custom movement panel

PRO
Canada
#7  

Certainly!To send commands from ARC to your ESP32 using the Net.sendUDP() function, you can create a custom Movement Panel in ARC. This will allow you to send specific commands to control your RoboQuad. Here's how you can set it up:

Step-by-Step Guide to Use Net.sendUDP() in ARC

  1. Create a Custom Movement Panel:

    • Open ARC and create a new project.
    • Add a "Custom Movement Panel" to your project.
  2. Configure the Custom Movement Panel:

    • Open the configuration for the Custom Movement Panel.
    • You'll see options to add scripts for different movement directions (Forward, Left, Right, Reverse, Stop).
  3. Add JavaScript or Python Code to Send UDP Commands:

    For each movement direction, you'll use the Net.sendUDP() function to send a command to the ESP32. Here's an example of how you can set up each direction:

    // Define the IP address and port of the ESP32
    var esp32IP = "192.168.1.100"; // Replace with your ESP32's IP address
    var esp32Port = 12345; // The port you set in the ESP32 code
    
    // Function to send a UDP command
    function sendUDPCommand(command) {
        var commandBytes = new Uint8Array(command.length);
        for (var i = 0; i < command.length; i++) {
            commandBytes[i] = command.charCodeAt(i);
        }
        Net.sendUDP(esp32IP, esp32Port, commandBytes);
    }
    
    // Forward command
    function onForward() {
        sendUDPCommand("F");
    }
    
    // Left command
    function onLeft() {
        sendUDPCommand("L");
    }
    
    // Right command
    function onRight() {
        sendUDPCommand("R");
    }
    
    // Reverse command
    function onReverse() {
        sendUDPCommand("B");
    }
    
    // Stop command
    function onStop() {
        sendUDPCommand("S");
    }
    
  4. Assign the Functions to Movement Directions:

    • In the Custom Movement Panel configuration, assign the onForward(), onLeft(), onRight(), onReverse(), and onStop() functions to the respective movement directions.
  5. Test the Setup:

    • Connect your ESP32 to the same network as your ARC setup.
    • Run the ARC project and use the Movement Panel to control your RoboQuad.

Notes:

  • Ensure that the IP address (esp32IP) matches the IP address of your ESP32.
  • The port (esp32Port) should match the port you configured in the ESP32 code.
  • The Net.sendUDP() function sends the command as a byte array, which the ESP32 will interpret to execute the corresponding IR command.

Feel free to ask if you have any questions or need further assistance!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
PRO
Canada
#9  

Got it! Let's focus on setting up the custom Movement Panel in ARC with a single script for each direction. Here's how you can configure it:

Step-by-Step Guide to Use Net.sendUDP() in ARC with a Custom Movement Panel

  1. Create a Custom Movement Panel:

  2. Configure the Custom Movement Panel:

    • Open the configuration for the Custom Movement Panel.
    • You'll see options to add scripts for different movement directions (Forward, Left, Right, Reverse, Stop).
  3. Add JavaScript Code to Send UDP Commands:

    For each movement direction, you'll use the Net.sendUDP() function to send a command to the ESP32. Here's an example of how you can set up each direction:

    // Define the IP address and port of the ESP32
    var esp32IP = "192.168.1.100"; // Replace with your ESP32's IP address
    var esp32Port = 12345; // The port you set in the ESP32 code
    
    // Function to send a UDP command
    function sendUDPCommand(command) {
        var commandBytes = new Uint8Array(command.length);
        for (var i = 0; i < command.length; i++) {
            commandBytes[i] = command.charCodeAt(i);
        }
        Net.sendUDP(esp32IP, esp32Port, commandBytes);
    }
    
    // Forward command
    sendUDPCommand("F");
    
    // Left command
    sendUDPCommand("L");
    
    // Right command
    sendUDPCommand("R");
    
    // Reverse command
    sendUDPCommand("B");
    
    // Stop command
    sendUDPCommand("S");
    
  4. Assign the Functions to Movement Directions:

    • In the Custom Movement Panel configuration, assign the sendUDPCommand("F"), sendUDPCommand("L"), sendUDPCommand("R"), sendUDPCommand("B"), and sendUDPCommand("S") to the respective movement directions.
  5. Test the Setup:

    • Connect your ESP32 to the same network as your ARC setup.
    • Run the ARC project and use the Movement Panel to control your RoboQuad.

Notes:

  • Ensure that the IP address (esp32IP) matches the IP address of your ESP32.
  • The port (esp32Port) should match the port you configured in the ESP32 code.
  • The Net.sendUDP() function sends the command as a byte array, which the ESP32 will interpret to execute the corresponding IR command.

Feel free to ask if you have any questions or need further assistance!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.