1-Wire on the imp

There have been a fair few forum discussions asking how to get the 1-Wire bus working on the imp, so I thought I’d try it out and condense the various suggestions and tips into a single developer resource document. I did, and it’s done:

Implementing a simple 1-Wire bus on the imp

Thanks are due to @theo and other Forum contributors whose work helped in the compilation of this article.

Don’t forget, there are more Electric Imp articles and guides at the Dev Center

Great work! @smittytone, @theo and others.

A few people have PM’d me asking about my luck in implementing this tutorial. I just wanted to say that it works great! If it doesn’t work for you, keep trying. Ask questions. It will work.

Most recent versions of my EI and Maxim temperature loggers are simple. An enclosure, Imp, battery, a few terminal blocks and cables glands…and I insert the cat5. After blinkup and a code paste in the IDE, I then see all of the temp sensors in Xively immediately. Kinda cool.

Pics attached.

The main question has been about maximum cable length. Honestly, I don’t know. The most I have done is two cat5 cables, each with about a dozen sensors. Cable length can be pretty long. 100’ easy. Maybe even a few hundred combined feet with multiple cables. I think keeping cable length similar when using multiple cables is a good strategy though. 1-wire (maxim) wiring layouts are notoriously finicky about topology structure.

The nice thing about the 1-wire ds18b20 sensors is that they are easy to find in waterproof version (stainless steel housing) for a few bucks each on ebay. However, if reliability is an issue, you might want to spend $10 each or so from a dedicated “industrial”-type supplier. To save cost I have been using the “cheapies” on ebay.

In theory (as the tutorial states), you could have dozens of sensors. No matter how many cat5 cables and sensors you use, it all goes through the same two imp pins. In my case I use the C3V0 from Makedeck (002) and UART57. I wire multiple terminal blocks together on a simple board and then connect any cat5 cables needed.

I needed to modify the code from the example to send data to Xively. The code I have for Xively automatically names the sensors and posts them online without me naming each individually (got it from Tom’s Tempbug, I think?), so with lots of sensors that’s cool. Downside is the names are all “Maximtemp_1”, “Maximtemp_2”, and so on. I have been meaning to ask the forum about how to read the array of data and assign more logical names, but for now it works.

The tutorial is based on a “homemade” (cheap) BUS to replicate the 1-wire…using just a resistor and a diode! Don’t forget how amazing that is! Years ago I was instrumenting houses with these sensors using much more expensive proprietary equipment, so this EI Maxim 1-wire stuff is really exciting to me. I love equipment diagnostics and being limited to 5-7 temp sensors (with just EI 001 and 002, no other chips or breakouts) was a bit frustrating.

Anyway, this is just a plug for the Tutorial. A special thanks to everyone who made it happen.

The 1-wire device discussion tweaked my interest. Thanks for that! I saw this today:

And then I saw this … although it’s $75 … but it has relays built-in and all channels can be set for inputs or outputs …


Looks like I’m buying another Imp [sigh]

The chip seems to be a bit rare and only avaliable in smd, but combined with a breakoutboard and a “ebay” relay board, you could make a output only version for less than half. :slight_smile:

hello again i built the 1 wire using the imp-001 and everything worked fine except my april’s pin 1 connection is lousy. so i switched to the imp-002 and my temperature is returning 0.00 degrees C

Hard to tell, but it doesn’t look to me like you’ve got the sensor connected to the power line. Connect your red wire from the imp002’s 3v3 to one of the empty slots on board line 13.

So…I’m a bit confused as to Dallas 1-wire and Maxim 1-wire. Are they compatible (i.e. the same) or not?

@ctmorrisonhvacsp, Maxim is the new official term. Dallas was bought out. As a result people use both terms interchangeably…Dallas or Maxim.

A little background:

Thanks for the clarification @solarishot! I had seemed to recall someone claiming they’re different, but all evidence I could find indicated they were one in the same. I appreciate your feedback! If someone were looking for digital input (think dry contact closure compatible), is there a recognized source for 1-wire devices?

If someone were looking for digital input (think dry contact closure compatible), is there a recognized source for 1-wire devices?


That Maxim 1-wire I/O chip does both Input and Output. View their PDF spec sheet and see example of pushbutton (dry contact) inputs on about page 30.

I have not used this chip before, but I’m really thinking about experimenting. There’s just too many other “Honey Do” items on my list this Summer.

Thanks for the recommendation! This certainly looks like it would do the trick.

i added the 3.3v to the sensor. guess i had too many hours on the bench lol. thank you smittytone. I bought the adafruit 7 segment LED and it seems to be doa is there a way to test this?

i added code from the MeetingMinder and finally lit up my display. but i cannot get this example to work correctly http://electricimp.com/docs/resources/onewire/it displays the temperature in my log but the display is not functioning.