ESP32 C3 - Strong wifi Tx signal cuases chip to crash "could not send data: 12""
Posted: Sat Oct 19, 2024 8:03 am
Hi :3
I'm really sorry if it was discussed already, but I wasn't able to find an answer. So...
My use case - custom DIY wireless tracker. Tracker should be inside of the 3D printed case (white natural PLA without any additives) with battery. Tracker can be covered or obstructed by human body.
Short version
Problem - At max Tx power level, if I get anything close to antenna (or if you put it inside tight plastic case, normal white PLA), chip will throw "endPacket(): could not send data: 12" error. Chip is not crashing fully, since the same millisecond you move object away it connects back and sends data.
Current solution - decrease Tx power by 9 dB. It helps to keep Wi-Fi alive even if it's in case or anything nearby.
My guess - signal reflects from antenna back and oversaturates Tx and/or Rx and chip goes a bit crazy.
Question - I've tried to use chip antenna and just 30 minutes ago external antenna (with small connector which is for sure matched well). Is there any possible way to use max Tx power? Can I set Rx gain lower or maybe attenuate it? My receiving power on ESP side is huge, router is close, so I can sacrifice Rx gain to have max Tx power.
Long version
I have a custom PCB with charger chip, buck, IMU BNO085, ESP32-C3FH4, and chip antenna. Board was made by a friend of mine and optimized/rechecked by me. Problem looks like this: if you put board inside of the 3D printed case it sends via serial port "endPacket(): could not send data: 12" error until you remove it from the case. Sometimes it does give an error, sometimes it's not. You can move your finger around case or metal object and sometimes it helps to get board back, sometimes it's not.
I've tried a lot of things and was able to pinpoint that when you affect area near antenna and crystal it causes that error. Squeezing, bending, covering, holding with bare hands lower part under the chip (with power and IMU) gives nothing. I also was reading Reddit and this forum and people were talking maybe it's enable pin, or for C3 micro or something there was not enough solder on caps - tried to add caps on that pin and more solder on 3.3V caps - nothing.
At the end I got to conclusion it's either bad crystal layout and/or RF matching and started to work on layout optimizations.
I've picked proper pi filter values using Smith chart and matching calculators targeting 35 ohm chip out and 50 ohm antenna port.
I've checked 50 ohm line width using PCB properties I have.
I added ton of ground and vias, made sure that ground plane on the second layer is almost fully one huge polygon for the entire board.
Added Z shape Pi (this version will come next week, but something tells me it will be the same)
Crystal was chosen correct (actually, Sora made an amazing work. I was just rechecking everything), caps values are calculated using recommended formula. Caps are super tight, a lot of vias around it, symmetric, short traces. Ground under crystal and chip is the same and there are vias under the chip to make sure that path is as tight as possible.
3.3V caps are as datasheet says and they are also super close to chip and with vias everywhere. All the other parts of power distribution are close to each other with a lot of ground and as small back loops as I was able to make.
And all of that didn't help. I've got a new version today and it was even worse because chip antenna is not 50 ohm in any possible way as I figured out.
With all of that I decided to remove RF caps and L one by one, cover each component or short it and at the end to solder external antenna (to a completely new PCB, without any experiments on it) and what happened - if you put metal object close to antenna itself - that error appears.
So this time I was able to isolate problem maybe fully - antenna is quite far away and metal is for sure affecting antenna only. My current guess - at some distance S11 gets so bad or radiated power just reflects back into the antenna and signal goes to Tx and/or Rx and hangs chip. If I decrease Tx power by 9 dB (esp_wifi_set_max_tx_power(44)) it works just fine. But I do not want to lose 9 dB to be honest :/
Has anyone experienced similar things before and maybe can tell me what is the real problem? Maybe it's not Tx or Rx problem, but I have such a small device that signal from ground plane somehow affects components through it? Can I decrease Rx gain maybe? What kind of options do I have? I need tracker to be small and I need Wi-Fi for it to work. I also need Tx power because tracker can be obstructed or covered. Or chip actually does not like when signal reflects back and I have no choice?
I would be happy to any help, was trying to find people for quite a while to talk and today decided to write here. I've added pictures of PCB and second ground layer just in case as well as pic of the position when chip crashes (tweezers close to antenna at some distance ~10mm). Sorry for bad antenna soldering, i was lazy at this pint >__<
P.S. Maybe there is a better chip to use for this application? If it has the same power consumption as ESP32-C3 and can work at max power I can redesign the board. Even if it's more expensive or anything. Unless it fits same footprint and gives same battery life I'm fine.
Thank you for reading and have a great day :3
I'm really sorry if it was discussed already, but I wasn't able to find an answer. So...
My use case - custom DIY wireless tracker. Tracker should be inside of the 3D printed case (white natural PLA without any additives) with battery. Tracker can be covered or obstructed by human body.
Short version
Problem - At max Tx power level, if I get anything close to antenna (or if you put it inside tight plastic case, normal white PLA), chip will throw "endPacket(): could not send data: 12" error. Chip is not crashing fully, since the same millisecond you move object away it connects back and sends data.
Current solution - decrease Tx power by 9 dB. It helps to keep Wi-Fi alive even if it's in case or anything nearby.
My guess - signal reflects from antenna back and oversaturates Tx and/or Rx and chip goes a bit crazy.
Question - I've tried to use chip antenna and just 30 minutes ago external antenna (with small connector which is for sure matched well). Is there any possible way to use max Tx power? Can I set Rx gain lower or maybe attenuate it? My receiving power on ESP side is huge, router is close, so I can sacrifice Rx gain to have max Tx power.
Long version
I have a custom PCB with charger chip, buck, IMU BNO085, ESP32-C3FH4, and chip antenna. Board was made by a friend of mine and optimized/rechecked by me. Problem looks like this: if you put board inside of the 3D printed case it sends via serial port "endPacket(): could not send data: 12" error until you remove it from the case. Sometimes it does give an error, sometimes it's not. You can move your finger around case or metal object and sometimes it helps to get board back, sometimes it's not.
I've tried a lot of things and was able to pinpoint that when you affect area near antenna and crystal it causes that error. Squeezing, bending, covering, holding with bare hands lower part under the chip (with power and IMU) gives nothing. I also was reading Reddit and this forum and people were talking maybe it's enable pin, or for C3 micro or something there was not enough solder on caps - tried to add caps on that pin and more solder on 3.3V caps - nothing.
At the end I got to conclusion it's either bad crystal layout and/or RF matching and started to work on layout optimizations.
I've picked proper pi filter values using Smith chart and matching calculators targeting 35 ohm chip out and 50 ohm antenna port.
I've checked 50 ohm line width using PCB properties I have.
I added ton of ground and vias, made sure that ground plane on the second layer is almost fully one huge polygon for the entire board.
Added Z shape Pi (this version will come next week, but something tells me it will be the same)
Crystal was chosen correct (actually, Sora made an amazing work. I was just rechecking everything), caps values are calculated using recommended formula. Caps are super tight, a lot of vias around it, symmetric, short traces. Ground under crystal and chip is the same and there are vias under the chip to make sure that path is as tight as possible.
3.3V caps are as datasheet says and they are also super close to chip and with vias everywhere. All the other parts of power distribution are close to each other with a lot of ground and as small back loops as I was able to make.
And all of that didn't help. I've got a new version today and it was even worse because chip antenna is not 50 ohm in any possible way as I figured out.
With all of that I decided to remove RF caps and L one by one, cover each component or short it and at the end to solder external antenna (to a completely new PCB, without any experiments on it) and what happened - if you put metal object close to antenna itself - that error appears.
So this time I was able to isolate problem maybe fully - antenna is quite far away and metal is for sure affecting antenna only. My current guess - at some distance S11 gets so bad or radiated power just reflects back into the antenna and signal goes to Tx and/or Rx and hangs chip. If I decrease Tx power by 9 dB (esp_wifi_set_max_tx_power(44)) it works just fine. But I do not want to lose 9 dB to be honest :/
Has anyone experienced similar things before and maybe can tell me what is the real problem? Maybe it's not Tx or Rx problem, but I have such a small device that signal from ground plane somehow affects components through it? Can I decrease Rx gain maybe? What kind of options do I have? I need tracker to be small and I need Wi-Fi for it to work. I also need Tx power because tracker can be obstructed or covered. Or chip actually does not like when signal reflects back and I have no choice?
I would be happy to any help, was trying to find people for quite a while to talk and today decided to write here. I've added pictures of PCB and second ground layer just in case as well as pic of the position when chip crashes (tweezers close to antenna at some distance ~10mm). Sorry for bad antenna soldering, i was lazy at this pint >__<
P.S. Maybe there is a better chip to use for this application? If it has the same power consumption as ESP32-C3 and can work at max power I can redesign the board. Even if it's more expensive or anything. Unless it fits same footprint and gives same battery life I'm fine.
Thank you for reading and have a great day :3