Found the working fix for this:
First, create directory to keep the driver source files in a common place if you don’t have it already.
mkdir drivers && cd drivers
I used latest Raspbian Jessie released on 5th of July 2017. For me it required only to install kernel header files as shown below.
sudo apt-get install raspberrypi-kernel-headers dkms
Get the driver source files hosted at github repo https://github.com/Mange/rtl8192eu-linux-driver. The driver source seems like for D-Link DWA-131, which is having same chipset, rtl8192eu, as my TP-Link TL-WN823N v2.
We have to clone realtek-4.4.x branch, which is for Linux kernel 4.4. However it worked for my Raspbian having kernel version 4.9.35.
git clone --branch realtek-4.4.x https://github.com/Mange/rtl8192eu-linux-driver.git
By default the building process will target desktop systems. We have to change that, to build the driver for Raspberry Pi.
You will see Makefile within driver source directory you just cloned above. Open it in a text editor. You can find following line:
CONFIG_PLATFORM_I386_PC = y
Change it to:
CONFIG_PLATFORM_I386_PC = n
Then find following line. If your Makefile does not contain the line below, then just copy and paste in directly below the line above in your file ensuring to remember to change the flag from n to y
CONFIG_PLATFORM_ARM_RPI = n
Change it to:
CONFIG_PLATFORM_ARM_RPI = y
Now we can build and install the driver.
sudo dkms add .
sudo dkms install rtl8192eu/1.0
If everything went well, then WiFi adapter should get detected once you restart networking service or reboot Pi.
This solution is originally from: