I'm using a PIC to take information from a sensor and transmit it via xbee to control a relay, as well as through a gateway to an online program. Forgive the noobie question here (I've searched and can't find it, maybe because I dont really know how to word this)...How would I go about changing the 'control' parameter for the relay. Say for instance I want a relay to turn on my a/c when it gets too hot, and I want to change what "too hot" is via the custom web program. It seems to me that it would require re-programming the PIC, however I've seen these types of devices before and that's not necessary, so I don't know what I'd need to do instead. TIA!!
There are basically four ways to get nonvolatile storage in a modern micro.
- Internal EEPROM: Many (not all) micros have EEPROM on-chip. It's good for perhaps 100,000 operations (sometimes more) before it wears out and takes some milliseconds to write (but is fast to read).
- Flash memory: (EEPROM emulation). Some micros allow you to write a portion of the flash during normal operation. This can be an alternative if EEPROM is not provided. FRAM based micros have nonvolatile memory that has fewer limitations than flash, but they're not very common.
External SEEPROM: Inexpensive and small serial EEPROMs are widely available. They typically use I2C, SPI or Microwire interface. A good alternative if the micro does not have EEPROM or you need more storage capacity.
Battery or supercapacitor backup: Simply store the information in RAM and put the micro in a very low power state when it is not active. Batteries (even rechargables) eventually wear out.
Edit: See the datasheet here:
You can find many code examples on line for using the data EEPROM.
PIC isn't my scene, but in general most modern microcontrollers have a small bit of non-volatile memory for the purpose of storage of data, and the contents of this storage can be modified at runtime. The trick is to write code such that it reads the control values from this storage, and can be directed to write new values to it if so directed.