Connecting One Wire Digital Temperature Sensor - DS18B20 to Cobra II

Hi all,

Is it possible to connect a Temperature Sensor - DS18B2( )0 to a FEZ Cobra 2 ? How would i do something like this ? Could i use the extender module ?



@ WimEling

You can find some samples in codeshare:

Hi Wolfgang,

Thnx for your reply i saw does examples but how do you connect to the sensor from for example a FEZ Cobra 2 ? Is this with the extender module ?

You could use an extender, or find the appropriate pin on the headers at the edge of the board. I haven’t used OneWire with NETMF, but it looks like you could use any GPIO pin, you just need to add a pull-up resistor before connecting the sensor.

I’ve used a DS18B20 with an Espruino board, and I just soldered a resistor between 3v3 and the data line, as described here:

I’m sure I could just plug that into a GPIO pin on my Cobra II and use one of the codeshare entries…just haven’t tried it, since I have a Gadgeteer based temp/humidity module, which is simpler to use.

You can use any GPIO pin. With short cable lengths, you’ll probably be ok even without a pullup resistor (although it’s good to have one).

Hi Thnx for the replies and helping me out. I will read the information and try

Hi Simon,

I am using a cobra 2 with g120 chip how would i know what cpu pin to use ?

I have connected my extender module with a one wire tempature sensor to socket one of my cobra and this is the code i am using

   var oneWirebus = new StablePoint.Hardware.OneWire.Bus(GHI.Pins.G120.P0_0);

@ WimEling - This link:

Has pin layouts for all the Gadgeteer socket types. There’s a table of all the possible socket labels, and you can click through to see the pin layout. Most socket types have several pins that are reserved for GPIO, so you should be able to use any of those pins.

Hi DevHammer i saw the website but i still cant figure out how these pins refer to the g120 cpu pins that i need for the stable point code to work.

Have you looked at schematics?

It shows which pin is which.

@ WimEling - here’s an example where P0_25 is used. You should change this to the pin number as you use in your setup.

// create an instance of the OneWire class
var oneWire = new OneWire(new OutputPort(Pin.P0_25, true));
//  use one wire
// Write a byte
// Read a byte
var result =  oneWire.ReadByte();

Ok so if i understand it correctly it is like this. I want to use GPIO of socket 5 of cobra g120. socket 5 is a u socket and a x socket

in the documentation as a U socket pin 6 is GPIO but as a X socket it is an UN socket is this correct ?

Lets go on the schematic tells me that pin 6 of socket 5 is P1.4 so my code should be ?

Is this correct if i want to use the 6 pin of the extender in socket 5 of the G120 ? to use with my one wire ? Or dit i made a mistake somewhere because it does not seem to work

Pin 6 on socket 5 is indeed P1.4.

A socket is just a group of pins. The letter/s that a socket can have are just a set of common pin functions that can coexist together. A socket labelled UX means that both U and X pin functions exist, and a pin that has no function in one type (marked UN) can therefore be defined as the other type.

Now you say it doesn’t work. That now becomes a question of wiring, or possibly how you use the OneWire device. Plus, you have overridden (or are using someone else’s code) “StablePoint”, is there any reason you are not just using generic netmf OneWire ?

Hi all,

It works i went full retard on this one I forgot to solder on the pullup resistor even though Simon told me to do so on the first page. Thanks for the support.