The maximum write speed I can achieve is 2.4 KB/s. Is there a way to increase this?
Using LUA on a NodeMCU ESP8266 and the SPI module in User_Modules.h. #define BUILD_FATFS is also enabled in user_config.h.
I have a datalogger that is sampling 920SPS or ~1.1ms/Sample for 10 hours at a time. 1.1 ms should be lots of time to write two Bytes to a SD card or a buffer of xxx Bytes in between samples, however the max write speed I see is 498 ms to write 1200 Bytes or 7ms to write 3 Bytes. This is a long way from SD class 0 standard of 12.5MB/s. The logger ends up missing ~450 Samples when I dump 1200 B to the card.
local adc1 = nil
local t_tbl={}
local n=1
function adcReady(_,_,c)
_,_, adctbl[n], _ = adc1:read()
n=n+1
if n>400 then
t_tbl[1]=tmr.now()
file.open("/SD0/sddata.txt","a")
for k,v in ipairs(adctbl) do
file.write(v..",")
adctbl[k]=nil
end
file.close()
t_tbl[2]=tmr.now()
print(t_tbl[2] - t_tbl[1])
n=1
end
end
do
local adc = {
ADC1_ID = 0,
ADC1_ADDRESS = ads1115.ADDR_GND,
GAIN = ads1115.GAIN_4_096V,
SAMPLES = ads1115.DR_920SPS,
CHANNEL = ads1115.SINGLE_0,
MODE = ads1115.CONTINUOUS,
CONV_READY = ads1115.CONV_RDY_1,
}
i2c.setup(i2c0.id, i2c0.sda, i2c0.scl, i2c0.speed)
ads1115.reset()
adc1 = ads1115.ads1015(adc.ADC1_ID, adc.ADC1_ADDRESS)
adc1:setting(adc.GAIN, adc.SAMPLES, adc.CHANNEL, adc.MODE, adc.CONV_READY)
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 2, spi.HALFDUPLEX)
vol = file.mount("/SD0", 8) -- 2nd parameter is optional for non-standard SS/CS pin
file.open("/SD0/sddata.txt","w+")
file.close()
tmr.create():alarm(1000,tmr.ALARM_SINGLE,function()
gpio.mode(i2c0.conv_rdy,gpio.INT)
gpio.trig(i2c0.conv_rdy,'up', adcReady) --enable interrupt, active low rising edge==conv ready
end)
end