When the spark is not connected to the internet/cloud (because of not in range with a wifi router), is there a way to have the measurements stored locally in flash and have these transferred later? Eventually send as a file to an ftp server for example?
You should really think about using SD library.
I can agree on that for measurements. But for example if I want to store limits I think it is best to store these in flash, so that local preprocessing can occur before sending data over the interent (only relevant data should be send). For example thresholds and alarm delay times or the parameters for first or second order filtering.
There is space in the on-board FLASH memory and there are low-level routines to read, write, and erase it. Sometimes weird things have happened while using this due the same SPI bus being use for the TI CC3000 WiFi chip and the external flash. Note this SPI bus is separate from the user SPI bus that you can use. The Spark team is working on a better interface to this flash memory, but you can use the low-level interface until then.
Another user suggested that surrounding the low-level calls with delay(20) improves the reliability since the TI WiFi chip gets serviced during a delay. Be careful writing and erasing this memory because you can do bad things to your core!
delay(20); sFLASH_EraseSector(FLASHADDR); delay(20); ... delay(20); sFLASH_WriteBuffer(byteBuffer, FLASHADDR, 256); delay(20); ... delay(20); sFLASH_ReadBuffer(byteBuffer, FLASHADDR, 256); delay(20);
Thank you for the response. So if I understand correctly, there is no way to be sure that the data written to the external memory is correctly written or read? Since you mention that sometimes wird things happen. Do you have any idea on timing when Spark will release their functions/libraries to access this memory area? I can imagine that there can be a lot of issues if this memory uses the same SPI channel was the Wifi Module.
Using the delays above, I was able to write a sector over and over, comparing the written data to the read data with no errors. Without the delays, the core will sometimes panic and restart at random times.
The Spark team is working on their feature and I saw some source code changes go by, but I don’t think it is done yet.
The code with the delays was very reliable for me.
Any news on the status of the access to the EPROM? There is a EEPROM.write and read available now, but it is only possible to access 100 bytes (since this is internal memory). Is there any function available yet for accessing the external eprom from range 0x80001 to 0x200000?
you can find the functions on https://github.com/spark/core-common-lib/blob/master/SPARK_Firmware_Driver/src/sst25vf_spi.c .
I’ve recently finished this library, which might help. It offers more storage than the built-in EEPROM class.
It has a circular buffer, so you can push data in one end, and when the wifi connection comes back, pull it out from the other. The buffer manages the flash memory for you so you don’t have to worry about when to erase etc. And because it’s a circular buffer, all pages have equal wear, improving endurance of the flash.
Hi, Do you know where they went in the Photon port?
The photon doesn’t have any external flash. The flash storage available is 2KBytes via the EEPROM library.