UVI sensor

edelvall

Member
Hi, I am having issues trying to make this guy (UVI v.2.0) to work with my arduino.

I am running the following code:


########################################################
// This sketch looks for 1-wire devices and
// prints their addresses (serial number) to
// the UART, in a format that is useful in Arduino sketches
// Tutorial:

#include <OneWire.h>

OneWire ds(3); // Connect your 1-wire device to pin 3

void setup(void) {
Serial.begin(9600);
discoverOneWireDevices();
}

void discoverOneWireDevices(void) {
byte i;
byte present = 0;
byte data[12];
byte addr[8];

Serial.print("Looking for 1-Wire devices...\n\r");
while(ds.search(addr)) {
Serial.print("\n\rFound \'1-Wire\' device with address:\n\r");
for( i = 0; i < 8; i++) {
Serial.print("0x");
if (addr < 16) {
Serial.print('0');
}
Serial.print(addr, HEX);
if (i < 7) {
Serial.print(", ");
}
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.print("CRC is not valid!\n");
return;
}
}
Serial.print("\n\r\n\rThat's it.\r\n");
ds.reset_search();
return;
}

void loop(void) {
// nothing to see here
}

########################################################

I put a DS18B20 in parasite mode and I get the following answer:

########################################################
Found '1-Wire' device with address:
0x28, 0xAD, 0x21, 0xCA, 0x02, 0x00, 0x00, 0x50
That's it.
########################################################

I put the UVI module conected to 12 v and screw 2 (DQ) to pin 3 on the arduino boards and I get no result.

Any ideas?

thanks you so much for your help.
 
That should have the latest firmware on it so I am not sure what the problem may be. Can you test it in the OneWireViewer to determine if it is a problem with the UVI or the arduino?
 
Hi,

thanks for your answer.

I am currently using a Mac, also I do not have a usb adapter for iWire devices, I only use my Arduino to interact with them. With the DS18B20 I have no problem, maybe the connection is different? have you tested the code I pasted on my original post?

Any idea where I can get a sample of code that works and a connection diagram so I can test it with a known configuration?

The arduino that I am using is powered via a FTDI / USB adapter and the UV sensor has it own 12v adapter, both grounds are conected in between and the DQ line is connected to the pin 3 of the arduino, I did that to ensure common reference.

If I put only 12v and put an osciloscope to the DQ line, what should I see? any ideas?

thank you so much.

Eduardo
 
We don't have a spec sheet but if the master follows the standard 1-Wire spec then it should work just fine.
 
So far no luck, has anybody else use this sensor with an Arduino board? I am not able to see the number on the on-board chip because it has the moisture coating. It will help me to search for more information. Eric, do you have it?

The only examples I am able to find are always related to the Temperature sensor so tey do not help that much. Played with them a lot du no data cames back.

Thanks
 
The UVI Meter uses a custom 1-Wire chip not any standard chip from Maxim. If there is any way for you to capture an oscilloscope output of the 1-Wire wave from from the arduino board I could try to figure out what is going wrong.

Eric
 
I found that is a PIC 24FJ16GA. Hence I assume it has a custom firmware that enables it as a 1-Wire device. I can use an oscilloscope to get the data. But how do I connect it? just 12 v and probe to the port 2? and check the "boot" process? or should I run my discovery program on the arduino and capture the data? I am using the screw connector instead of the RJ's. I will send you pictures of the oscilloscope screen. Haven't you hear of anybody using it with and Arduino?.

It is correct the way I am connecting them?
12v for UVI - screw 1 and 3
screw 2 to pin 3 on the arduino
ground from UVI to ground on arduino

9 v for Arduino

so basically there are two wires in between them.

Question: why it needs 9 volts? it should work with 5v since the spec on the 24FJ chip is from 2.5 and up...

Thanks,

Ed
 
Ed,

You should be able to supply +5v and have it work fine.

Capture the data on the DQ line when you are running your discovery program on the arduino.

Eric
 
Hi,

I have to apologize first. I made a NEWBIE mistake!!! totally my bad. The sensor works just fine. I forgot to put the pullup resistor on the DQ line. I had to testing boards, one for the DS1820's and other for the UVI. The DS HAD the pullup resistor but the other did not. The fact that you said "follows the standard 1-Wire spec" made me review the wiring from scratch and I "found" the missing resistor.

Now I have a couple of questions: How often should I poll the sensors, temperature and UV? I have found OWFS documentation for EEEF devices that says that Temperature us updated every 30 secs and UVI every 0.5 seconds. I ask because sometimes I get incorrect readings, like 0 C, or 25 UVI (that means that poll was not succesfull according to the documentation).

this is the code I am using. Thanks again for all your help.

##############################################################
#include <OneWire.h>

// constants definition
int pin = 6;
byte address[8] = {0xEE, 0x66, 0x4C, 0xCB, 0x01, 0x08, 0x00, 0x09};

// Variables
byte data[2];
float temp = 0;
float uvi = 0;

OneWire ds(pin); // creates the OneWire object on pin

void setup(void) {
Serial.begin(9600); // enables serial comm

// programa de identificación de sensor
ds.reset_search();
Serial.println("----------------------------------------------");
Serial.println("Starting NEW search");

byte i;
byte addr[8];

// to print de address
ds.search(addr);
for( i = 0; i < 8; i++) {
Serial.print("0x");
if (addr < 16) {
Serial.print('0');
}
Serial.print(addr, HEX);
if (i < 7) {
Serial.print(", ");
}
}
Serial.println(" ");

//to validate the crc
if ( OneWire::crc8( addr, 7) == addr[7]) {
Serial.println("CRC IS valid!");
} else {
Serial.println("CRC is NOT valid!");
}

Serial.println("----------------------------------------------");
delay(1000);
}

void loop(void) {
int HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract; // for the temperature
char buf[20];
byte sensor;
temp = 0;
uvi = 0;

Serial.println("Lectura de Sensor (updated every 30 seconds)");
delay(1000);

// read temp
ds.reset();
ds.select(address);
ds.write(0x21);
for (int i = 0; i < 2; i++) {
data = ds.read();
}

// read uvi
ds.reset();
ds.select(address);
//uvi = 0;
ds.write(0x24);
uvi = ds.read()/10;

// convert temp to something leible
LowByte = data[0];
HighByte = data[1];
TReading = (HighByte << 8) + LowByte;
SignBit = TReading & 0x8000; // test most sig bit
if (SignBit) // negative
{
TReading = (TReading ^ 0xffff) + 1; // 2's comp
}
Tc_100 = (TReading*100/2);

Whole = Tc_100 / 100; // separate off the whole and fractional portions
Fract = Tc_100 % 100;

// print all the temp conversion data
Serial.print("BUF :");
Serial.println(buf);
Serial.print("Sensor :");
Serial.println(sensor);
Serial.print("SignBit:");
Serial.println(SignBit);
Serial.print("Whole :");
Serial.println(Whole);
Serial.print("Fract :");
Serial.println(Fract);

Serial.println("");

// print temp
Serial.print("Temp = ");
Serial.print(Whole);
Serial.print(".");
Serial.print(Fract);
Serial.println(" C");

//print UVI
Serial.print("UVI = ");
Serial.println(uvi,1);
Serial.println("");

}

##############################################################

Ed,
 
This is the serial results. Noticed that sometimes Temp = 0.50 C
Any idea why?

----------------------------------------------
Starting NEW search
0xEE, 0x66, 0x4C, 0xCB, 0x01, 0x08, 0x00, 0x09
CRC IS valid!
----------------------------------------------
Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:-32768
Whole :0
Fract :50

Temp = 0.50 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 25.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:-32768
Whole :0
Fract :50

Temp = 0.50 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 25.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:-32768
Whole :0
Fract :50

Temp = 0.50 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0

Lectura de Sensor (updated every 30 seconds)
BUF :’þ
Sensor :
SignBit:0
Whole :25
Fract :0

Temp = 25.0 C
UVI = 0.0
 
Glad you found your issue.

I'm not sure why the temp is returning 0.05C but if you get a 25 reading for UVI that means that the device was busy internally. I thought that I had mostly gotten rid of that problem. If you get a 25 just wait a second or so and take the reading again.

Eric
 
I think that 5 minutes readings are fine.
For temperature I will read until I get something different than 0.5
For UVI I will read until I get something different that 25

About the 5volts, can I supply those using pins 1 and 2 of the RJ45 connector? 2 for the +5v and 1 for the ground?

thanks again
 
Back
Top