# Thermister to Celcius

Played a bit around with my arduino and a temperature brick from Seeed Studio, and had to convert the reading on the analog pin to degrees in Celsius.

After a bit searching searching around, I found this, and it seems to do the job just fine.

```double Thermister(int RawADC)
{
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
Temp = Temp - 273.15;            // Convert Kelvin to Celcius
return Temp;
}
```

All I then had to do, was to call it like this

```Thermister(analogRead(5))
```

And I got the result back I wanted.

To test if it really worked, I tried to make a little sketch to just run through all the numbers.

```double Thermister(int RawADC)
{
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
Temp = Temp - 273.15;            // Convert Kelvin to Celcius
return Temp;
}

void setup()
{
Serial.begin(9600);

for(int i = 0; i &lt; 1024; i++)
{
Serial.print(Thermister(i)); Serial.print(&quot;c&quot;); Serial.print(&quot; = &quot;); Serial.println(i);
}
}

void loop()
{
}
```

Output:

```-83.64c = 1
-75.86c = 2
-71.08c = 3
-67.57c = 4
-64.78c = 5
-62.46c = 6
-60.46c = 7
-58.70c = 8
-57.13c = 9
-55.70c = 10
-54.40c = 11
-53.20c = 12
-52.09c = 13
-51.05c = 14
-50.07c = 15
-49.15c = 16
-48.28c = 17
-47.45c = 18
-46.66c = 19
-45.91c = 20
-45.19c = 21
-44.50c = 22
-43.84c = 23
-43.20c = 24
-42.58c = 25
-41.98c = 26
-41.41c = 27
-40.85c = 28
-40.31c = 29
-39.79c = 30
-39.28c = 31
-38.78c = 32
-38.30c = 33
-37.83c = 34
-37.37c = 35
-36.92c = 36
-36.48c = 37
-36.05c = 38
-35.64c = 39
-35.23c = 40
-34.83c = 41
-34.44c = 42
-34.05c = 43
-33.67c = 44
-33.30c = 45
-32.94c = 46
-32.59c = 47
-32.24c = 48
-31.89c = 49
-31.55c = 50
-31.22c = 51
-30.89c = 52
-30.57c = 53
-30.26c = 54
-29.94c = 55
-29.64c = 56
-29.33c = 57
-29.03c = 58
-28.74c = 59
-28.45c = 60
-28.16c = 61
-27.88c = 62
-27.60c = 63
-27.33c = 64
-27.06c = 65
-26.79c = 66
-26.52c = 67
-26.26c = 68
-26.00c = 69
-25.75c = 70
-25.49c = 71
-25.24c = 72
-25.00c = 73
-24.75c = 74
-24.51c = 75
-24.27c = 76
-24.03c = 77
-23.80c = 78
-23.57c = 79
-23.34c = 80
-23.11c = 81
-22.89c = 82
-22.66c = 83
-22.44c = 84
-22.22c = 85
-22.01c = 86
-21.79c = 87
-21.58c = 88
-21.37c = 89
-21.16c = 90
-20.95c = 91
-20.75c = 92
-20.54c = 93
-20.34c = 94
-20.14c = 95
-19.94c = 96
-19.74c = 97
-19.55c = 98
-19.35c = 99
-19.16c = 100
-18.97c = 101
-18.78c = 102
-18.59c = 103
-18.40c = 104
-18.22c = 105
-18.03c = 106
-17.85c = 107
-17.67c = 108
-17.49c = 109
-17.31c = 110
-17.13c = 111
-16.95c = 112
-16.78c = 113
-16.60c = 114
-16.43c = 115
-16.26c = 116
-16.09c = 117
-15.92c = 118
-15.75c = 119
-15.58c = 120
-15.41c = 121
-15.25c = 122
-15.08c = 123
-14.92c = 124
-14.76c = 125
-14.59c = 126
-14.43c = 127
-14.27c = 128
-14.11c = 129
-13.96c = 130
-13.80c = 131
-13.64c = 132
-13.49c = 133
-13.33c = 134
-13.18c = 135
-13.02c = 136
-12.87c = 137
-12.72c = 138
-12.57c = 139
-12.42c = 140
-12.27c = 141
-12.12c = 142
-11.97c = 143
-11.83c = 144
-11.68c = 145
-11.53c = 146
-11.39c = 147
-11.24c = 148
-11.10c = 149
-10.96c = 150
-10.81c = 151
-10.67c = 152
-10.53c = 153
-10.39c = 154
-10.25c = 155
-10.11c = 156
-9.97c = 157
-9.84c = 158
-9.70c = 159
-9.56c = 160
-9.42c = 161
-9.29c = 162
-9.15c = 163
-9.02c = 164
-8.89c = 165
-8.75c = 166
-8.62c = 167
-8.49c = 168
-8.35c = 169
-8.22c = 170
-8.09c = 171
-7.96c = 172
-7.83c = 173
-7.70c = 174
-7.57c = 175
-7.44c = 176
-7.32c = 177
-7.19c = 178
-7.06c = 179
-6.94c = 180
-6.81c = 181
-6.68c = 182
-6.56c = 183
-6.43c = 184
-6.31c = 185
-6.19c = 186
-6.06c = 187
-5.94c = 188
-5.82c = 189
-5.69c = 190
-5.57c = 191
-5.45c = 192
-5.33c = 193
-5.21c = 194
-5.09c = 195
-4.97c = 196
-4.85c = 197
-4.73c = 198
-4.61c = 199
-4.49c = 200
-4.37c = 201
-4.26c = 202
-4.14c = 203
-4.02c = 204
-3.90c = 205
-3.79c = 206
-3.67c = 207
-3.56c = 208
-3.44c = 209
-3.33c = 210
-3.21c = 211
-3.10c = 212
-2.98c = 213
-2.87c = 214
-2.75c = 215
-2.64c = 216
-2.53c = 217
-2.42c = 218
-2.30c = 219
-2.19c = 220
-2.08c = 221
-1.97c = 222
-1.86c = 223
-1.75c = 224
-1.64c = 225
-1.53c = 226
-1.42c = 227
-1.31c = 228
-1.20c = 229
-1.09c = 230
-0.98c = 231
-0.87c = 232
-0.76c = 233
-0.65c = 234
-0.55c = 235
-0.44c = 236
-0.33c = 237
-0.22c = 238
-0.12c = 239
-0.01c = 240
0.10c = 241
0.20c = 242
0.31c = 243
0.41c = 244
0.52c = 245
0.63c = 246
0.73c = 247
0.84c = 248
0.94c = 249
1.04c = 250
1.15c = 251
1.25c = 252
1.36c = 253
1.46c = 254
1.56c = 255
1.67c = 256
1.77c = 257
1.87c = 258
1.98c = 259
2.08c = 260
2.18c = 261
2.28c = 262
2.38c = 263
2.49c = 264
2.59c = 265
2.69c = 266
2.79c = 267
2.89c = 268
2.99c = 269
3.09c = 270
3.19c = 271
3.29c = 272
3.39c = 273
3.49c = 274
3.59c = 275
3.69c = 276
3.79c = 277
3.89c = 278
3.99c = 279
4.09c = 280
4.19c = 281
4.28c = 282
4.38c = 283
4.48c = 284
4.58c = 285
4.68c = 286
4.78c = 287
4.87c = 288
4.97c = 289
5.07c = 290
5.16c = 291
5.26c = 292
5.36c = 293
5.46c = 294
5.55c = 295
5.65c = 296
5.74c = 297
5.84c = 298
5.94c = 299
6.03c = 300
6.13c = 301
6.22c = 302
6.32c = 303
6.42c = 304
6.51c = 305
6.61c = 306
6.70c = 307
6.80c = 308
6.89c = 309
6.99c = 310
7.08c = 311
7.17c = 312
7.27c = 313
7.36c = 314
7.46c = 315
7.55c = 316
7.65c = 317
7.74c = 318
7.83c = 319
7.93c = 320
8.02c = 321
8.11c = 322
8.21c = 323
8.30c = 324
8.39c = 325
8.49c = 326
8.58c = 327
8.67c = 328
8.76c = 329
8.86c = 330
8.95c = 331
9.04c = 332
9.13c = 333
9.23c = 334
9.32c = 335
9.41c = 336
9.50c = 337
9.59c = 338
9.69c = 339
9.78c = 340
9.87c = 341
9.96c = 342
10.05c = 343
10.14c = 344
10.23c = 345
10.33c = 346
10.42c = 347
10.51c = 348
10.60c = 349
10.69c = 350
10.78c = 351
10.87c = 352
10.96c = 353
11.05c = 354
11.14c = 355
11.23c = 356
11.32c = 357
11.41c = 358
11.50c = 359
11.59c = 360
11.68c = 361
11.77c = 362
11.86c = 363
11.95c = 364
12.04c = 365
12.13c = 366
12.22c = 367
12.31c = 368
12.40c = 369
12.49c = 370
12.58c = 371
12.67c = 372
12.76c = 373
12.85c = 374
12.94c = 375
13.03c = 376
13.12c = 377
13.21c = 378
13.30c = 379
13.38c = 380
13.47c = 381
13.56c = 382
13.65c = 383
13.74c = 384
13.83c = 385
13.92c = 386
14.01c = 387
14.10c = 388
14.18c = 389
14.27c = 390
14.36c = 391
14.45c = 392
14.54c = 393
14.63c = 394
14.71c = 395
14.80c = 396
14.89c = 397
14.98c = 398
15.07c = 399
15.16c = 400
15.24c = 401
15.33c = 402
15.42c = 403
15.51c = 404
15.60c = 405
15.69c = 406
15.77c = 407
15.86c = 408
15.95c = 409
16.04c = 410
16.13c = 411
16.21c = 412
16.30c = 413
16.39c = 414
16.48c = 415
16.56c = 416
16.65c = 417
16.74c = 418
16.83c = 419
16.92c = 420
17.00c = 421
17.09c = 422
17.18c = 423
17.27c = 424
17.35c = 425
17.44c = 426
17.53c = 427
17.62c = 428
17.70c = 429
17.79c = 430
17.88c = 431
17.97c = 432
18.05c = 433
18.14c = 434
18.23c = 435
18.32c = 436
18.40c = 437
18.49c = 438
18.58c = 439
18.67c = 440
18.75c = 441
18.84c = 442
18.93c = 443
19.02c = 444
19.10c = 445
19.19c = 446
19.28c = 447
19.37c = 448
19.45c = 449
19.54c = 450
19.63c = 451
19.72c = 452
19.80c = 453
19.89c = 454
19.98c = 455
20.07c = 456
20.15c = 457
20.24c = 458
20.33c = 459
20.42c = 460
20.50c = 461
20.59c = 462
20.68c = 463
20.77c = 464
20.85c = 465
20.94c = 466
21.03c = 467
21.12c = 468
21.21c = 469
21.29c = 470
21.38c = 471
21.47c = 472
21.56c = 473
21.64c = 474
21.73c = 475
21.82c = 476
21.91c = 477
22.00c = 478
22.08c = 479
22.17c = 480
22.26c = 481
22.35c = 482
22.44c = 483
22.52c = 484
22.61c = 485
22.70c = 486
22.79c = 487
22.88c = 488
22.96c = 489
23.05c = 490
23.14c = 491
23.23c = 492
23.32c = 493
23.41c = 494
23.49c = 495
23.58c = 496
23.67c = 497
23.76c = 498
23.85c = 499
23.93c = 500
24.02c = 501
24.11c = 502
24.20c = 503
24.29c = 504
24.38c = 505
24.47c = 506
24.56c = 507
24.64c = 508
24.73c = 509
24.82c = 510
24.91c = 511
25.00c = 512
25.09c = 513
25.18c = 514
25.27c = 515
25.36c = 516
25.45c = 517
25.54c = 518
25.62c = 519
25.71c = 520
25.80c = 521
25.89c = 522
25.98c = 523
26.07c = 524
26.16c = 525
26.25c = 526
26.34c = 527
26.43c = 528
26.52c = 529
26.61c = 530
26.70c = 531
26.79c = 532
26.88c = 533
26.97c = 534
27.06c = 535
27.15c = 536
27.24c = 537
27.33c = 538
27.42c = 539
27.52c = 540
27.61c = 541
27.70c = 542
27.79c = 543
27.88c = 544
27.97c = 545
28.06c = 546
28.15c = 547
28.24c = 548
28.33c = 549
28.42c = 550
28.52c = 551
28.61c = 552
28.70c = 553
28.79c = 554
28.88c = 555
28.97c = 556
29.07c = 557
29.16c = 558
29.25c = 559
29.34c = 560
29.43c = 561
29.53c = 562
29.62c = 563
29.71c = 564
29.81c = 565
29.90c = 566
29.99c = 567
30.08c = 568
30.18c = 569
30.27c = 570
30.36c = 571
30.45c = 572
30.55c = 573
30.64c = 574
30.74c = 575
30.83c = 576
30.92c = 577
31.01c = 578
31.11c = 579
31.20c = 580
31.30c = 581
31.39c = 582
31.49c = 583
31.58c = 584
31.67c = 585
31.77c = 586
31.86c = 587
31.96c = 588
32.05c = 589
32.15c = 590
32.24c = 591
32.34c = 592
32.43c = 593
32.53c = 594
32.62c = 595
32.72c = 596
32.82c = 597
32.91c = 598
33.01c = 599
33.11c = 600
33.20c = 601
33.30c = 602
33.39c = 603
33.49c = 604
33.59c = 605
33.68c = 606
33.78c = 607
33.88c = 608
33.98c = 609
34.07c = 610
34.17c = 611
34.27c = 612
34.37c = 613
34.46c = 614
34.56c = 615
34.66c = 616
34.76c = 617
34.86c = 618
34.96c = 619
35.05c = 620
35.15c = 621
35.25c = 622
35.35c = 623
35.45c = 624
35.55c = 625
35.65c = 626
35.75c = 627
35.85c = 628
35.95c = 629
36.05c = 630
36.15c = 631
36.25c = 632
36.35c = 633
36.45c = 634
36.55c = 635
36.65c = 636
36.75c = 637
36.86c = 638
36.96c = 639
37.06c = 640
37.16c = 641
37.26c = 642
37.37c = 643
37.47c = 644
37.57c = 645
37.67c = 646
37.78c = 647
37.88c = 648
37.98c = 649
38.09c = 650
38.19c = 651
38.29c = 652
38.40c = 653
38.50c = 654
38.61c = 655
38.71c = 656
38.82c = 657
38.92c = 658
39.03c = 659
39.13c = 660
39.24c = 661
39.34c = 662
39.45c = 663
39.56c = 664
39.66c = 665
39.77c = 666
39.87c = 667
39.98c = 668
40.09c = 669
40.20c = 670
40.31c = 671
40.41c = 672
40.52c = 673
40.63c = 674
40.74c = 675
40.85c = 676
40.95c = 677
41.06c = 678
41.17c = 679
41.28c = 680
41.39c = 681
41.50c = 682
41.61c = 683
41.72c = 684
41.83c = 685
41.94c = 686
42.05c = 687
42.17c = 688
42.28c = 689
42.39c = 690
42.50c = 691
42.61c = 692
42.73c = 693
42.84c = 694
42.95c = 695
43.07c = 696
43.18c = 697
43.29c = 698
43.41c = 699
43.52c = 700
43.64c = 701
43.75c = 702
43.86c = 703
43.98c = 704
44.10c = 705
44.21c = 706
44.33c = 707
44.44c = 708
44.57c = 709
44.68c = 710
44.80c = 711
44.91c = 712
45.04c = 713
45.15c = 714
45.27c = 715
45.39c = 716
45.51c = 717
45.63c = 718
45.74c = 719
45.87c = 720
45.99c = 721
46.11c = 722
46.23c = 723
46.35c = 724
46.47c = 725
46.60c = 726
46.71c = 727
46.84c = 728
46.96c = 729
47.08c = 730
47.21c = 731
47.33c = 732
47.46c = 733
47.58c = 734
47.71c = 735
47.83c = 736
47.96c = 737
48.08c = 738
48.21c = 739
48.34c = 740
48.46c = 741
48.59c = 742
48.72c = 743
48.85c = 744
48.98c = 745
49.11c = 746
49.23c = 747
49.37c = 748
49.49c = 749
49.62c = 750
49.75c = 751
49.88c = 752
50.02c = 753
50.15c = 754
50.29c = 755
50.42c = 756
50.55c = 757
50.68c = 758
50.82c = 759
50.95c = 760
51.09c = 761
51.22c = 762
51.36c = 763
51.49c = 764
51.63c = 765
51.77c = 766
51.91c = 767
52.05c = 768
52.19c = 769
52.33c = 770
52.46c = 771
52.60c = 772
52.74c = 773
52.89c = 774
53.03c = 775
53.17c = 776
53.32c = 777
53.46c = 778
53.60c = 779
53.74c = 780
53.89c = 781
54.03c = 782
54.18c = 783
54.32c = 784
54.47c = 785
54.62c = 786
54.77c = 787
54.92c = 788
55.06c = 789
55.21c = 790
55.37c = 791
55.51c = 792
55.67c = 793
55.82c = 794
55.97c = 795
56.12c = 796
56.28c = 797
56.43c = 798
56.58c = 799
56.74c = 800
56.89c = 801
57.05c = 802
57.21c = 803
57.37c = 804
57.53c = 805
57.69c = 806
57.86c = 807
58.01c = 808
58.17c = 809
58.34c = 810
58.50c = 811
58.67c = 812
58.82c = 813
59.00c = 814
59.16c = 815
59.32c = 816
59.49c = 817
59.66c = 818
59.82c = 819
60.00c = 820
60.17c = 821
60.34c = 822
60.51c = 823
60.68c = 824
60.85c = 825
61.03c = 826
61.20c = 827
61.38c = 828
61.56c = 829
61.74c = 830
61.92c = 831
62.10c = 832
62.28c = 833
62.46c = 834
62.64c = 835
62.83c = 836
63.00c = 837
63.19c = 838
63.37c = 839
63.57c = 840
63.76c = 841
63.94c = 842
64.13c = 843
64.33c = 844
64.52c = 845
64.70c = 846
64.91c = 847
65.10c = 848
65.29c = 849
65.49c = 850
65.70c = 851
65.90c = 852
66.10c = 853
66.30c = 854
66.50c = 855
66.71c = 856
66.91c = 857
67.12c = 858
67.33c = 859
67.54c = 860
67.74c = 861
67.95c = 862
68.17c = 863
68.39c = 864
68.59c = 865
68.82c = 866
69.04c = 867
69.25c = 868
69.48c = 869
69.69c = 870
69.93c = 871
70.14c = 872
70.38c = 873
70.60c = 874
70.84c = 875
71.07c = 876
71.30c = 877
71.54c = 878
71.78c = 879
72.01c = 880
72.25c = 881
72.50c = 882
72.74c = 883
72.99c = 884
73.23c = 885
73.48c = 886
73.73c = 887
73.98c = 888
74.24c = 889
74.50c = 890
74.76c = 891
75.02c = 892
75.29c = 893
75.53c = 894
75.81c = 895
76.08c = 896
76.36c = 897
76.61c = 898
76.90c = 899
77.18c = 900
77.45c = 901
77.74c = 902
78.04c = 903
78.31c = 904
78.61c = 905
78.89c = 906
79.20c = 907
79.49c = 908
79.78c = 909
80.10c = 910
80.40c = 911
80.70c = 912
81.03c = 913
81.34c = 914
81.65c = 915
81.96c = 916
82.31c = 917
82.63c = 918
82.96c = 919
83.29c = 920
83.63c = 921
83.97c = 922
84.31c = 923
84.66c = 924
85.01c = 925
85.37c = 926
85.73c = 927
86.10c = 928
86.47c = 929
86.85c = 930
87.23c = 931
87.59c = 932
87.98c = 933
88.38c = 934
88.78c = 935
89.16c = 936
89.58c = 937
90.00c = 938
90.39c = 939
90.83c = 940
91.23c = 941
91.68c = 942
92.13c = 943
92.56c = 944
93.03c = 945
93.47c = 946
93.91c = 947
94.41c = 948
94.87c = 949
95.38c = 950
95.85c = 951
96.34c = 952
96.83c = 953
97.37c = 954
97.88c = 955
98.40c = 956
98.93c = 957
99.52c = 958
100.07c = 959
100.63c = 960
101.20c = 961
101.79c = 962
102.38c = 963
102.99c = 964
103.61c = 965
104.24c = 966
104.89c = 967
105.55c = 968
106.22c = 969
106.91c = 970
107.62c = 971
108.35c = 972
109.02c = 973
109.78c = 974
110.56c = 975
111.35c = 976
112.10c = 977
112.94c = 978
113.80c = 979
114.69c = 980
115.52c = 981
116.46c = 982
117.34c = 983
118.33c = 984
119.36c = 985
120.33c = 986
121.42c = 987
122.45c = 988
123.62c = 989
124.73c = 990
125.98c = 991
127.17c = 992
128.40c = 993
129.81c = 994
131.15c = 995
132.54c = 996
134.14c = 997
135.66c = 998
137.25c = 999
138.93c = 1000
140.86c = 1001
142.72c = 1002
144.68c = 1003
146.76c = 1004
148.97c = 1005
151.56c = 1006
154.09c = 1007
156.81c = 1008
159.74c = 1009
162.92c = 1010
166.38c = 1011
170.19c = 1012
174.41c = 1013
179.12c = 1014
184.46c = 1015
190.58c = 1016
197.74c = 1017
206.31c = 1018
215.73c = 1019
229.06c = 1020
247.45c = 1021
276.07c = 1022
334.94c = 1023
```