I thought one could explain the relationship based on the Seforno, who comments that the Torah here not only prohibits using unfair weights and measures, which would amount to out-and-out theft, but prohibits even possessing such weights, as ownership of these items prevents the hashra’as haShechina. In other words, our concern is not just justice – even in secular society, there has to be fair and standard weights and measures used in commerce or cheating would be rampant and business could not be transacted. However, in secular law, if you keep a faulty weight locked in your cabinet and no one knows about it and you never use it, nothing happens. In Torah, you cause the Shechina to not want to be near you.
The Torah gives us a reminder of what happens when there is no Shechina protecting us. Amalek attacked those members of Klal Yisrael who for whatever reason found themselves outside the camp and without the protection of the ananei hakavod. Had they been inside the camp, under the “iron dome” of the ananim and hashra'as haShechina, Amalek would have had no power.