free75degrees said:
nofossil said:
I could do it in software, but that ties up the CPU to do the required timing. I need the CPU for other cool stuff like serving the web page.
Interfacing the sensor directly with the arm DOES require taking over all of the CPU time for the duration of the query, but it is still pretty quick. Reading one sensor without using the ROM (which necessitates using one one sensor per IO) takes somewhere on the order of 150ms. If there are 6 sensors that you want to read every couple minutes then the impact is about 1 second every two minutes. With these numbers the impact to a web server will be very small. In the off chance that you happen to hit the server during a sensor reading, you would get at most a 1 second delay.
I read all 16 analog inputs every second. There are some control functions where I want pretty quick response, and I don't want to compromise on speed for at least those values. I also log all inputs and outputs every 30 seconds (to an SQL database), so I'd need to sample all inputs at least that often.
For people who aren't quite as obsessive, every minute would probably be fine. How quickly does outside or storage temperature change, after all?
One other issue - to make the timing work, the temp sensor task would have to disallow preemption by the operating system task switcher. If the task crashed, it would then take the operating system with it.