How to recieve hex data JPEG camera from Arduino and show image in Processing

Hello. I need some help about how to write a Processing code.
I use JPEG camera module snapshot and sent data to output serial port and I want to write a Processing code to recieve this data to show image. Thank you.
I try to copy hex data output and past as a text file and change to image but when i receive from serial port it cannot.
Please help me I don’t know the way i can do.

1 Like
import processing.serial.*;
Serial myPort;
String inBuffer;
//String txtImg [];
void setup(){
  myPort = new Serial(this, "COM9", 115200);

void draw(){

void keyPressed()
  if ((key == 'b') | (key == 'B'))

void serialEvent(Serial p)
  inBuffer = p.readString();  // store serial port buffer in global var inBuffer
  //print(inBuffer);  // show the line of serial input
  String[] txt = split(inBuffer,' ');
  byte[] sampleBytes = new byte[txt.length];
 for ( int i=0;i<txt.length;i++){
 saveBytes("image1.jpg", sampleBytes);

It’s error cant convert Sring to Sring[]*****

1 Like


It seems that one symbol is wrong on this line:

String[] txt = split(inBuffer,’ ');

The first ' is not really a '. Not sure if just here or also in your code…

This is my simple code to save image but i look like to read only first line and tell error . What i should to do ?

Or i need to change my Arduino code. Pls help me.

Hello. I can do it already but my image has a bit problem. How is wrong ?

Hi warayutsitha2,

The first part of your picture is alright, so I’m thinking you have an over-run problem. The source is sending too much too fast, the receiver doesn’t read it all, and some is lost in the middle. You could test this idea by sending smaller pictures. You could try a lower baud rate, this would be a crude way of slowing things down.

If that helps then you could introduce flow control. Try making your Arduino send 200 bytes then pause until it receives a character. Make the processing program read all the bytes that arrive, add them on to a big string, and each 200 bytes received, send a char to the Arduino.