Mqtt with ESP8266 not working

I try to connect an ESP8266 to home assistant via mqtt.
The program, written in Arduino code, does connect to the broker as seen in the logfile.
An extract of the logfile:

1586276776: New connection from 192.168.1.18 on port 1883.
1586276776: New client connected from 192.168.1.18 as esp8266-ec:fa:bc:13:7:92 (p2, c1, k15).
1586276808: New connection from 192.168.1.30 on port 1883.
1586276808: New client connected from 192.168.1.30 as auto-535EEB47-6318-8354-2D9E-DD5E7D8E943C (p2, c1, k60).

When I try to send a message with the mqqt-switch a made in the yaml fiel or via the mqtt option in home assistant nothing is send. I verified it with wireshark.
I run Home assistant on a Pi2 model 2 1Gb, but I have the intention to run it on a Pi4 with 4Gb.
Does anyone has suggestions to overcome my problem?
Thanks for the help