Pages: [1]   Go Down
Author Topic: How to send analog value from xbee to excel file  (Read 815 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello there, I am trying to send data from my arduino to another and import data to an excel file. I am using a temperature and humidity sensor DHT11. can you help in providing the code.

below the code I have but it imports data to a program called X-CTU


#define DHT11_PIN 0      // ADC0
 
byte read_dht11_dat()
{
  byte i = 0;
  byte result=0;
  for(i=0; i< 8; i++){
 
 
    while(!(PINC & _BV(DHT11_PIN)));  // wait for 50us
    delayMicroseconds(30);
 
    if(PINC & _BV(DHT11_PIN))
      result |=(1<<(7-i));
    while((PINC & _BV(DHT11_PIN)));  // wait '1' finish
 
 
  }
  return result;
}
 
 
void setup()
{
  DDRC |= _BV(DHT11_PIN);
  PORTC |= _BV(DHT11_PIN);
 
  Serial.begin(9600);
 
  Serial.println("Ready");
}
 
void loop()
{
  byte dht11_dat[5];
  byte dht11_in;
  byte i;
  // start condition
  // 1. pull-down i/o pin from 18ms
  PORTC &= ~_BV(DHT11_PIN);
  delay(18);
  PORTC |= _BV(DHT11_PIN);
  delayMicroseconds(40);
 
  DDRC &= ~_BV(DHT11_PIN);
  delayMicroseconds(40);
 
  dht11_in = PINC & _BV(DHT11_PIN);
 
  if(dht11_in){
    Serial.println("dht11 start condition 1 not met");
    return;
  }
  delayMicroseconds(80);
 
  dht11_in = PINC & _BV(DHT11_PIN);
 
  if(!dht11_in){
    Serial.println("dht11 start condition 2 not met");
    return;
  }
  delayMicroseconds(80);
  // now ready for data reception
  for (i=0; i<5; i++)
    dht11_dat = read_dht11_dat();
 
  DDRC |= _BV(DHT11_PIN);
  PORTC |= _BV(DHT11_PIN);
 
  byte dht11_check_sum = dht11_dat[0]+dht11_dat[1]+dht11_dat[2]+dht11_dat[3];
  // check check_sum
  if(dht11_dat[4]!= dht11_check_sum)
  {
    Serial.println("DHT11 checksum error");
  }
 
  Serial.print("Current humdity = ");
  Serial.print(dht11_dat[0], DEC);
  Serial.print(".");
  Serial.print(dht11_dat[1], DEC);
  Serial.print("%  ");
  Serial.print("temperature = ");
  Serial.print(dht11_dat[2], DEC);
  Serial.print(".");
  Serial.print(dht11_dat[3], DEC);
  Serial.println("C  ");
 
  delay(2000);
}
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 83
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what abouth get all data from sensor to sd card  smiley-wink. this is great tutorial and there is used excel:
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can use a python script to listen to the serial port and save the data into a text document. Excel can import files in .csv and .txt (with tab as a field separator). you can view more information on excel importing at http://office.microsoft.com/en-us/excel-help/import-or-export-text-txt-or-csv-files-HP010099725.aspx

http://apexlogic.net/code-bank/python/pyserial-example/

here is a an example to read information from the arduino through a python script.
Logged

Pages: [1]   Go Up
Jump to: