EmonTH w/Multiple external DS18B20 AND DS18B20 in DHT22 socket Sketch

I have a bunch of EmonTHs with the DS18B20 in the DHT22 socket and I want to add multiple external DS18B20s as well.

 

I can find sketches for a DS18B20 in the DHT22 socket and I can find sketches for multiple external DS18B20s, but not a sketch that combines both. 

Does something like that exist? I am not a programmer, so my feeble attempts to mash the two together never made it past the compiling stage. 

 

Thanks

Robert Wall's picture

Re: EmonTH w/Multiple external DS18B20 AND DS18B20 in DHT22 socket Sketch

Why do you think you need to use DS18B20s in both places? How many do you need, and how are they wired (star or in-line)? 

rjsears's picture

Re: EmonTH w/Multiple external DS18B20 AND DS18B20 in DHT22 socket Sketch

Hi Robert - 

I need three temp sensors on one particular emonTH. I have an onboard DS18B20 sensor already installed in the DHT22 socket (ordered from OEM this way) and I have two external DS18B20s connected via the terminal block (both of them connected directly to the terminal block) in a star configuration.

I guess I could just add a third external DS18B20 to the emonTH but I was hoping to use the temp sensor already onboard.

I have one sketch that recognizes the DS18B20 in the DHT22 socket as well as a sketch that allows me to see multiple external DS18B20s, but I cannot get a sketch to work that does both, and that was what I was looking for on this particular emonTH. 

I was just wondering if someone already had a sketch to do that....

 

Thanks (again) :-)

Robert Wall's picture

Re: EmonTH w/Multiple external DS18B20 AND DS18B20 in DHT22 socket Sketch

I don't know of a sketch, but it should not be difficult to combine the two. But by far the easiest solution - as you can't successfully do the sketch - would be to add the third sensor to the terminal block.

pb66's picture

Re: EmonTH w/Multiple external DS18B20 AND DS18B20 in DHT22 socket Sketch

Could you not just bridge the on-board temp data pin and the external temp data pin on the emonTH and use the multiple external sketch with the on-board code looking to an unused pin so it thinks there is no on-board sensor and 3 external despite the physical location? 

Adding a short piece of wire and changing a pin number might be an easy enough route. 

Paul

rjsears's picture

Re: EmonTH w/Multiple external DS18B20 AND DS18B20 in DHT22 socket Sketch

Well, it is not as pretty as some code out there, but I finally managed to get a sketch working with two external DS1820B sensor and another DS1820B in the DHT22 socket.

 

Since I am not a programmer, this took a long time for me to figure out, but it was fin and in the end, it works great. 

 

I have the serial set to 38400 because for some reason below that I get partial garbage out of the IDE. Just a line or two, but still annoying. I also have it set for (°F) as I am in the US.

Maybe this will help someone else out there!

Robert Wall's picture

Re: EmonTH w/Multiple external DS18B20 AND DS18B20 in DHT22 socket Sketch

You probably needed 38400 Baud because the serial output didn't complete in time - it's interrupt-driven and if another interrupt comes along, the timing goes awry. Adding a small delay after the offending "Serial.print" usually does the trick.

rjsears's picture

Re: EmonTH w/Multiple external DS18B20 AND DS18B20 in DHT22 socket Sketch

Thanks Robert - 

Adjusting the delay will give me some tinkering to do!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.