EE2012
Posts: 7
Joined: Thu Oct 25, 2018 10:59 pm

Transfer a Picture from Pi to Arduino via UART

Thu Oct 25, 2018 11:10 pm

I am trying to take pictures with the Raspberry Pi camera and compress them to be sent to my Arduino Uno via UART. I have been working on a program to do this automatically through a Python program. Any suggestion or help offered would be greatly appreciated.

User avatar
topguy
Posts: 6288
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Transfer a Picture from Pi to Arduino via UART

Fri Oct 26, 2018 1:56 pm

What will you do with the picture after it is sent to the Uno ?
Will you need to keep full resolution and colors of the picture ?
The less resolution and colors you need to send, the faster it is to transfer.

To transfer anything securely and controllable you need to choose a protocol. I dont know the capabilities of the Uno but I know a bit about sending data over serialport (UART).
- You could try to use one of the established protocol from back in the BBS days: xmodem, ymodem and zmodem.
Could be very fast to implement if you find existing Arduino code for this: https://github.com/ecm-bitflipper/Arduino_ZModem

- Or you could create something simple from scratch yourself.

EE2012
Posts: 7
Joined: Thu Oct 25, 2018 10:59 pm

Re: Transfer a Picture from Pi to Arduino via UART

Sun Oct 28, 2018 10:27 pm

The picture will then be package and transmitted wirelessly to a computer. I need to keep as much resolution and picture as possible. The transfer period is something I am worried about. I do not want it to take to long. Also I plan on using the serial port for UART. I will review the xmodem and github code. I appreciate any help.

User avatar
topguy
Posts: 6288
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Transfer a Picture from Pi to Arduino via UART

Mon Oct 29, 2018 9:41 am

The picture will then be package and transmitted wirelessly to a computer.
The Arduino will do this ? Why not the Pi ?
Also I plan on using the serial port for UART
An UART ( Universal asynchronous receiver-transmitter ) is the chip that controls a serialport so that senctence makes no sense to me.

EE2012
Posts: 7
Joined: Thu Oct 25, 2018 10:59 pm

Re: Transfer a Picture from Pi to Arduino via UART

Sat Nov 10, 2018 7:10 pm

Sorry for the delay in a reply. I appreciate the help and you were right. I mistyped about the serial port and UART. I am trying to write a python program where a picture is taken, then is transferred via UART to the Arduino. So far I have used numpy and PIL to take the image and make it into an array of doubles. The array is RGB coding that goes through each pixel of the picture and assigns a value from 0-255. Obviously the number corresponds to a color from Black = 0 to White = 255. The output of the array look like the figure below:

[[[ 100 200 132 255]
[ 164 123 245 240]
[ 54 214 215 214]
[ 234 123 124 125]
[ 252 256 257 259]
[ 89 90 93 95 ]
[ 76 78 78 79]
[ 10 0 0 2 ]]

I am now trying to package this array into where I can send it to the arduino via UART. So far I have had a problem doing that with my code.

User avatar
B.Goode
Posts: 9607
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Transfer a Picture from Pi to Arduino via UART

Sat Nov 10, 2018 7:21 pm

The picture will then be package and transmitted wirelessly to a computer.

I'll ask again, because it didn't get a reply last time..

Why not cut out the 'man in the middle' and simply transmit the file wirelessly from the RPi to the destination computer?

Involving an Arduino via a serial port connection seems to add complexity - what value does it add to the process?

(Of course you are welcome to implement this any way you choose, but understanding the reason for your choice might help focus the response.)

EE2012
Posts: 7
Joined: Thu Oct 25, 2018 10:59 pm

Re: Transfer a Picture from Pi to Arduino via UART

Sat Nov 10, 2018 7:30 pm

I am not going straight to a computer because I am doing imaging in the air.

User avatar
B.Goode
Posts: 9607
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Transfer a Picture from Pi to Arduino via UART

Sat Nov 10, 2018 7:36 pm

EE2012 wrote:
Sat Nov 10, 2018 7:30 pm
I am not going straight to a computer because I am doing imaging in the air.
So the RPi and its camera are airborne?

Where is the Arduino? If you are making a serial port connection is it also part of the same payload?

EE2012
Posts: 7
Joined: Thu Oct 25, 2018 10:59 pm

Re: Transfer a Picture from Pi to Arduino via UART

Sat Nov 10, 2018 7:41 pm

The arduino and the RPI will be apart of the same payload in the air.

User avatar
B.Goode
Posts: 9607
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Transfer a Picture from Pi to Arduino via UART

Sat Nov 10, 2018 7:45 pm

Why do you need the added weight and code complexity of the Arduino.

Why not ship the file wirelessly from the RPi to the 'groundstation'?

EE2012
Posts: 7
Joined: Thu Oct 25, 2018 10:59 pm

Re: Transfer a Picture from Pi to Arduino via UART

Sat Nov 10, 2018 8:42 pm

The arduino controls other applications of the payload. I have to have both controls believe I have tried to simplify the system as much as I could. If you could help me with the problem I am asking about it would be a great help. Thanks

EE2012
Posts: 7
Joined: Thu Oct 25, 2018 10:59 pm

Re: Transfer a Picture from Pi to Arduino via UART

Sat Nov 10, 2018 8:45 pm

Also, to answer your question the arduino is in control of the transmitter. The high altitude makes it only possible to go through the arduino that controls the transmitter as I found out from previous test. The high altitude eliminates the possibly of wifi or bt capabilities to transfer.

User avatar
B.Goode
Posts: 9607
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Transfer a Picture from Pi to Arduino via UART

Sat Nov 10, 2018 9:32 pm

If you could help me with the problem I am asking about it would be a great help.


Personally, I find it difficult to offer help without first understanding the problem to be solved. If that approach does not suit you I will withdraw and leave you to accept help from someone else.

User avatar
topguy
Posts: 6288
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Transfer a Picture from Pi to Arduino via UART

Sun Nov 11, 2018 2:09 pm

EE2012 wrote:
Sat Nov 10, 2018 8:45 pm
Also, to answer your question the arduino is in control of the transmitter. The high altitude makes it only possible to go through the arduino that controls the transmitter as I found out from previous test. The high altitude eliminates the possibly of wifi or bt capabilities to transfer.
What is the bandwidth of the transmitter to the ground ? I know that is not part of what you are asking for, but I'm assuming that also will limit the amount of data that will be useful to send to the Arduino.

So far you have not been very specific about what exactly you need help with..
- Have you connected the Arduino to the Pi ?
- Have you verified that you can send any data over the serialport to the arduino and reliable receive it ?

ragishtin
Posts: 12
Joined: Fri Jan 24, 2020 7:30 am

Re: Transfer a Picture from Pi to Arduino via UART

Sat Mar 21, 2020 9:16 pm

I'm having a similar problem ..

I'm working on a project where I need to transmit a picture from one Pi to another using serial communication .. it is not possible to send it via the network .. it is required in the project to send the picture serially ..

Could anyone help me ?

Regards,
Ragy Samy ..

User avatar
topguy
Posts: 6288
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Transfer a Picture from Pi to Arduino via UART

Mon Mar 23, 2020 2:31 pm

You could create a network connection over serial between the two Pis.
https://www.tldp.org/HOWTO/PPP-HOWTO/direct.html

Then you can use FTP/SCP or any other networking protocol to data/files from one Pi to the other.

Return to “Camera board”