Dynamic APIs/Variables

Hi folks,

I've been learning the basics of Arduino and have set up multipoint sensors around my house and garden using an ESP8266 and sensor components (eg DHT22 to return temp/humidity) and 3d printed housings.

Given the cost of these components (very low), I've got more and more of them, so I'm starting to think about making my code more practical to avoid running back and forward with the devices each time I want to update them, improve code, add features etc.

Question 1) I haven't heard anyone talking about remote flashing of arduino code (ie via wifi), so assume it needs to be com connected?

This being so, I'm thinking about abstracting some of the more common elements I update to my home server and loading these as part of the loop.

ie where I currently have

#define API "0B23323345gfegfg" //api string
#define SensorName "Greenhouse"

Question 2) I'm thinking I could load these off a central database and this'd allow me to add extra devices /update APIs etc.

Would this work?

Appreciate any thoughts on flaws on this/better ways to approach it?

I think I have heard about updating code over wifi. I assume you'd need to update the boot loader but I've never done it. Maybe google a bit more.

As to your second question, I'd give each device a unique ID and put it in EEPROM and have it query the database to get its other parameters via an API.

To get the original ID, a new device could call the "I'm new" API to be provided with one.

Ah, super - didn't even think of looking for that.

Think I've moreorless got my ESP8266 updating OTA now - only problem is I think I'm using delay() in between my temp sensor updating, which means any OTA updates won't be received (as ESP effectively freezes the board).

Stupid question, but what's the alternative to delay() for delaying!?? (I want to just update the temperature every 30 mins)