temperature sensor ds18b20 error reading with analog input

Everything about programming the platform and using the Waspmote API
Post Reply
nlatin
Posts: 9
Joined: Sat Sep 06, 2014 11:39 am

temperature sensor ds18b20 error reading with analog input

Post by nlatin » Fri Oct 17, 2014 1:18 pm

I have two sensors, one ds18b20 (one wire) and other UV sensor (analog output).
ds18b20 is connected to DIGITAL8, and UV sensor to ANALOG1.

Running this code:

Code: Select all

int UV_analog;
float temp = 0;

void setup() {   
    PWR.setSensorPower(SENS_5V,SENS_ON); 
    USB.ON();
}

void loop() {
  //reading analog UV sensor
  analogRead(ANALOG1);
  delay(10);
  UV_analog = analogRead(ANALOG1);
  USB.print(F("UV analog sensor output: "));
  USB.print(UV_analog);
  USB.println(F(" ADC"));
  //Reading temp sensor
  temp = Utils.readTempDS1820(DIGITAL8);
  USB.print(F("DS1820 Temperature: "));
  USB.print(temp);
  USB.println(F(" degrees"));
  delay(1000);
}
Everything is ok if there is no analog value.
After some UV light (analog reading) I am getting temperature error reading (-1000).
Here is the output:
UV analog sensor output: 0 ADC
DS1820 Temperature: 25.8125000000 degrees
UV analog sensor output: 0 ADC
DS1820 Temperature: 25.8125000000 degrees
UV analog sensor output: 0 ADC
DS1820 Temperature: 25.8125000000 degrees
UV analog sensor output: 0 ADC
DS1820 Temperature: 25.8125000000 degrees

UV analog sensor output: 16 ADC
DS1820 Temperature: -1000.0000000000 degrees
UV analog sensor output: 12 ADC
DS1820 Temperature: -1000.0000000000 degrees
UV analog sensor output: 12 ADC
DS1820 Temperature: -1000.0000000000 degrees
UV analog sensor output: 19 ADC
DS1820 Temperature: -1000.0000000000 degrees


Is there any solution for this problem?

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: temperature sensor ds18b20 error reading with analog inp

Post by libelium-dev » Fri Oct 17, 2014 2:20 pm

Hi,

are you taking into account the issue mentioned on this topic?

http://www.libelium.com/forum/viewtopic ... b20#p41895

We think this is the problem you have.

nlatin
Posts: 9
Joined: Sat Sep 06, 2014 11:39 am

Re: temperature sensor ds18b20 error reading with analog inp

Post by nlatin » Sat Oct 18, 2014 1:20 pm

I will test solution from post you sugested.

Thanks

camma
Posts: 6
Joined: Thu May 04, 2017 2:08 pm

Re: temperature sensor ds18b20 error reading with analog input

Post by camma » Mon Feb 05, 2018 7:16 am

I using waspmote API 0.30 for reading DS18B20 sensor. the sketch used is
http://www.libelium.com/development/was ... g-ds18b20/
The value returned always is -1000
The sensor is plugged to waspmote in this mode: red (3.3V) black (GND), yellow (DIGITAL8). I used a 4K7 resistor.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: temperature sensor ds18b20 error reading with analog input

Post by libelium-dev » Mon Feb 05, 2018 9:02 am

Hi,

Did you set the 4K7 resistor between red and write wires? Could you share with us some images of your devices? You can use some free service like google drive, dropbox, imageshack, etc. to share the images.

Regards

camma
Posts: 6
Joined: Thu May 04, 2017 2:08 pm

Re: temperature sensor ds18b20 error reading with analog input

Post by camma » Mon Feb 05, 2018 12:03 pm

Hello,

my waspmote version is 1.5

should i post in IoT waspmote 1.5?

regards

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: temperature sensor ds18b20 error reading with analog input

Post by libelium-dev » Tue Feb 06, 2018 8:37 am

Hi,

Don't worry, you can continue la conversion in this topic

Regards

camma
Posts: 6
Joined: Thu May 04, 2017 2:08 pm

Re: temperature sensor ds18b20 error reading with analog input

Post by camma » Tue Feb 06, 2018 2:51 pm

Hi,

this is the photo of the 'circuit'

https://drive.google.com/open?id=1en8dX ... 8Q-xY1yp-d

regards

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: temperature sensor ds18b20 error reading with analog input

Post by libelium-dev » Wed Feb 07, 2018 8:57 am

Hi,

Please try to make the following modifications inside WaspOneWire library. Replace this function

Code: Select all

uint8_t WaspOneWire::read_bit(void)
{
	IO_REG_TYPE mask=bitmask;
	volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg;
	uint8_t r;

	noInterrupts();
	DIRECT_MODE_OUTPUT(reg, mask);
	DIRECT_WRITE_LOW(reg, mask);	
	delayMicroseconds(1);
	DIRECT_MODE_INPUT(reg, mask);	// let pin float, pull up will raise
	delayMicroseconds(5);
	r = DIRECT_READ(reg, mask);
	interrupts();
	delayMicroseconds(50);
	return r;
}
with

Code: Select all

uint8_t WaspOneWire::read_bit(void)
{
	IO_REG_TYPE mask=bitmask;
	volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg;
	uint8_t r;

	noInterrupts();
	DIRECT_MODE_OUTPUT(reg, mask);
	DIRECT_WRITE_LOW(reg, mask);
	delayMicroseconds(2);
	DIRECT_MODE_INPUT(reg, mask);	// let pin float, pull up will raise
	delayMicroseconds(7);
	r = DIRECT_READ(reg, mask);
	interrupts();
	delayMicroseconds(45);
	return r;
}
Does it work?

Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest