Arduino + Sim800 Development issues.

Good day. Recently I assembled small circuit based on Arduino and sim800. I have a goal to fetch sms one time per hour or some another period of time.

I downloaded Arduino IDE, used such sketch:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX
void setup() {
  Serial.begin(19200);  
  Serial.println("Goodnight moon!");
  mySerial.begin(19200); 
}

void loop() {
 if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

When I upload it to Arduino and go to Serial Monitor, I execute 3 commands: AT+cpin?, AT+CMGF=1, AT+CMGL=“ALL” - everything is ok - I get sms list. But now I want to do it programmatically.

I read that Processing language can help me for my case, so I downloaded Processing IDE, and wrote next code in it, Arduino code still same.

import processing.serial.*;
import cc.arduino.*;
Serial myPort;  
String val;

void setup() {
   size(200,200);
   myPort = new Serial(this, Serial.list()[n], 19200);
}

void draw()
{
  if ( myPort.available() > 0) 
  {  
    val =myPort.readString();   
    if (val != null) {
      println(val);
    }
  }
  
  if (mousePressed == true) 
  {                          
     myPort.write("ATI");
     println("ATI");   
  }  
}

As excepted result I want to see info about sim in log after mouse clicking, but unfortunately I get nothing(only “ATI”).
Can somebody help me fetch some data from Arduino via Processing? Thanks in advance.

I have a goal to fetch sms one time per hour or some another period of time.

As opposed to whenever one arrives? Well, OK.

As excepted result I want to see info about sim in log after mouse clicking, but unfortunately I get nothing(only “ATI”).

I wouldn’t expect that code to even compile. The array index variable, n, is not declared or initialized.

The draw() function is NOT the place to read serial data. Create a serialEvent() method with the proper signature, and read serial data there. The serialEvent() method can be set to be called when the expected end of packet marker arrives by using the bufferUntil() method of the Serial class.

Can somebody help me fetch some data from Arduino via Processing?

Not until we are certain that the code compiles, that the Arduino is connected to the serial port you are connecting to, and that the data is being read at the right time/place in the code.