I'm doing a project that consists of an RPi and an ESP8266. My RPi acts as the broker. I send data from my ESP to RPi through MQTT by subscribing. When I don't subscribe and run my code the data is lost until the point I subscribe. Is there a way to save the data values in the RPi as a file and when I subscribe, the previous data isn't lost as it is saved?
There needs to be a subscriber for the broker to not discard messages. If you want to keep all of them, you will need to have a subscriber that records messages and can play them back later or otherwise allow you to process the data.
How to save data values without subscribing through MQTT?