Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

1-Wire DS18B20 Programming Errors


  • Please log in to reply
4 replies to this topic

#1 escallanio

escallanio

    New Member

  • Members
  • Pip
  • 9 posts
  • LocationSydney

Posted 29 April 2014 - 12:49 PM

Hi,

 

I am work on constrained protocol having NetDuino platform (v4.2.2). I added OneWireBus.cs and DS18B20.CS to my server for temperature monitoring of the room. However, i am getting errors

 

Error1:

 

'Observe_Server_Netduino.Program' does not contain a definition for '_oneWire' and no extension method '_oneWire' accepting a first argument of type 'Observe_Server_Netduino.Program' could be found (are you missing a using directive or an assembly reference?) E:\CoAP Implementation\Observing Resources\Observe-Server-Netduino\Observe-Server-Netduino\Program.cs 169 26 Observe-Server-Netduino
 
 
 

 Error 2:

 
The type or namespace name 'DS18B20' could not be found (are you missing a using directive or an assembly reference?) E:\CoAP Implementation\Observing Resources\Observe-Server-Netduino\Observe-Server-Netduino\Program.cs 170 17 Observe-Server-Netduino
 
 
I am using drivers from  
 
Funny thing is they work perfectly fine as standalone. but when i integrate them into my server program, i am getting the above errors. Any Idea?
 
escallanio
 
 


#2 escallanio

escallanio

    New Member

  • Members
  • Pip
  • 9 posts
  • LocationSydney

Posted 29 April 2014 - 01:06 PM

Ah,

 

Been able to solve the first error (Error 1). I was missing 

private OneWire _oneWire = null;

 

However, still i am getting error 2. :(



#3 kerk-akker

kerk-akker

    Member

  • Members
  • PipPip
  • 12 posts
  • LocationNetherlands

Posted 29 April 2014 - 01:09 PM

Hi,

 

I am doing also temp monitoring with DS18B20. It works fine. It seems you are missing a "using statement" or a Reference entry. I only discovered with long wires ( about 20 metres ) I can only add two sensors on one port. As such I have defined multiple ports as one wire bus. I am currently running 7 sensors on 4 GPIO's. Working fine.

 

Br,

 

Arno 



#4 SomeGuy

SomeGuy

    Member

  • Members
  • PipPip
  • 10 posts

Posted 21 March 2015 - 01:20 PM

hi!

 

I just got started with this temp thing & I got some errors too ...

I'm using  the same sensor with a NetduinoPlus 1 & the v4.2 of the firmeware ...

I've found this post in which the guy explains how to wire the sensor and he has put a simple example of code that he has used base on the same classes you've mentioned (Mr. escallanio ) , the OneWireBus.cs & the DS18B20.cs

this's the post : http://bradsduino.bl...support-my.html .

 

I did exactly the  same thing but i get this error at the OneWireBus (at the " var devs = ow.FindAllDevices();" line)

 

....

public enum Family : byte
        {
            Unknown = 0x00,
            DS18S20 = 0x10,
            DS18B20 = 0x28,
        }

        public static Device[] Scan(OneWire ow, params Family[] includeFamilies)
        {
            var list = new ArrayList();
            var all  = false;
            var devs = ow.FindAllDevices();

            if( includeFamilies != null )
            {
                foreach( var f in includeFamilies )
                {
                    if( f == Family.Unknown )
                        all = true;
                }
            }
.....

C# throws an exception and highlight the line above

 

some help please!!



#5 KiwiDev

KiwiDev

    Advanced Member

  • Members
  • PipPipPip
  • 100 posts
  • LocationNew Zealand

Posted 25 March 2015 - 08:30 AM

Hi SomeGuy,

 

I used the bradsduino code as the basis for the sample below which I use for testing my sensors

 

 

using System;
using System.Threading;
using Microsoft.SPOT;
using SecretLabs.NETMF.Hardware.Netduino;
using ThreelnDotOrg.NETMF.Hardware;
 
....

 

public class TemperatureDS18B20Demo
   {
      public static DS18B20 outletTemperature;
 
      public static void Main()
      {
         Timer outletTimer;
 
         outletTemperature = new DS18B20(Pins.GPIO_PIN_D2);
 
         outletTimer = new Timer(timerCallbackExhaustTemperature, null, 5000, 30000);
 
         Thread.Sleep(Timeout.Infinite);
      }
 
      
      
      static void timerCallbackExhaustTemperature(object state)
      {
         try
         {
            float temperature = outletTemperature.ConvertAndReadTemperature();
 
            Debug.Print("Temperature " + temperature.ToString("F2"));
         }
         catch (Exception ex)
         {
            Debug.Print("ERROR: failed with error: " + ex.Message);
         }
      }
   }

 

I find that if I use D1 (shared with serial port) it doesn't work.  I use Seeedstudio plug-n-play Grove Kit so this maybe a feature of my hardware

 

http://www.seeedstud...sor-p-1235.html

http://www.seeedstud...-V2-p-1378.html

 

What is the exception you are getting?

 

 

B: blog.devmobile.co.nz
T: @KiwiBryn?





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.