Getting variables from a mysql database and storing in the eeprom

I have (after plenty of help from the likes of ScruffR and others) managed to update a mysql database with a string from my photon and was wondering if it is possible to reverse the procedure and save the data from the database to the photons eeprom at given intervals. Would I somehow have to create a php page which would request the data from the database which passed it on to the subscribing photon or would I create a function on the photon which request the information from the database. I’m just not sure of the best way to go about it.

You would send the data via a Particle.function() POST request.

@benjiiiiuk did this solve your question?

not really I was still looking in to it. so would the photon send the request from the sql database then store it in the eeprom ?

That doesn't make sense. The Photon doesn't host the DB so it can't send a request from it.

You said

and

Both is possibe, but what do you want?
For option 1 you'd need a Particle.function() that you call from your PHP to transmit the data from your DB to the device.
For option 2 you'd use a webhook where the device sends an event to request the data from the DB to which the DB responds and the device subscribes to the respective hook-response event.

That helps a lot thanks I can now look at each method and see which best suits. Thanks for your help

1 Like