Wondering why you initialize the HW twice...
Also looked at your coding and formatting stile in the module...
Last but not least, I'd take a look at the try counts and defer times: timeout times rcTimeoutTime and ccTimeoutTime (I'd like to see them anyway to be part of the C-onstants and not hard coded... ;/...). Make them match to hour intended measuring interval / prevent time overlapping. Worst case - or if you really want to get tight - you make an open interval constructed with comparing actual time and a defer with a timeout if needed to not measure more frequently that your intend maximum, but give time to complete a measurement in case it takes longer. Such a construct (self calling - by timeout -method/function as in the rc and cc defers in the module) you can use then also for firing right again a measurement after a failing one.
All depends though on your context where you want to use the sensor. I assume you did this work not just for the sensors' sake.
NB: Don't forget to remove the convenient setTimeout(onInit,... before you upload for saving (the code)
Thank you for the hints. I will keep to work on it in the next weeks, since it is part of my research project at university. I will try to follow your advice. HW initializing twice is an error, I just copied it twice. Thank you again for your efforts!
© Espruino, powered by microcosm.
Report a problem