Last time, we left the ESP32 ADC Hat by the phone, waiting for a call from Raspberry Pi Zero W.
Our RPI Zero W knows that finding the perfect mate will not be easy. He needs a plan and the help from an experienced matchmaker, but whom? After much thought, he found the answer, Node-Red to the rescue!
Well, Node-Red wasted no time figuring out a plan to create the perfect match. Node knows that a successful relationship needs good communications. So here is Red’s plan:
Zero was blown away. Red asked Zero to tell him the type of mate he is looking for.
Then, using an ip-node to extract the network IP address header, Node broadcasts a UDP message. Since ESP32’s phone is listening, ESP32 gets the message and responds with a letter of introduction written in JSON.
Zero is no fool. He finds ESP32’s personal address in the letter and writes her a private data gram telling her to turn on all her attributes.
The match is made! ESP32 and Zero can exchange information over a UDP channel to their heart’s content. The JSON curly brackets make nice short (200-Byte) messages that are easy to decode, so there are no long distance charges.
Will the relationship last? Yes, Node thought of everything. If the Internet goes down, Zero and ESP32 can still communicate because they are on the same local network. What if Zero looses ESP32’s address? A Ha, Node planned for that too, Node saves all flow data to a file and writes it to Zero’s SD memory.