100% understand that this is not a spark specific question (well, kind of…its about 3.3v boards), but i feel like the community is so helpful here, im comfortable asking.
i am trying to build a wifi temperature sensor using my spark core. i have previously built ones using the RasPi, but i feel like a spark would be a more elegant solution.
for a thermometer, ive planned on using a Maverick ET-73 since they are so easy to come by. they are thermsistors, so i have one clicked in using a 10k resistor. unfortunately, all the examples i found were built for arduino UNOs (and a 5v board)
since i know enough about these to understand the voltage matters, i modified the code from here:
I retrieved a decent A, B, C value set, and then changed the code to the below, but its showing entirely incorrect temps. any ideas where im wrong on this??
// calculate voltage float voltage = aval / 1024 * 3.3; Serial.print("voltage = "); Serial.print(voltage); Serial.print("\n"); // calculate resistance float resistance = (10000 * voltage) / (3.3 - voltage); Serial.print("resistance = "); Serial.print(resistance); Serial.print("\n"); // calcuate temperature. Use these values for A, B, and C till you // get everything working, and then do some measurements to calibrate // your thermistor in circuit. float logcubed = log(resistance); logcubed = logcubed * logcubed * logcubed; float kelvin = 1.0 / (2.3067434E-4 + 2.3696596E-4 * log(resistance) - 1.2636414E-7 * (logcubed)); // Convert to Fahrenheit float f = (kelvin - 273.15) * 9.0/5.0 + 32.0; return (int) f;