Libelium is offering new technical support channels, to contact with de Technical Support team to solve any issue our doubt please contact with your sales agent or visit our contact site



Post a new topicPost a reply Page 1 of 2   [ 12 posts ]
Go to page 1, 2  Next
Author Message
 Post subject: Reading NTC sensor value
PostPosted: Fri Jan 12, 2018 10:43 am 

Joined: Mon Oct 23, 2017 9:34 am
Posts: 49
Hi,
I am sending temperature values fom NTC sensors,followed cooking hacks documentation(https://www.cooking-hacks.com/documenta ... eme-range/).

I succeed in getting the values from analog output,I convert it to degree celusis.I tested the sensor inside and outside.My outside temperature is 4 degree celusis,whereas the sensor records this as 20 degree in beginning then takes time to reduce and stops at 13 degree.Thereafter it didn't go low.

Let me know if this is normal,according data sheet of MCP9700.Accuracy is +or - 4 degree.

Also the program has a bug,change the data type from int to float,because the for the values like 0.69 is stored as 0.And the entire result is 0.


Last edited by karthik22 on Fri Jan 12, 2018 3:43 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Converting NTC into temperature celusis
PostPosted: Fri Jan 12, 2018 11:33 am 

Joined: Mon Oct 23, 2017 9:34 am
Posts: 49
//Referred from Cooking Hacks

#include "SX1272.h"

int e;
char message1 [60];
int ldr;
int ntc;//this is the bug
void get_temp();

void setup()
{
// Print a start message
printf("SX1272 module and Arduino: receive packets without ACK\n");

// Power ON the module
sx1272.ON();
printf("Setting power ON: state ");
printf("%d\n",e);

// Set transmission mode and print the result
e = sx1272.setMode(4);
printf("Setting Mode: state ");
printf("%d\n",e);

// Select frequency channel
e = sx1272.setChannel(CH_12_868);
printf("Setting Channel: state ");
printf("%d\n",e);

// Select output power (Max, High or Low)
e = sx1272.setPower('H');
printf("Setting Power: state ");
printf("%d\n",e);

// Set the node address and print the result
e = sx1272.setNodeAddress(2);
printf("Setting node address: state ");
printf("%d\n",e);

// Print a success message
printf("SX1272 successfully configured\n");
}

void loop(void)
{
ldr = analogRead(1);
get_temp();
sprintf(message1,"LDR value: %i \r\nNTC value: %i\r\n",ldr,ntc);
e = sx1272.sendPacketTimeout(3, message1);
printf("Packet sent, state ");
printf("%d\n",e);

delay(5000);
}


void get_temp() {
ntc = analogRead(0) * 5 / 1024.0;
ntc = ntc - 0.5;
ntc = ntc / 0.01;
}

int main (){
setup();
while(1){
loop();
}
return (0);
}


Top
 Profile  
 
 Post subject: Re: Reading NTC sensor value
PostPosted: Mon Jan 15, 2018 9:24 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi karthik22,

Same as the other pot, can you tell us with hard aware configuration are you using?

Thanks.

Regards


Top
 Profile  
 
 Post subject: Re: Reading NTC sensor value
PostPosted: Tue Jan 16, 2018 5:18 pm 

Joined: Mon Oct 23, 2017 9:34 am
Posts: 49
Hi dev,
Raspberry pi model 3 B
LoRa SX1272
MCP9700 temp sensor


Top
 Profile  
 
 Post subject: Re: Reading NTC sensor value
PostPosted: Wed Jan 17, 2018 8:21 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi karthik22,

Can you upload some pictures of how do you connect the sensor to the Raspberry?

Thanks.

Regards


Top
 Profile  
 
 Post subject: Re: Reading NTC sensor value
PostPosted: Mon Jan 22, 2018 12:05 pm 

Joined: Mon Oct 23, 2017 9:34 am
Posts: 49
Hi dev,

I followed the documentation of cooking-hacks (https://www.cooking-hacks.com/documenta ... eme-range/) but only on declaring the NTC as float and %f as format specifier.I am able to receive the correct value.

Whereas in the documentation NTC is declared as int and format specifier as %i which doesn't give the dersired result.The circuit connection and connecting it to raspberry. I have done exactly according to documentation.

I am sorry I am not able to upload the images as I don't know how to upload the photo stored in my machine in this interface.


Top
 Profile  
 
 Post subject: Re: Reading NTC sensor value
PostPosted: Tue Jan 23, 2018 7:58 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi karthik22,

If you want to upload a photo to the forum, you need to upload it to google drive or dopbox and share with us the public link of the photo.

Thanks.

Regards


Top
 Profile  
 
 Post subject: Re: Reading NTC sensor value
PostPosted: Fri Feb 09, 2018 12:08 pm 

Joined: Mon Oct 23, 2017 9:34 am
Posts: 49
https://drive.google.com/file/d/19xI225hUBFj1cmwvfUWdMYe9m_cZ1yyP/view?usp=sharing
you can view the setup in the above image.It is exactly as per the documentation.


Top
 Profile  
 
 Post subject: Re: Reading NTC sensor value
PostPosted: Fri Feb 09, 2018 3:26 pm 

Joined: Mon Oct 23, 2017 9:34 am
Posts: 49
Hi ,
I wanted to how is the temp sensor value computed (as per cooking hacks documentation).I went through the MCP9700 data sheet,but I couldn't understand it clearly as I am new to this field.Can anyone please explain how it is computed?This is the code for ref

ntc = analogRead(0) * 5 / 1024.0;
ntc = ntc - 0.5;
ntc = ntc / 0.01;

Thank you :)


Top
 Profile  
 
 Post subject: Re: Reading NTC sensor value
PostPosted: Mon Feb 12, 2018 8:06 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi karthik22,

Here you can see a explanation:

http://starter-kit.nettigo.eu/2010/how- ... d-mcp9700/

Code:
The program measures temperature and sends the reading to Serial, from which we can read it using serial port monitor in Arduino IDE. How the temperature is calculated? I divded the whole process in three steps to make it easier to understand:

    · temp = analogRead(0)*5/1024.0; Reading value from analog input and converting it to voltage. Maximal voltage Arduino is able to measure equals 5V and the A/D converter’s resolution is 10 bits, which means 1024 values, thus voltage value on Analog0 input is the value returned by analogRead multiplied by the voltage equaling one step of A/D converter. You have to remember, that dividing 5 by 1024 would be interpreted by compiler as integer operation and the result in this case will equal 0. Because of this in the code appears 1024.0 and thanks to this entry, the compiler will treat the dividing as floating point operation.

   · temp = temp - 0.5; Calibrating to 0°C – the difference between voltage read from the sensor and 500 mV is linearily dependent on temperature.

    · temp = temp / 0.01; This difference is divided by 10mV/step and now we have temperature



Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 2   [ 12 posts ]
Go to page 1, 2  Next


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use.