Maker Pro
Maker Pro

Temperature sensor with PIC18F45K80

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?
 
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.
 
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....
 

Harald Kapp

Moderator
Moderator
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.
 
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.
Hi Harald
I don't use assembly for programming. I always prefer c programming language
 
Top