# File Transfer (From PC To Raspberry Pi)

**URL:** <https://forums.digi.com/t/file-transfer-from-pc-to-raspberry-pi/21689>\
**Category:** Python\
**Tags:** raspberry-pi, python, xbee\
**Created:** [August 24, 2020, 8:48am UTC](https://forums.digi.com/t/file-transfer-from-pc-to-raspberry-pi/21689 "2020-08-24T08:48:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![highpriv](https://avatars.discourse-cdn.com/v4/letter/h/67e7ee/32.png) [@highpriv](https://forums.digi.com/u/highpriv)\
**Post date:** [August 24, 2020, 8:48am UTC](https://forums.digi.com/t/file-transfer-from-pc-to-raspberry-pi/21689/1 "2020-08-24T08:48:55Z")

</div>

Hey,

I’ve two xBee Pro S2C module. I’m trying to send a image from Windows PC to Raspberry Pi with xBee modules. I configured my xBees for API mode and i can receive/send AT text messages with Python codes.

I want to send a image from my PC to Raspberry Pi Model 3 B+

I also checked this subject: [http://cms.digi.com/support/forum/70518/transfer-image-between-xbee-modules-connected-raspberry-each](http://cms.digi.com/support/forum/70518/transfer-image-between-xbee-modules-connected-raspberry-each)

I made some changes and tried codes below.

PC side(sender)  
###########################  
ser = serial.Serial(‘COM6’, 9600,timeout=.5)  
fc= ‘xbee.jpg’  
File = open(fc,‘r’)  
#while True:  
line = ser.readline()  
a= File.read()  
print(str(a))  
ser.write(str(a))  
#############################

Raspberry Pi side (receiver)  
#############################

ser = serial.Serial(‘/dev/ttyUSB0’, 9600,timeout=.5)

while True:  
incoming = ser.readline().strip()

file = open (‘images.png’,‘wb’)

print (incoming)  
file.write(incoming)  
file.close()  
content= file.read()

#################################

Then i got a error:

UnicodeDecodeError: ‘charmap’ codec can’t decode byte 0x81 in position 240: character maps to

Also an idea came to my mind. I made a script converts an image to base64 code and saves as a .txt file. I changed “images.png” as “test.txt”. There is no error occured but also there is no .txt file created on my raspberry pi.

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [August 24, 2020, 9:06am UTC](https://forums.digi.com/t/file-transfer-from-pc-to-raspberry-pi/21689/2 "2020-08-24T09:06:14Z")

</div>

This is not an issue for the XBee but for your Python or Arduino group.
