One other thing to note.
If anyone tries to compile this code and gets and gets a compiler error message something like “‘dynamicjsonbuffer’ was not declared in this scope” then you need to downgrade your ArduinoJson library from 6.x.x to 5.13.5
Pete.