Connect with us

Temperature sensor with PIC18F45K80

Discussion in 'Microcontrollers, Programming and IoT' started by Djsarkar, Oct 22, 2020.

Scroll to continue with content
  1. Djsarkar

    Djsarkar

    46
    4
    Jul 27, 2020
    Hi
    I have temperature sensor ky013 module. I want to interface with PIC18F45K80

    IMG_20201022_113259.jpg

    The temperature signal are the analog signals, while the microcontroller works on the digital signal. If the sensor gives an analog signal, the microcontroller will not be able to read it.

    Do I need an external ADC?
    Should I use inbuilt ADC in pic micro?
     
  2. Bluejets

    Bluejets

    4,277
    908
    Oct 5, 2014
    Seems an overkill using a micro such as that with a temp sensor.

    Most would have analog handling capability although the readings tend to drift around a bit.
     
    Djsarkar likes this.
  3. hexreader

    hexreader

    119
    27
    Apr 21, 2011
    Use inbuilt 12-bit ADC first, then if stability is not good enough, use external one.

    Here is my suggestion of a way forward - feel free to ignore and do it any other way that you prefer

    1) Start with your working UART code that you posted on Microchip forum.
    2) Comment every line of your UART code so that you will understand it better and those that help you can better understand your intentions
    3) Fix the poor formatting so that the code is more readable
    4) Write or borrow a function that converts unsigned integer to ASCII decimal.
    5) Write ADC code and use the above functions to print it approximately every second
    6) (optional) write or borrow a clever function that converts raw ADC reading to temperature

    The above test code, when written, will be useful for probably all of your sensors that give an analogue voltage as output.

    Do not forget - comment everything while learning and use clear formatting (indenting) to make your code readable

    Good luck....
     
    Djsarkar likes this.
  4. Harald Kapp

    Harald Kapp Moderator Moderator

    10,591
    2,360
    Nov 17, 2011
    This may get you started. But you'll have to learn programming in C, not assembler as you seem to prefer so far.
    Learning C is useful. You can write the bulk of your code in C much better readable and easier to service. You can always mix assembler into C code whenever required (e.g. for extremely time or memory sensitive tasks.
     
  5. Djsarkar

    Djsarkar

    46
    4
    Jul 27, 2020
    Hi Harald
    I don't use assembly for programming. I always prefer c programming language
     
  6. Harald Kapp

    Harald Kapp Moderator Moderator

    10,591
    2,360
    Nov 17, 2011
    Sorry, my memory failed here. Then you are good.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-