A thermistor changes resistance based on its temperature. The sensor readings from the breadboard can be converted to temperatures using a few formulas based on the Steinhart–Hart equation.
First you will need to connect up your Wifi, Power Station and Breadboard blocks and connect them to a power source.
Put the Breadboard block into your Workspace and open the properties panel for the block. In the custom settings section select the visual map to start configuring the pins on your Breadboard block.
Configure each of the pins following the reference below:
IO5 - AnalogIn |
IO6 - VCC | IO7 - GND |
The sensor PCB has an "S" written on the signal side and a negative symbol on the ground side, which leaves the middle pin to be VCC. Make sure to connect the sensor to the corresponding pins on the Breadboard block.
Sensor | Breadboard |
S(signal) | --> IO5 AnalogIn |
Vcc | --> IO6 VCC |
- (GND) | --> IO7 GND |
***NOTE: If your sensor starts increasing in temperature when it should be decreasing swap your GND and VCC pins. The board is mislabelled. ***
Now that your pins are configured and the sensor is connected you will start getting readings from the sensor. We will now need to convert these readings to temperatures.
Logic maker method:
In the breadboard logic maker follow the image below to convert the sensor reading to a temperature:
Script block method:
To use the script block, put it into your Workspace by selecting it from the Virtual Blocks menu.
Open the script block logic maker and copy and paste the code below into the window.
var R1 = 10000; // value of R1 on board
var c1 = 0.001129148;
var c2 = 0.000234125;
var c3 = 0.0000000876741; //Steinhart–Hart coefficients
async function onReload(){
const BBblock = await Kitsi.waitForBlock(BlockTypes.Breadboard);
console.log("block connected");
Kitsi.onData(BBblock, function(data){
console.log(data);
//extract thermistor reading and convert to temp in Celsius
var tempRead = data[0].value;
var temp= calcTemp(tempRead);
});
}
//Converts sensor reading to temperature
function calcTemp(Tvalue){
var R2 = R1 * (0xFFFF / Tvalue - 1.0); //calculate resistance on thermistor
var logR2 = Math.log(R2);
var T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2)); // temperature in Kelvin
T = T - 273.15; //convert Kelvin to Celsius
console.log("Temp: " + T);
return T;
}
After pasting the code hit apply in the bottom right corner to run the code.
Once your code is running we can see information being printed out in the console window. To open the console window select the "Console" drop down menu and select Show.
The console window will pop up at the bottom of the window and will display the sensor reading from pin IO5 as well as the converted temperature.