# Data loss while transfer data within wifi connecting

**URL:** <https://community.particle.io/t/data-loss-while-transfer-data-within-wifi-connecting/17380>\
**Category:** Troubleshooting\
**Created:** [November 12, 2015, 8:30am UTC](https://community.particle.io/t/data-loss-while-transfer-data-within-wifi-connecting/17380 "2015-11-12T08:30:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yoonsik](https://avatars.discourse-cdn.com/v4/letter/y/8baadc/32.png) [@yoonsik](https://community.particle.io/u/yoonsik)\
**Post date:** [November 12, 2015, 8:30am UTC](https://community.particle.io/t/data-loss-while-transfer-data-within-wifi-connecting/17380/1 "2015-11-12T08:30:22Z")

</div>

I’m using photon device and imu shield to receive accel, gyro data.  
And, it is connected wifi communication to transfer above data to PC.  
When i checked the time from accumulation data to sending data, it is about 270 ms and 4616 byte.  
If the device is close to AP router, it’s fine.  
But i moved the device little bit far from AP router whthin connected wifi, it is loosing data. ( I know that wifi signal is weak when it is far from router, but it is still maintening wifi connection.)  
Sometimes, it is loosing data when it is close to router.  
Is there any method or information not to lose data when transfer data within connected wifi?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [November 12, 2015, 11:21am UTC](https://community.particle.io/t/data-loss-while-transfer-data-within-wifi-connecting/17380/2 "2015-11-12T11:21:56Z")

</div>

What kind of transfer protocol are you using?

UDP for example is focused on speed but allows for packet loss, TCP on the other hand introduces some overhead which reduces speed but increases reliability to get all the packets and keeping them in order.

If you don’t need permanent cloud support, you could use one of the non-`AUTOMATIC` `SYSTEM_MODE`s and/or `SYSTEM_THREAD(ENABLED)` for decoupling of cloud and application threads.

BTW, how do you confirm that connection does not cut out for short periods?

---

<div class="post-metadata">

**Author:** ![yoonsik](https://avatars.discourse-cdn.com/v4/letter/y/8baadc/32.png) [@yoonsik](https://community.particle.io/u/yoonsik)\
**Post date:** [November 12, 2015, 11:30pm UTC](https://community.particle.io/t/data-loss-while-transfer-data-within-wifi-connecting/17380/3 "2015-11-12T23:30:17Z")

</div>

I’m using TCP protocol to transfer data.  
And, i don’t use permanet cloud support by using SYSTEM\_MODE(SEMI\_AUTOMATIC).

To confirm that connection does not cut out for short periods, i use server socket pc program.  
Open the server program, and when the client connection is connected, it transfer data to PC server program about 270ms.

SYSTEM\_THREAD(ENABLED) means it makes photon use thread?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [November 13, 2015, 12:54am UTC](https://community.particle.io/t/data-loss-while-transfer-data-within-wifi-connecting/17380/4 "2015-11-13T00:54:21Z")

</div>

Have a read about [`SYSTEM_THREAD()`](https://docs.particle.io/reference/firmware/photon/#system-thread)

But what do you exactly mean with loosing data?  
How much data?  
Whole data sets or only some bytes of a set?  
Do you get currupted data?  
Are you actually loosing data or could it be that data acquisition just cuts out and there is not data (instead of existing data lost)?

---

<div class="post-metadata">

**Author:** ![yoonsik](https://avatars.discourse-cdn.com/v4/letter/y/8baadc/32.png) [@yoonsik](https://community.particle.io/u/yoonsik)\
**Post date:** [November 13, 2015, 1:52am UTC](https://community.particle.io/t/data-loss-while-transfer-data-within-wifi-connecting/17380/5 "2015-11-13T01:52:43Z")

</div>

transfer whole data sets like that.  
client.write(reinterpret\_cast\<byte\*\>(&Senddata), sizeof(Senddata));

byte is about 4616.  
If it is far from router, (it transfer data), some of data value are zero or -1.6E + 38.  
While it is clost to router, sometimes it occur data shift.  
I think photon sending data, but server pc program couldn’t receive correct data. I’ll check more.  
Also, i doubt AP router ability.

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [November 13, 2015, 3:02am UTC](https://community.particle.io/t/data-loss-while-transfer-data-within-wifi-connecting/17380/6 "2015-11-13T03:02:33Z")

</div>

You are asking the underlying software to break up your large array into packets for you since the size of your array exceeds a single packet.

Have you tried sending your data in say 1024 byte chunks instead of all at once?
