Maker Pro
Maker Pro

Temperature sensor with PIC18F45K80

Djsarkar

Jul 27, 2020
46
Joined
Jul 27, 2020
Messages
46
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?
 

Bluejets

Oct 5, 2014
6,901
Joined
Oct 5, 2014
Messages
6,901
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.
 

hexreader

Apr 21, 2011
135
Joined
Apr 21, 2011
Messages
135
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
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
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.
 

Djsarkar

Jul 27, 2020
46
Joined
Jul 27, 2020
Messages
46
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
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
Sorry, my memory failed here. Then you are good.
 
Top