interfacing a MCP9701 #398
Replies: 17 comments
-
Posted at 2014-02-25 by ltj You should not use a resistor like the thermistor tutorial suggests. Instead you connect the output pin (white on the Atlas device) on the MCP9701 directly to an ADC pin on the Espruino. The voltage you read is proportional to the temperature. Use the calculations described in the atlas datasheet to get the actual temperature. Just remember that Espruino analogRead returns a resolution-independent number between 0 and 1, and the Aref voltage is 3.3V. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-25 by @gfwilliams Hi... It looks from the MCP9701 info like the MCP9701 is an 'active' thermistor and outputs a voltage (rather than resistance) so you don't need a resistor at all. Not only that but it's linear. The datasheet gives you the formula you need - I don't have one here to test but your code should look something like:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-25 by d0773d Thank you. Hook up was simple :-) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-26 by d0773d Gordon, your example worked. I echoes out, for example, 24.91330565947488295819 I was able to convert C to F by this:
Is there anyway to change the decimal place to just two digits after the decimal? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-26 by tage try tempinf.toFixed(2) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-26 by d0773d That worked. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-28 by d0773d I am now attempting to get a more accurate result by finding the average of multiple temp results. The issue I am having is, when I find the average I am getting undefined and NaN from the output of the variable that I supposedly saved the average to. The issue I think is stemming from the way I am saving the temp value. Also, besides taking the average results, is there another way I could achieve a more accurate temperature? My code:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-28 by @gfwilliams Try setting
In JavaScript, values default to |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-28 by d0773d Hi Gordon. Setting both the variables to 0 worked. I am now receiving a negative temp reading. It has to be my math that is the issue. Code:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-28 by DrAzzy Around -20C by any chance? (in other words, tempinc=(-0.4)*tCooef, so Vout=0 because of a wiring issue or something like that) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-01 by d0773d DrAzzy, yes the temp is averaging around -20C. I don't think it is a wiring issue. I was getting positive readings before I attempting to implement some kind of averaging temp reading. Well, I just made a liar out of myself. I went back to my original code without the averaging stuff and I am still receiving negative readings. Original code:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-01 by DrAzzy Oh, I just found your problem! E.getAnalogVRef() returns something that's nearly 0 on V53 of Espruino firmware.
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-01 by d0773d DrAzzy, I'm at a loss to what that means. What should I do to fix this issue? UPDATE |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-02 by @gfwilliams Yes, sorry about this. I'll try and fix this tomorrow. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-03 by d0773d Thanks, I'm looking forward to the fix :-) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-03 by @gfwilliams Ok, it's fixed (1v55). The next time you try it, it should prompt you to update. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-03 by d0773d Gordon, thank you! All is working as expected :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-25 by d0773d
In my past projects I have successfully used a MCP9701. Atlas-scientific has created a wonderful waterproof and food friendly product that incorporates the MCP9701. I emailed the manufacturer for more info about their product. They responded that their product uses a "MCP9701 and other stuff" in the past I had to modify their arduino example code to work with the mbed platform with success. Now, I would like to port/modify the arduinos example code to work on the Espruino platform. I stumbled across http://www.espruino.com/Thermistors. I am not sure of the mcp chip that I am using will work when using the Espruino thermistors example. The example page asked to check the resistance then use a matching resistor. I have never used a resistor with my past projects using a arduino and mbed because the datasheet of the temp probe https://www.atlas-scientific.com/_files/_datasheets/_sensor/ENV-TEMP_1.4.pdf never asked to use one. maybe the resister is already part of the atlas-scientific temp probe? I'm looking for guidance to port the code over to Espruino, any help is greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions