Show Posts
Pages: [1]
1  Using Arduino / Sensors / Re: Temp Sensor does not get reasonable result on: June 22, 2011, 05:38:47 am
This:
Code:
sensorValue_Light = analogRead(sensorPin_Light);
sensorValue_Temp = analogRead(sensorPin_Temp);

may be problematic. The analog pins share a single A2D converter. If you try to read from multiple pins in rapid succession, the later results tend to be inaccurate. Recent posts have suggested a couple of remedies: use a small delay between readings or take two readings for each input and ignore the first. In your case, just commenting out the analogRead for the light should show you if that is the issue.

I have tried both ways: only read temperature and read twice when there is light sensor. fortunately, both of them works well for me. Thank you very much. smiley
2  Using Arduino / Sensors / Re: Temp Sensor does not get reasonable result on: June 22, 2011, 04:41:58 am
Q:

Udp.sendPacket(udp_content, remoteIP, remotePort ); ?? How does sendPacket know the length of the packet to be send?

According to my understanding, for every UDP packet in IP v4, the size of data in one packet is always 160 bits. In other words, no matter how real size of data is, the method always send 160 bits data every time.
3  Using Arduino / Sensors / Re: Temp Sensor does not get reasonable result on: June 21, 2011, 11:04:33 am
my code as following:
Code:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10,10,102,160 };
unsigned int localPort = 8012;

int sensorPin_Light = A0;
int sensorValue_Light = 0;

int sensorPin_Temp = A1;
int sensorValue_Temp = 0;
char sensorValue_Temp_Char[2] ;

byte remoteIP[] = { 10,10,102,133 };
int remotePort = 58121; // the destination port

void setup() {
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);
  
  Serial.begin(9600);
 }

void loop() {
  
  sensorValue_Light = analogRead(sensorPin_Light);
  sensorValue_Temp = analogRead(sensorPin_Temp);
  
  //udp packet can have max 160 bits for data.
  char udp_content[20] ;
  //four char is used for every integer's digital whose max value is 1024, and end with ','
  char sensorValue_Light_Char[5] ;
  itoa (sensorValue_Light, sensorValue_Light_Char, 10);
  
  char sensorValue_Temp_Char[5] ;
  itoa (sensorValue_Temp, sensorValue_Temp_Char, 10);


  strcpy (udp_content,sensorValue_Light_Char);
  strcat (udp_content,",");
  strcat (udp_content,sensorValue_Temp_Char);
  strcat (udp_content,",");

  Serial.println(udp_content);
  
  Udp.sendPacket(udp_content, remoteIP, remotePort );
  delay(2000);
}

how i connect the lm35:
5v for power, GND line connect with GND pin and analog in 1 for temperature.
PS. meanwhile, I also use a light intensity sensor with A0.

4  Using Arduino / Sensors / Temp Sensor does not get reasonable result on: June 21, 2011, 05:48:07 am
Hi All,

I am totally new to arduino, even hardware, could someone help me out with below problem:

I have an arduino UNO and DFROBOT ethernet shield which connected with each other. Then, I connect a temperature sensor (lm 35 dz) to the ethernet shield, 5 v power supply. Additionally, I use a 9 volts AC power supply for the entire unit. I use following formula to calculate centigrade from pin output: signal*voltage*100/1023, voltage here is 4.98 volts measured manually.

However, result is near 40 degree while real temperature is only 24 degree. Also I measure the voltage between power supply and GND of this temp sensor, it is about 0.25 volts which multiple by 100 is close to real temperature.

I do not know what's wrong? Could anyone give me some idea or clues about it?

Regards,
Jie
Pages: [1]