ONEWIRE DS18B20 setup for ImpExplorer kit

Hi

(newbie question)

I’ve bought this probe

Now I try to hook it up to my impExplorer board. It’s attached it to pin5 and run the code below, slightly modified from 1WIRE DS18B20 Multiple-device Code - Help!

// code start
// Thermometer electric imp - DS18B20

function onewireReset() {
// Configure UART for 1-Wire RESET timing
ow.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS);
ow.write(0xF0);
ow.flush();
local read = ow.read();
if (read == -1) {
// No UART data at all
server.log(“No circuit connected to UART.”);
return false;
} else if (read == 0xF0) {
// UART RX will read TX if there’s no device connected
server.log(“No 1-Wire devices are present.”);
return false;
} else {
// Switch UART to 1-Wire data speed timing
ow.configure(115200, 8, PARITY_NONE, 1, NO_CTSRTS);
return true;
}
}

ow <- hardware.uart57;
onewireReset();


// code end

However, I only get this…

2017-10-17 11:46:07 +02:00 [Status] Agent restarted: reload.
2017-10-17 11:46:07 +02:00 [Status] Device connected
2017-10-17 11:46:07 +02:00 [Device] No circuit connected to UART.

I guess I’m missing something really obvious.

Can anyone point me in the right direction?
Best regards
Johannes

Johannes …

Have you looked at this yet?
https://electricimp.com/docs/resources/onewire/

Is your sensor similar to the one shown on that description?

Couple of issues here, @nuevo. First, doing OneWire over UART only works if you connect the circuit shown in the document that @mlseim mentioned. You put it between your imp board and your OneWire sensor. Plugging your DS18B20 into the impExplorer board will not do this because the impExplorer doesn’t have that circuit built in.

Second, the impExplorer doesn’t expose the two UART pins that you need. The UART is chosen in this line of the code:

ow <- hardware.uart57;

Doing OneWire via UART requires both uart57’s pins, but pin 7 (RX) is not connected to the A1/D1 Grove port on the impExplorer (it sends data to the LED instead). Unfortunately, the other imp001 UART, uart12 is likewise not fully connected to the A0/D0 Grove port: you have pin 2 (RX) but not pin 1 (TX).

(You can see the impExplorer pin connections in the schematic here)

There’s no easy way around this, unfortunately. Either you build the circuit mentioned above and solder it to the correct SD card slot pins on the impExplorer, and then run jumper wires from the DS18B20’s Grove connector to the circuit. Or you buy yourself a $10 April card (you can use the imp001 you already have) and use that, which will easier. But you still need to build the circuit.

Yes, it’s very fortunate that you can use your same imp001 on an April card instead of the Explorer card. The program stays in the imp, but I think you’ll have to re-blink it because the ID is with the board, in this case, it will be the new April board. I agree that is the better way to go. And besides, you’ll have all of the pins at your disposal without messing around with the Grove stuff. I’ve actually been buying the Imp003 boards from DigiKey (they are only $30) and you get more pins than you can ever need. Footprint-wise, the same size as the April board w/imp plugged in.

Hi guys

Being a newbie I thought the Grove cabling on the impExplorer was just about plug n’ code but that seems not to be the case. I’ll write back when I’ve tried one of / some of your suggestions.

Thanks so much for the input!

To be fair, you probably can plug’n’code with the OneWire sensor you have, but not with the code you mentioned. It’s theoretically possible to control pin 5 as both an input and and an output to do OneWire communications through it, but it’s by no means a simple task as it involves getting the timing of signals just right - not a newbie project.