Calculate temperature based on resistance from thermistor with lookup chart
thermister_ert-j0eg1.h@5:88bf5a42812e, 2016-03-30 (annotated)
- Committer:
- joeata2wh
- Date:
- Wed Mar 30 13:32:40 2016 +0000
- Revision:
- 5:88bf5a42812e
- Parent:
- 0:39f659087759
- Child:
- 6:3c9cb2bd08c6
Fixed odd bug when readings where for very high resistance. Also renamed some constants to provide less potential for conflict with other modules.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joeata2wh | 0:39f659087759 | 1 | #ifndef thermister_ert_j0eg1_h |
joeata2wh | 0:39f659087759 | 2 | #define thermister_ert_j0eg1_h |
joeata2wh | 5:88bf5a42812e | 3 | #define ERTThermisterAdcRef 3.30f |
joeata2wh | 5:88bf5a42812e | 4 | #define ERTThermisterErrorOver 255.0f |
joeata2wh | 5:88bf5a42812e | 5 | #define ERTThermisterErrorUnder -255.0f |
joeata2wh | 0:39f659087759 | 6 | |
joeata2wh | 0:39f659087759 | 7 | float conv_c_to_f(float tempC); |
joeata2wh | 5:88bf5a42812e | 8 | float conv_f_to_c(float tempF); |
joeata2wh | 5:88bf5a42812e | 9 | float ERTThermisterReadTemp(AnalogIn adcpin); |
joeata2wh | 5:88bf5a42812e | 10 | float ERTThermisterAvgReadTemp(AnalogIn adcpin, int numRead); |
joeata2wh | 5:88bf5a42812e | 11 | |
joeata2wh | 5:88bf5a42812e | 12 | |
joeata2wh | 5:88bf5a42812e | 13 | // Read the ERT0xxx thermister and return the temperature |
joeata2wh | 5:88bf5a42812e | 14 | // in C on the specified pin. |
joeata2wh | 5:88bf5a42812e | 15 | // TODO: How do we detect and report error of -999; |
joeata2wh | 5:88bf5a42812e | 16 | |
joeata2wh | 5:88bf5a42812e | 17 | // Shorthand to read thermister by pinName |
joeata2wh | 5:88bf5a42812e | 18 | // rather than reading it with pre-allocated |
joeata2wh | 5:88bf5a42812e | 19 | // AnalogIn. |
joeata2wh | 5:88bf5a42812e | 20 | float ERTThermisterRead(PinName apin); |
joeata2wh | 5:88bf5a42812e | 21 | |
joeata2wh | 5:88bf5a42812e | 22 | // read the temp from thermister and print out |
joeata2wh | 5:88bf5a42812e | 23 | // both the reading and intermediate values. |
joeata2wh | 5:88bf5a42812e | 24 | float ERTThermisterReadPrint(Serial log, char *label, PinName apin); |
joeata2wh | 0:39f659087759 | 25 | |
joeata2wh | 0:39f659087759 | 26 | #endif |