DHT11 read temperature freezes arduino, when temperature is sent over UDP

I’m pulling my hair over my arduino code not working. So the problem is. When I read the temperature with dht.readTemperature() and output it to serial monitor, it works fine. When I send something over UDP, it works fine, but when I want to send read temperature over UDP, arduino crashes and starts working again, when I restart it.
It reads from temperature sensor only once and freezes after line UDP.endPacket(). I was googling, found that bug, applied the patch, tried many things, but nothing seems to be working.

Again, UDP and readTemperature() works fine on its own, but when I want to send temperature data over UDP, it freezes.
Thank you all for any provided help!

#include <DHT_U.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
#include "Timer.h"

byte MAC[] = { 0xDE, 0x12, 0x44, 0xAF, 0xBE, 0x56 };
IPAddress IP(192, 168, 2, 100);
unsigned int localPort = 5000;

char packetBuffer[UDP_TX_PACKET_MAX_SIZE];
String dataReq;
int packetSize;

EthernetUDP UDP;
Timer t;

#define DHTPIN 13
#define DHTTYPE DHT11 

void setup() {
	Ethernet.begin(MAC, IP);


	for (int i = 2; i < 14; ++i) {
		pinMode(i, OUTPUT);
	t.every(1000, takeTemperatureReading);


void loop() {
	packetSize = UDP.parsePacket();

	float temp = dht.readTemperature();

	UDP.beginPacket(UDP.remoteIP(), UDP.remotePort());
	UDP.endPacket(); //Packet has been sent
	if (packetSize > 0) {

		// Some stuff for recieving data
		UDP.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE); // Reading the data request, saving it in packetBuffer of UDP max size
		String dataReq(packetBuffer); // converting char array to string
		String type = dataReq.substring(0, 3);
		int pin = dataReq.substring(3, 5).toInt();
		int state = dataReq.substring(5, 6).toInt();
		digitalWrite(pin, state);

	memset(packetBuffer, 0, UDP_TX_PACKET_MAX_SIZE);

UDP.endPacket(); //Packet has been sent


Delay(100); //allow the serial buffer time to transmit

I am very suspicious of the code following that - I can't point my finger at the problem off the top of my head, but I get bad vibes from it.

It does not pass.
I've tried many times under different circumstances, but it does not work.
I tried with different Ethernet shields and Arduino Unos, but it does not work.

I don't understand why you are mixing reading an incoming packet and sending an outgoing packet. Complete one task before starting another.

I have no clue what "it does not work" means that the Arduino and/or other device are doing. All I know is that what they are doing is not what you want. What either is actually doing and what you expect are NOT at all clear. Stop using that phrase.