DS18B20

Everything about programming the platform and using the Waspmote API
libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: DS18B20

Post by libelium-dev » Fri Jan 27, 2017 10:45 am

Hi,

DS18B20 sensor don't work with Agriculture PRO sensor board v3.0. You can use the DS18B20 sensor in Agriculture sensor board v3.0 (not PRO). The 4k7 resistor is internally in the board, you don't have to connect the resistor.

Do not worry about the silkscreen of the board. They have the same functionalities, simply the silkscreen was modified to clarify the connections.

Regards

Franky
Posts: 17
Joined: Wed Nov 23, 2016 8:43 am

Re: DS18B20

Post by Franky » Wed Mar 22, 2017 5:32 pm

Hi Support,

Is the issue with the DS18B20 sensor fixed?

We use a P&S Smart Agriculture with Agriculture sensor board v3.0 (not PRO)

IDE 05
API026 and 027 - no difference

- Sensor is plugged in Socket D
- Surrounding temperature (TEMPC) is 15°C
- Batterylevel (BAT) 100%

We get unexplainable measurements (SOILTC -1000.00)



Without resetting the sensor or plaing around with Software
(as you can see in the counting Frame Number) in this database dump,
suddenly it stops generating the correct temperature.
  • 224359 UT-02-SA 613F67057C1054A4 134 22 SOILTC -1000.00 16.03.2017 11:13 0 noraw 1 meshlium0964
    224373 UT-02-SA 613F67057C1054A4 134 22 SOILTC -1000.00 16.03.2017 11:13 0 noraw 1 meshlium0964
    224396 UT-02-SA 613F67057C1054A4 134 23 SOILTC -1000.00 16.03.2017 11:29 0 noraw 1 meshlium0964
    224410 UT-02-SA 613F67057C1054A4 134 23 SOILTC -1000.00 16.03.2017 11:29 0 noraw 1 meshlium0964
    224424 UT-02-SA 613F67057C1054A4 134 23 SOILTC -1000.00 16.03.2017 11:29 0 noraw 1 meshlium0964
    224438 UT-02-SA 613F67057C1054A4 134 23 SOILTC -1000.00 16.03.2017 11:29 0 noraw 1 meshlium0964
    224461 UT-02-SA 613F67057C1054A4 134 24 SOILTC -1000.00 16.03.2017 11:44 0 noraw 1 meshlium0964
    224475 UT-02-SA 613F67057C1054A4 134 24 SOILTC -1000.00 16.03.2017 11:44 0 noraw 1 meshlium0964
    224498 UT-02-SA 613F67057C1054A4 134 25 SOILTC 14.75 16.03.2017 12:00 0 noraw 1 meshlium0964
    224512 UT-02-SA 613F67057C1054A4 134 25 SOILTC 14.75 16.03.2017 12:00 0 noraw 1 meshlium0964
    224526 UT-02-SA 613F67057C1054A4 134 25 SOILTC 14.75 16.03.2017 12:00 0 noraw 1 meshlium0964
    224549 UT-02-SA 613F67057C1054A4 134 26 SOILTC 15.19 16.03.2017 12:16 0 noraw 1 meshlium0964
    224563 UT-02-SA 613F67057C1054A4 134 26 SOILTC 15.19 16.03.2017 12:16 0 noraw 1 meshlium0964

    OK UNTIL

    225204 UT-02-SA 613F67057C1054A4 134 49 SOILTC 14.75 16.03.2017 18:17 0 noraw 1 meshlium0964
    225218 UT-02-SA 613F67057C1054A4 134 49 SOILTC 14.75 16.03.2017 18:17 0 noraw 1 meshlium0964
    225232 UT-02-SA 613F67057C1054A4 134 49 SOILTC 14.75 16.03.2017 18:17 0 noraw 1 meshlium0964
    225246 UT-02-SA 613F67057C1054A4 134 49 SOILTC 14.75 16.03.2017 18:17 0 noraw 1 meshlium0964
    225278 UT-02-SA 613F67057C1054A4 134 50 SOILTC -1000.00 16.03.2017 18:33 0 noraw 1 meshlium0964
    225292 UT-02-SA 613F67057C1054A4 134 50 SOILTC -1000.00 16.03.2017 18:33 0 noraw 1 meshlium0964
    225306 UT-02-SA 613F67057C1054A4 134 50 SOILTC -1000.00 16.03.2017 18:33 0 noraw 1 meshlium0964
    225329 UT-02-SA 613F67057C1054A4 134 51 SOILTC -1000.00 16.03.2017 18:49 0 noraw 1 meshlium0964
    225343 UT-02-SA 613F67057C1054A4 134 51 SOILTC -1000.00 16.03.2017 18:48 0 noraw 1 meshlium0964
    225357 UT-02-SA 613F67057C1054A4 134 52 SOILTC -1000.00 16.03.2017 19:04 0 noraw 1 meshlium0964
    225488 UT-02-SA 613F67057C1054A4 134 64 SOILTC -1000.00 16.03.2017 22:13 0 noraw 1 meshlium0964
    225502 UT-02-SA 613F67057C1054A4 134 64 SOILTC -1000.00 16.03.2017 22:13 0 noraw 1 meshlium0964

Code: Select all

/*  
 *  ------------  [Ag_v30_11] - Frame Class Utility  -------------- 
 *  
 *  Explanation: This is the basic code to create frames with all sensors
 * 	used in the Agriculture Board v30
 *  
 *  Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L. 
 *  http://www.libelium.com 
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  Version:		    3.0
 *  Design:         David Gascón
 *  Implementation: Carlos Bello
 */

#include <WaspXBee868LP.h>
#include <WaspSensorAgr_v30.h>
#include <BME280.h>
#include <WaspFrame.h>

// Destination MAC address
//////////////////////////////////////////
//char RX_ADDRESS[] = "13A20040D76C2F";
//char RX_ADDRESS[] = "0013A2004156A13C"; // P&S UT-01-A
char RX_ADDRESS[] = "0013A2004156A007"; // Meshlium KIT
//////////////////////////////////////////

char node_ID[] = "UT-02-SA";
char* sleepTime = "00:00:15:00";

// define variable for XBee-errorhandling
uint8_t error;
//////////////////////////////////////////

//Instace sensor object

ds18b20Class ds18b20;  // NEW
leafWetnessClass lwSensor;
radiationClass radSensor;
dendrometerClass dendSensor;
pt1000Class pt1000Sensor;
watermarkClass wmSensor1(SOCKET_1);
watermarkClass wmSensor2(SOCKET_2);
watermarkClass wmSensor3(SOCKET_3);
weatherStationClass weather;

//variables to store sensors readings
float temp = 0; // NEW ds18b20
float temperature;
float humidity;
float pressure;
uint8_t wetness;
float UVvalue;
float radiation;
float dendrometer;
float pt1000Temperature;
float watermark1;
float watermark2;
float watermark3;
float anemometer;
float pluviometer1;
float pluviometer2;
float pluviometer3;
uint8_t vane;

// variable to store the number of pending pulses
int pendingPulses;

// variable for Auxilliaries
int   batteryLevel;
char  batteryLevelString[10];
char  BATTERY[4] = "BAT";
char  TIME_STAMP[3] = "TS";

void setup() 
{
  USB.ON();
  USB.println(F("Start program P&S Smart Agriculture UT-02-SA-15Min"));
  
  // Turn on the sensor board
  Agriculture.ON();
  
  // Set the Waspmote ID
  frame.setID(node_ID); 
  xbee868LP.ON();
}

void loop()
{
  /////////////////////////////////////////////
  // 1. Enter sleep mode
  /////////////////////////////////////////////
  Agriculture.sleepAgr(sleepTime, RTC_OFFSET, RTC_ALM1_MODE4, SENSOR_ON, SENS_AGR_PLUVIOMETER);

  /////////////////////////////////////////////
  // 2. Check interruptions
  /////////////////////////////////////////////
  //Check pluviometer interruption
  if( intFlag & PLV_INT)
  {
    USB.println(F("+++ PLV interruption +++"));

    pendingPulses = intArray[PLV_POS];

    USB.print(F("Number of pending pulses:"));
    USB.println( pendingPulses );

    for(int i=0 ; i<pendingPulses; i++)
    {
      // Enter pulse information inside class structure
      weather.storePulse();

      // decrease number of pulses
      intArray[PLV_POS]--;
    }

    // Clear flag
    intFlag &= ~(PLV_INT); 
  }
  
  //Check RTC interruption
  if(intFlag & RTC_INT)
  {
    USB.println(F("+++ RTC interruption +++"));
    
    // switch on sensor board and XBee
    Agriculture.ON();
    xbee868LP.ON();
    
    USB.print(F("Time:"));
    USB.println(RTC.getTime());        

    // measure sensors
    measureSensors();

    // Clear flag
    intFlag &= ~(RTC_INT); 
  }  
}

void measureSensors()
{  

  ///////////////////////////////////////////
  // 3. Read sensors
  ///////////////////////////////////////////  


  
  batteryLevel = PWR.getBatteryLevel();

  
  //It takes several minutes to read all sensors
/*
  // Read the ultraviolet sensor 
  UVvalue = radSensor.readRadiation();
  // Conversion from voltage into umol·m-2·s-1
  radiation = UVvalue / 0.0002;
  // Read the dendrometer sensor 
  //dendrometer = dendSensor.readDendrometer();
  // Read the PT1000 sensor 
  //pt1000Temperature = pt1000Sensor.readPT1000();
*/

  // PS-SA READ SOCKET A
  // Read the anemometer sensor 
  anemometer = weather.readAnemometer();
  // Read the pluviometer sensor 
  pluviometer1 = weather.readPluviometerCurrent();
  pluviometer2 = weather.readPluviometerHour();
  pluviometer3 = weather.readPluviometerDay();
  // Read the vane sensor 
  vane = weather.readVaneDirection();

  
  // PS-SA READ SOCKET B
  // Read the watermark 1 sensor 
  watermark1 = wmSensor1.readWatermark();
  
  // PS-SA READ SOCKET C
  // Read the watermark 2 sensor Siehe "Waspmote_plug_and_sense_technical_guide.pdf" Seite 66 kein Soil Moisture 2
 //  watermark2 = wmSensor2.readWatermark();
  // Read the watermark 3 sensor 
  watermark3 = wmSensor3.readWatermark();  


  //delay(2000);
  // PS-SA READ SOCKET D
  // Read the ds18b20 Soil Temperature sensor
  temp = ds18b20.readDS18b20();   
  //delay(2000);
  
  // PS-SA READ SOCKET E
    // Read the leaf wetness sensor 
  wetness = lwSensor.getLeafWetness();
  
  // PS-SA READ SOCKET F
  // Read the temperature sensor 
  temperature = Agriculture.getTemperature();
  // Read the humidity sensor
  humidity = Agriculture.getHumidity();
  // Read the pressure sensor
  pressure = Agriculture.getPressure();

  
  ///////////////////////////////////////////
  // 4. Create ASCII frame
  /////////////////////////////////////////// 

  // Create new frame (ASCII)
  frame.createFrame(ASCII);

  // add frame fields
  frame.addSensor(SENSOR_STR, "SA-UT-02-MAN");
  frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel());
  
  // Add temperature
  frame.addSensor(SENSOR_AGR_TC, temperature);
  // Add humidity
  frame.addSensor(SENSOR_AGR_HUM, humidity);
  // Add pressure
  frame.addSensor(SENSOR_AGR_PRES, pressure);
  // Add wetness
  frame.addSensor(SENSOR_AGR_LW, wetness);
  // Add radiation NICHT VORHANDEN
  // frame.addSensor(SENSOR_AGR_PAR, radiation);
  // Add dendrometer NICHT VORHANDEN
  // frame.addSensor(SENSOR_AGR_TD, dendrometer);
  // Add watermark 1
  frame.addSensor(SENSOR_AGR_SOIL1, watermark1);
  // Add watermark 2
  // frame.addSensor(SENSOR_AGR_SOIL2, watermark2);
  // Add watermark 3
  frame.addSensor(SENSOR_AGR_SOIL3, watermark3);  
  // Add pluviometer value
  frame.addSensor( SENSOR_AGR_PLV1, pluviometer1 );
  // Add pluviometer value
  frame.addSensor( SENSOR_AGR_PLV2, pluviometer2 );
  // Add pluviometer value
  frame.addSensor( SENSOR_AGR_PLV3, pluviometer3 );
  // Add anemometer value
  frame.addSensor( SENSOR_AGR_ANE, anemometer );
  // Add pluviometer value
  frame.addSensor( SENSOR_AGR_WV, vane );
  // Add DS18B20 soil temperature sensor 
  frame.addSensor( SENSOR_AGR_SOILTC, temp );
  // Add PT1000 Alternative PRO
  // frame.addSensor(SENSOR_AGR_SOILTC, pt1000Temperature);

  // Show the frame
  frame.showFrame();
  ///////////////////////////////////////////
  // 5. Send packet XBee
  ///////////////////////////////////////////  

  // send XBee packet
  error = xbee868LP.send( RX_ADDRESS, frame.buffer, frame.length );   
  
  // check TX flag
  if( error == 0 )
  {
    USB.println(F("send ok"));
    
    // blink green LED
    Utils.blinkGreenLED(500,2);
    
  }
  else 
  {
    USB.println(F("send error"));
    
    // blink red LED
    Utils.blinkRedLED(100,10);
  }

  // wait 2 seconds
  //delay(2000);
  //sequenceNumber++;
}
Attention: There should be an other issue.
As you can see the frames are received by our meshlium multiple times.

I cant explain it, too.

BR
Frank

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

Re: DS18B20

Post by libelium-dev » Thu Mar 23, 2017 3:14 pm

Hi,

Do you get the same issue if you try with the example code to read the DS18B20? Please post the output of this code
http://www.libelium.com/development/was ... r-reading/

Use the API v027 because it fix a bug related this sensor.

Regards

Franky
Posts: 17
Joined: Wed Nov 23, 2016 8:43 am

Re: DS18B20

Post by Franky » Thu Mar 23, 2017 4:23 pm

Sorry, but I posted, we are NOT using the PRO.

BR
Frank

Franky
Posts: 17
Joined: Wed Nov 23, 2016 8:43 am

Re: DS18B20

Post by Franky » Thu Mar 23, 2017 4:28 pm

Franky wrote:Sorry, but I posted, we are NOT using the PRO.

BR
Frank
Sorry - got the wrong Post!

We will check it with the example code!

BR
Frank

Franky
Posts: 17
Joined: Wed Nov 23, 2016 8:43 am

Re: DS18B20

Post by Franky » Tue Mar 28, 2017 11:48 am

As I drove to the P&S-Box, the Sensor was showing correct values with the "old"-software.

I applied the Democode with API027, the sensor showed the same values.
https://goo.gl/photos/RbVsjyquvGMR58xQ7


Hopefully I checked the values reveived again and ... same problem with API027.

The sensor works for some time and than suddenly delivers -1000.
Than some time later ist produces correct values again.

https://goo.gl/photos/rVBLZSxoaLGSFEwh9

Any new idea?
Please keep in mind every single test costs us a 1hour drive.

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

Re: DS18B20

Post by libelium-dev » Thu Mar 30, 2017 9:49 am

Hy Franky,

Sorry for our late reponse,

Do you have more than a DS18B20 to test with? They have the same behavior?

We're going to make some tests to check what it's happening.

Regards

Franky
Posts: 17
Joined: Wed Nov 23, 2016 8:43 am

Re: DS18B20

Post by Franky » Thu Mar 30, 2017 10:08 am

Hi Support,

unfortunately we only have one DS18B20 (@our P&S SA) and one PT1000 (@P&S SA Pro).
For test purposes we have another P&S SA Pro :( .

Any other sensor @the P&S works fine.

BR
Franky

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

Re: DS18B20

Post by libelium-dev » Fri Mar 31, 2017 11:58 am

Hi Franky,

Please test the example code turning ON the board at the beginning of the main loop and turning it OFF after reading the sensor.

You can test the same at your code, also we recommend you turn ON the Xbee just before sending and turning it OFF after sending the values, at this way also you will save some battery.

Regards.

gdmd86
Posts: 3
Joined: Sun Apr 23, 2017 7:54 pm

Re: DS18B20

Post by gdmd86 » Fri May 19, 2017 12:03 am

Hi everybody,

Are the wiring.c issues still present on the latest API?? We are using V1.5 with Dallas DS18B20 sensors and we haven't been able to obtain a read different from -1000. A sensor problem is discarded since we can read these sensors using Arduino & Raspberry Pi without any issues.

Thanks for any info you can provide us.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest