Show Posts
Pages: 1 ... 13 14 [15] 16 17 ... 19
211  Forum 2005-2010 (read only) / Interfacing / Re: Serial read from sensor on: October 29, 2009, 06:27:17 am
Hi Awol,

Thanks for the advice - I substituted your code into the script but I'm getting errors beyond my ability.  It will be my lack of syntax/knowledge !!  Would you be up for patching it into the original code?
212  Forum 2005-2010 (read only) / Interfacing / Re: Serial read from sensor on: October 28, 2009, 05:06:25 pm
Ideally I would get I2C working :-)  I am using 4K7 pullups to 5V and analog pins 4 & 5.  The code below (written by another helpful soul)returns a result but the bytes returned are all 8's with a PPM: 2056 !!!

IE:
CO PPM: 2056
Data received:8,8,8,8,8,8,8,


Code:
#include <Wire.h>
//wire library

#define address 0x31
//address of the sensor

#define delayC 5000
//delay count in ms

#define baudrate 9600
//baudrate for communication

void setup()
{
  Wire.begin();
  Serial.begin(baudrate);
}

void loop()
{
  //Serial.print("CO PPM: ");
  
  int co=0;

  Wire.beginTransmission(address);
  // start the transmission
  
  Wire.send('R');
    
  Wire.endTransmission();
  //end the transmission
  
 /// Wire.requestFrom(address, 7);
  
  // format
  // 1) Configuration 0x08
  // 2) CO (high byte?)
  // 3) CO (low byte?)
  // 4) reserved
  // 5) reserved
  // 6) reserved
  // 7) reserved
  
  Serial.print ("Data received:");
  for (int i=0;i<7;i++)
  {
    byte c;
    c = getI2Cchar();
    Serial.print(c,HEX);
    Serial.print(',');
    if (i==1) co = c;
    if (i==2) co = (co << 8) | c;
  }
  Serial.println("");
  Serial.print("CO PPM: ");
  Serial.println(co);

  delay(delayC);
}

byte getI2Cchar()
{
  delay(2); // delay 2mS
  Wire.requestFrom(address, 1);
  return (Wire.receive());
}
213  Forum 2005-2010 (read only) / Interfacing / Re: Serial read from sensor on: October 28, 2009, 04:37:20 pm
Hi Groove,

OKAY - that would explain a lot - it looks like I am back to headscratching (well scrathced already) with I2C then or buying a MEGA?
214  Forum 2005-2010 (read only) / Interfacing / Re: Serial read from sensor on: October 28, 2009, 04:33:19 pm
Hi Andy,

Your right - at this stage I just want to 'see' the output, eventually printing to an LCD and finally data logging.

The sensor is pre-production so not too much info available to share - it does output to both I2C & UART.

Thanks for the serial expalination - I'm clear now - would also expalin why I couldn't upload with the sensor connected!
215  Forum 2005-2010 (read only) / Interfacing / Re: Serial read from sensor on: October 28, 2009, 04:28:23 pm
Hmmm, you could be right - I looked at this too: http://arduiniana.org/libraries/NewSoftSerial/ max BAUD being 28800 - does it have to be exactly the same to work?

The data sheet say this:

UART
38400bps, 8bit, No parity, 1 stop bit
TTL Level Voltage 3.0~4.5V
216  Forum 2005-2010 (read only) / Interfacing / Re: Serial read from sensor on: October 28, 2009, 04:12:16 pm
Hi Andy,

Thanks for your reply.  Part of the problem is that I am very new to Arduino/MCU's - I'm kinda feeling my way slowly :-)

I am using a Duemilanove which I guess has just one real serial port which I was hoping to use but it sounds like a software serial is required for this board?

I'm rubbish at coding a the mo - learning slowly.  Would you be up for showing me, based on the code below, how to ask for 10 bytes and then printing them to a serial window?  Any help is appreciated as I have been on this for days now - failed to get I2C working and now failing at serial too !

Code:
#include <SoftwareSerial.h>

#define rxPin 3
#define txPin 4

SoftwareSerial softSerial =  SoftwareSerial(rxPin, txPin);

void setup()  {

  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  softSerial.begin(9600);

  Serial.begin(9600);
}

void loop() {

  int data = softSerial.read();
  Serial.println(data);

}
 
217  Forum 2005-2010 (read only) / Interfacing / Re: Serial read from sensor on: October 28, 2009, 02:33:29 pm
Thanks for the help folks - the codes don't infact resemble the desired ASCII output !!!

If I take out the ATMEGA328 chip - connect the sensor to pin 1 (TX) - open the serial port at BAUD 38400 - I can see the expected data delivered every 3 seconds as documented - this is the format:

  857 ppm
  853 ppm
  850 ppm
  851 ppm
  850 ppm

I have no idea how to access this data via C however - I understand the suggestions made and have tried them - the only one I'm not sure about is how to ask for 10bytes and then print them out in the correct format?  I guess the 10 byte output for 857 ppm in decimal would be:
32 56 53 55 32 112 112 109 13 10 (last two being carriage return and linefeed) - this is nothing like the output I'm getting?
218  Forum 2005-2010 (read only) / Interfacing / Re: Serial read from sensor on: October 28, 2009, 05:08:26 am
Hi,

The output looks like below - I guess I need to somehow group these bytes into 10 and convert to ASSCI?

-1
161
255
49
33
213
49
33
213
49
233
244
49
233
244
49
161
244
219  Forum 2005-2010 (read only) / Interfacing / Re: Serial read from sensor on: October 28, 2009, 03:09:49 am
Thanks Andy,

Here is one try :

Code:
void setup()
{  
  Serial.begin(9600);
}

void loop()
{  
  int data = Serial.read();
  Serial.println(data);
  delay (1000);
}

And another using SoftwareSerial:


Code:
#include <SoftwareSerial.h>

#define rxPin 3
#define txPin 4

SoftwareSerial softSerial =  SoftwareSerial(rxPin, txPin);

void setup()  {
  
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  softSerial.begin(9600);

  Serial.begin(9600);
}

void loop() {
  
  int data = softSerial.read();
  Serial.println(data);
  
  delay (1000);
}
220  Forum 2005-2010 (read only) / Interfacing / Serial read from sensor on: October 27, 2009, 07:16:35 pm
Hi,  Sorry, this is a very basic question.  I am trying to pickup 10 ASCII characters being output from a sensor but not making much progress!!!  I have plugged the sensor TTL TXD into Arduino RX pin and using simple Serial.read() to try and get the string of 10 bytes output at 9600 and Serial.println to output - I guess my code is way off - what would be the best way to do this?
221  Forum 2005-2010 (read only) / Troubleshooting / Re: Sensirion Temp/Humidity sensor library help on: November 20, 2010, 02:19:51 pm
Just a quick note to say thanks for the help posted here, especially tasasaki who cracked the resolution issue which had me foxed for quite some time  smiley

I have this all working nicely now on a Seeeduino Stalker data logger and have posted a small write up along with the Arduino Sketch:

http://www.airsensor.co.uk/component/zoo/item/temperature-humidity-logger.html
222  Forum 2005-2010 (read only) / Development / Temperature display on 8 segment displays on: September 08, 2010, 11:43:43 am
Hi,

I'm still not very good at electronics but would like to be able to build a temperature display for our local outdoor swimming pool which is run for the community by volunteers.  Over the months I have collected various bits of hardware to build one as a gift but I don't think I can do it without help.... would anyone be able to hold my hand and guide me through the circuit and arduino sketch to get it working?

The kit I have is:

Seeeduino 168 board
Dallas 18B20 - 1 wire temperature sensor
74HC165N shift registers x 4
75mm high 8 (10pins) segment LED display units x 4
prototype board
resitors

Anyone interested :-)
223  Forum 2005-2010 (read only) / Development / Re: Large LED display for temperature. on: October 13, 2009, 05:49:54 am
Hehe, now that would be fun :-)
224  Forum 2005-2010 (read only) / Development / Re: Large LED display for temperature. on: October 12, 2009, 10:55:56 am
Hi Mike,

Thanks, even bigger :-)  But like you say not inexpensive - maybe I will ask if they will help out with a charity project :-)

Cheers.
225  Forum 2005-2010 (read only) / Development / Re: Large LED display for temperature. on: October 12, 2009, 10:37:16 am
Hi Programmer - that's perfect - many thanks... wonder if these are available in the UK?.... nothing showing on the Google.
Pages: 1 ... 13 14 [15] 16 17 ... 19