have a look at this topic Using Node-RED as a Local Fallback Server then modify it to collect data and analise.