I am using Arduino Uno and the image size is 12.7 kb. I want to read a jpeg image from computer and convert into bitmap in arduino. Later on it will be implemented using SD card.Is it possible to read a .jpeg image from computer to Arduino using serial communication? If yes, then how?

  • 3
    Which Arduino? How big is this image? Why do you want to do this? Please read How do I ask a good question?
    – Nick Gammon
    Mar 1, 2016 at 5:55
  • This is almost certainly a bad idea. On the more conventional Arduino boards, you could only accomplish it by streaming the image from the source, through whatever processing you are doing and to the permanent storage, as you just don't have the on-board RAM to hold more than a tiny part of it at any time. Depending on the processing you want to do you may need simultaneous access to more of the image than you can fit in memory at once, unless you can "rewind" the source or destination to multiply process it. Much better to do your conversion on the real computer! Mar 1, 2016 at 6:43
  • @ChrisStratton I am not going to implement this idea in the final project. All I am asking is for experimenting purpose. And besides the final project will be on Arduino Mega, one entire image can be loaded from SD card, processed and written back to SD card. I just want to know if right now I can do with serial communication or not.
    – explorer
    Mar 1, 2016 at 6:52

2 Answers 2


You can send anything you like through the serial port. It is just 8-bit raw data. The onus is on you, however, to implement a suitable high level protocol with which to transfer the data.

One important thing to bear in mind though: JPEG is a highly compressed complex image format. I am not aware that anyone has ever managed to squeeze JPEG decompression into a lowly Arduino. Instead you will need to use a decompressed image format such as BMP, or do the decompression on the computer before-hand and send the raw RGB image data over the serial instead.

  • As an addendum to this: I wrote a crude JPEG decompresser for chipKIT boards. It requires about 100KB of RAM to operate, so no chance of it ever working on an Arduino.
    – Majenko
    Jul 11, 2016 at 23:44

Of course you can, but as stated in the comments and in the other answer JPEG use a complex algorithm to compress the images, and most computers have a dedicated hardware to perform the cosens discrete transform. Anyway the answer to your question is yes, and it's not hard.

You just have to split the image into bytes, send them through the serial port and make Arduino read and save them into an array. To avoid errors create a protocol that can decode what are you doing.

For example: 0b1111000 for 3 times = Start sending 0b00011000 = new line and so on..

The first thing that come in my mind is to use the pySerial library, that can automate the process. Python is perfect for prototyping: open the image (maybe using the numpy library instead of using lists) and with a for loop send every byte over the serial port in according to the protocol you created.

On the Arduino just code the protocol to understand every bite and save the image in an array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.