Welcome to Android Central! Speakerphone typically uses the secondary mic (at the top of the phone). If people can only hear you on speakerphone or when using a wired or Bluetooth headset, then your primary mic is either faulty or blocked. Inspect the mic opening closely to see if it's clogged by debris.