How to execute serial communication on Arduino Giga r1 wifi

Hi all! I am a new Arduino user who is trying to create a complex problem on a short deadline. I've bought some Atlas Scientific Sensors and copied their Arduino Mega code, but want to use it on the Arduino Giga r1 wifi board. I'm wondering why this code works on the Mega but not the giga and if anyone has any suggestions.



String inputstring = "";                              //a string to hold incoming data from the PC
String sensorstring = "";                             //a string to hold the data from the Atlas Scientific product
boolean input_string_complete = false;                //have we received all the data from the PC
boolean sensor_string_complete = false;               //have we received all the data from the Atlas Scientific product
float DO;                                             //used to hold a floating point number that is the DO


void setup() {                                        //set up the hardware
  Serial.begin(9600);                                 //set baud rate for the hardware serial port_0 to 9600
  Serial4.begin(9600);                                //set baud rate for software serial port_3 to 9600
//  inputstring.reserve(10);                            //set aside some bytes for receiving data from the PC
 // sensorstring.reserve(30);                           //set aside some bytes for receiving data from Atlas Scientific product
}

void serialEvent() {                                  //if the hardware serial port_0 receives a char
  inputstring = Serial.readStringUntil(13);           //read the string until we see a <CR>
  input_string_complete = true;                       //set the flag used to tell if we have received a completed string from the PC
}


void serialEvent3() {                                 //if the hardware serial port_3 receives a char
  sensorstring = Serial4.readStringUntil(13);         //read the string until we see a <CR>
  sensor_string_complete = true;                      //set the flag used to tell if we have received a completed string from the PC
}


void loop() {                                         //here we go...


  if (input_string_complete == true) {                //if a string from the PC has been received in its entirety
    Serial4.print(inputstring);                       //send that string to the Atlas Scientific product
    Serial4.print('\r');                              //add a <CR> to the end of the string
    inputstring = "";                                 //clear the string
    input_string_complete = false;                    //reset the flag used to tell if we have received a completed string from the PC
  }


  if (sensor_string_complete == true) {               //if a string from the Atlas Scientific product has been received in its entirety
    Serial.println(sensorstring);                     //send that string to the PC's serial monitor
   /*                                                 //uncomment this section to see how to convert the D.O. reading from a string to a float 
    if (isdigit(sensorstring[0])) {                   //if the first character in the string is a digit
      DO = sensorstring.toFloat();                    //convert the string to a floating point number so it can be evaluated by the Arduino
      if (DO >= 6.0) {                                //if the DO is greater than or equal to 6.0
        Serial.println("high");                       //print "high" this is demonstrating that the Arduino is evaluating the DO as a number and not as a string
      }
      if (DO <= 5.99) {                               //if the DO is less than or equal to 5.99
        Serial.println("low");                        //print "low" this is demonstrating that the Arduino is evaluating the DO as a number and not as a string
      }
    }
  */
  }
  sensorstring = "";                                  //clear the string:
  sensor_string_complete = false;                     //reset the flag used to tell if we have received a completed string from the Atlas Scientific product
}

That's not a good combination.
The aim for forum is helping members learn and grow in programming. Fixing code, schematics etc and produce ready to use things is not happening.

Do they have datasheets?........

It doesn't look like the entire code. Not one single library used. That can't work on any controller.

Thank you for your reply! They have data sheets but I'm not sure what to do with them, they really only talk about the hardware of the device and I know I've wired it correctly because the code was working on the MEGA.

Okey.
Datasheets often contain application notes that helpers could use.
Of course You can wait until a Giga helper steps in.
What about the last line in my post?

I'm working on finding a library now! I'm also watching videos on serial communication.

Look for how to start up a Wifi communication. Then look for the commands being used.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.