Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. Atmega328 internal temperature sensor (yes it exists!)
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

Atmega328 internal temperature sensor (yes it exists!)

Scheduled Pinned Locked Moved Hardware
12 Posts 8 Posters 4.7k Views 11 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Nca78N Offline
    Nca78N Offline
    Nca78
    Hardware Contributor
    wrote on last edited by
    #2

    I wish I had a home that fresh :D

    Thank you for the time taken to test and report, I knew about didn't think you could keep that close to a temperature sensor even after individual calibration.

    Question is, is it worth the time to calibrate each atmega compared to adding a cheap i2c sensor ?

    mfalkviddM 1 Reply Last reply
    0
    • NeverDieN Offline
      NeverDieN Offline
      NeverDie
      Hero Member
      wrote on last edited by
      #3

      Does the difference remain small over a wide temperature range? I doubt it.

      1 Reply Last reply
      0
      • Nca78N Nca78

        I wish I had a home that fresh :D

        Thank you for the time taken to test and report, I knew about didn't think you could keep that close to a temperature sensor even after individual calibration.

        Question is, is it worth the time to calibrate each atmega compared to adding a cheap i2c sensor ?

        mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by mfalkvidd
        #4

        @nca78 if a single calibration at room temperature is enough, I’d say it is. Quick and simple. But if i need to put the node in the freezer to get a second calibration point, it would take too much time.

        My guess is that one calibration point is insufficient, since my tests show increased drifting both at ~24C (-0.4C) and ~21.5C (+0.3C). So as soon as we get away from the 23C calibration point the accuracy becomes bad.

        1 Reply Last reply
        1
        • NeverDieN Offline
          NeverDieN Offline
          NeverDie
          Hero Member
          wrote on last edited by NeverDie
          #5

          It would be an interesting experiment to gather data at every point over a wide temperature range. That chip would then be perfectly calibrated. The question would then be: how well do other chips follow the same curve? Maybe they follow it reasonably closely. Or, maybe they don't. I suppose it depends on manufacturing tolerances.

          As far as I know, no one has done that experiment.

          mfalkviddM 1 Reply Last reply
          0
          • NeverDieN NeverDie

            It would be an interesting experiment to gather data at every point over a wide temperature range. That chip would then be perfectly calibrated. The question would then be: how well do other chips follow the same curve? Maybe they follow it reasonably closely. Or, maybe they don't. I suppose it depends on manufacturing tolerances.

            As far as I know, no one has done that experiment.

            mfalkviddM Offline
            mfalkviddM Offline
            mfalkvidd
            Mod
            wrote on last edited by
            #6

            @neverdie from what I have read, there will be large differences between different chips. Similar to the pullups not being exactly same, and the internal band gap reference being different.

            YveauxY 1 Reply Last reply
            0
            • mfalkviddM mfalkvidd

              @neverdie from what I have read, there will be large differences between different chips. Similar to the pullups not being exactly same, and the internal band gap reference being different.

              YveauxY Offline
              YveauxY Offline
              Yveaux
              Mod
              wrote on last edited by
              #7

              @mfalkvidd This appnote contains a conclusion on accuracy:

              • One-point calibration. Offset removal using room temperature as reference gives +/-5°C accuracy from -30°C to 100°C and +/-3°C accuracy between 0°C and 85°C.
              • Two-point calibration. Here, +/-1°C accuracy from 5°C to 95°C can be achieved.

              http://yveaux.blogspot.nl

              1 Reply Last reply
              2
              • A Offline
                A Offline
                ashokgowtham
                wrote on last edited by
                #8

                Interesting to know that atmega328 has a temperature sensor!
                I'm thinking the calibration doesn't need to be completely manual and shouldn't be requiring us to flash the µC again just to recalibrate. we could connect an I2C sensor just during calibration and disconnect it after calibration is done. the firmware could get data from both internal and external sensors and store the calibration data in eeprom. This data can then be read back to measure properly using internal sensor after deploying.
                It is even possible to remove the need to flash the µC after the calibration, if the calibration logic is part of the production firmware itself.

                1 Reply Last reply
                0
                • mfalkviddM Offline
                  mfalkviddM Offline
                  mfalkvidd
                  Mod
                  wrote on last edited by mfalkvidd
                  #9

                  While browsing the MySensors source code, I stumbled on this code that shows that support for the internal temperature sensor is already included in the MySensors library, including offset and gain calibration.

                  Just call hwCPUTemperature()

                  1 Reply Last reply
                  2
                  • alowhumA Offline
                    alowhumA Offline
                    alowhum
                    Plugin Developer
                    wrote on last edited by
                    #10

                    @mfalkvidd :-D

                    1 Reply Last reply
                    0
                    • O Offline
                      O Offline
                      oneyb
                      wrote on last edited by
                      #11

                      @mfalkvidd that is pretty nifty. I need to figure out how I can use this. Thanks for keeping this discussion active. Little things like that have the possibility of saving even more power.

                      1 Reply Last reply
                      0
                      • dirkcD Offline
                        dirkcD Offline
                        dirkc
                        wrote on last edited by
                        #12

                        @mfalkvidd said in Atmega328 internal temperature sensor (yes it exists!):

                        hwCPUTemperature()

                        sorry, stupid question maybe, but with my 328p based sensors hwCPUTemperature() is not automatically callable using just
                        #include <MySensors.h> --> neither with 2.2.0 nor with 2.3.0

                        Do I have to include /hal/architecture/AVR/MyHwAVR.h ?
                        Cannot compile it, what path should I use in the #include statement? :white_frowning_face:

                        Controller: Home Assistant & FHEM - Gateway: ESP8266wifi - MySensors: 2.3.2 (nRF24)

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        16

                        Online

                        11.7k

                        Users

                        11.2k

                        Topics

                        113.0k

                        Posts


                        Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • OpenHardware.io
                        • Categories
                        • Recent
                        • Tags
                        • Popular