ESP8266 with landns and thermocouple

For stand-alone microprocessors

ESP8266 with landns and thermocouple

Postby Doug Coulter » Mon Nov 07, 2016 5:40 pm

I figured I'd see what all the fuss was about the ESP-8266 out there, so I got a couple of Adafruit's breakout "Huzzah" boards for them. They are nice! As it turns out I had a use for one that justified the work getting up to speed with it - I needed a wifi remote thermocouple. Actually, I need two. One for my woodstove, and one for my "boil that cup of tea" eg temperature rise in a thermos bottle of water from neutron output of the fusor. I'll need some accuracy for that since I'm keeping the power down (still extreme by hobby standards, but "we're onto something" here).

So, I used the arduino IDE, in this case 1.6.12 since I just grabbed one while I was building up a new pi-3 with "pixel" (which is nice) and why not. You add the board url to the file->preferences for this, and bingo, you've got it.
All this, including this post, was done on this pi-3.

One problem I've had in general is "flaky or hard to work with" LAN discovery. I got tired enough of this (not everything wants to run heavyweight dns resolvers and I don't want things fishing outside the lan either) to write landns which is up here elsewhere. It basically works by broadcasting a host's name and IP address periodically to a particular UDP port, and all the machines on the LAN both do this and listen with a "tellme" program that's part of landns, which writes the /etc/hosts file, so everybody can find everybody - and fast. Sometimes it even seems to jumpstart the other junk that's supposed to work but often doesn't too, so I keep doing it.

This sketch does it too, but only the send part, as these are kinda meant to be a slave out there, commanded by some other host that needs to find them - but once you're talking to one, it knows how to talk back anyway (and what tellme does in perl is a real bear in C in one of these anyway).

It also drives a max 31855 thermocouple breakout (Ada again) for type K couples, which it samples once a second and then exponentially averages the results. You send it a t (just one letter is all it takes) on its port 42000 (life, the universe and everything times 1000) and it sends you back a UDP packet containing time since boot in milliseconds, cold junction temperature, and thermocouple temperature (latter two as floats converted to text).
And of course, it announces itself on the network so you can find it. If you have some other way, fine - but at any rate, you'll have to change the PC end code to have the right hostname for your ESP. It appears that despite many almost-sucessful attempts, no one yet knows how to change an ESP 8266 host-name, but they're easy to build inside the ESP - they are ESP_(then the last 3 digits of the MAC address in uppercase hex).
So that's what I do for my "tellem" broadcast.

Of course, to be useful, you need something at the PC end that can send and receive UDP packets. I wrote a little perl script called esptst for that. Yes, I just hardcoded the host-name of the one I'm using. It's short, sweet, dumb, and it works.

The point of all this is, that thermcouple runs can't be long - this is microvolt stuff and the other hardware doesn't like long runs. Nor does the digital stuff be it I2C or SPI, USB, or even RS 232 like long runs. Ah, but wifi is cheap...and power is plentiful and around (it doesn't take much to run one of these) and already nearby. Plus - galvanic isolation in the fusor case is nice.

2016-11-07-173353_1920x1080_scrot.png
testing on a pi-3 with pixel desktop


ESPTherm.ino.bz2
The sketch for the 8266
(2.4 KiB) Downloaded 215 times

esptst.bz2
Perl to talk to the ESP 8266
(597 Bytes) Downloaded 212 times


I'll be going other places with this stuff, but this is a nicely solid base, and one of the apps - measuring the temperature of water inside a thermos jug with minimal disturbance - it's ready for right now. Yes, it was a trick modifying the top of a thermos bottle (ask Bill - it was also a trick even finding one of the old good glass/vacuum ones) - to let in thermocouple wire with a long sneak path and good insulation so external heat doesn't have a way to mess it up.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: ESP8266 with landns and thermocouple

Postby Jerry » Thu Nov 10, 2016 2:41 am

There is a successor to the ESP8266 that should be out any time if not already.

If you use the 31865 instead you can use RTD sensors instead and use 3 or 4 wire configuration and get as long as a run as you want since it measures the resistance of the leads and compensates. They are typically more accurate too. I used the 31865 in a temp sensor system I was designing at my last job.
Jerry
 
Posts: 573
Joined: Sun Jul 18, 2010 12:07 am
Location: Beaverton, OR

Re: ESP8266 with landns and thermocouple

Postby Doug Coulter » Fri Nov 11, 2016 12:42 pm

Thanks for the tip, Jerry. I'll have use for those too, I think.

The deal with the fusor is that one wants to use something with zero (or even negative as with a loaded thermocouple - Peltier effect) heat input to the tested media. If I'm going to "boil that cup of tea" which of course I won't quite do - a degree or two C is what I expect at current max outputs at reasonable run times - I don't want people saying well, your thermistor or RTD or other temp sensor is where that heat came from.
So for that one use, anything that makes heat when measuring is not useful to being a credible test - there will be skeptics who will try to discredit anything they can find a hook for, numerate or not. For everything else, yeah.

Even with the couple, you have to be careful and double-monitor the cold junction temperature because its measured inside that MAX chip which tends to heat up about 2 degrees above ambient.
(and is only moderately well thermally coupled to the TC wire)
Which of course will vary depending on air currents and so forth. This would be true of any thermocouple measuring scheme I'm aware of, other than a chopper op amp and a real ice bath, which probably has its own "gotchas".

Who'da thunk something as "simple" as temperature measurement could have so many complex variables?
This is the low-buck version of a calorimeter...the "real ones" are a bit past my budget and might not work well in this application anyway.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: ESP8266 with landns and thermocouple

Postby Rex Allers » Fri Nov 11, 2016 7:30 pm

Doug,
I'm a long time reader, but this is my first post.

This looks like interesting stuff for very little money. I wasn't aware of the ESP chip or the MAX temp chips. I think I'll look into this stuff sometime soon, too.

So I browsed on the Adafruit and Maxim pages . Seems the step-up chip (and board) from the MAX31855 is the MAX31856. Looking at the datasheets, the 56 claims better accuracy and a lot better resolution, plus support for many thermocouple types, and the Adafruit board is only a few dollars more. So, I'm wondering if you looked at them and if you preferred the 55 for some reason?
Rex Allers
 
Posts: 28
Joined: Mon Sep 05, 2016 8:22 am
Location: San Jose CA

Re: ESP8266 with landns and thermocouple

Postby Doug Coulter » Fri Nov 11, 2016 8:26 pm

Ignorance? Working with what I've got?

Jerry mentioned using RTDs, a different type of sensor (Resistive temperature device). Those, like thermistors, you have to apply some power into to read the resistance (which will create at least a little heat in the thing being measured, though it might be orders magnitude less than what you're measuring, sadly, critics tend to be innumerate when it works to their cause) - and his mention of 3 or 4 wire hookup, like the best most-exotic ohmeters (particularly for lower resistances) use is so the somewhat variable resistance of your wire doesn't mess it up. (Cu has a tempco and thermoelectric potential vs all else, and who knows how long the wiring is....the 4 wire hookup solves all that).

If it also does thermocouples and is more accurate, I'll switch to it, didn't know it existed and that it does that (if it does) but I will look into it - which is why I thanked Jerry for the tip.
I really did not want to get into something so fancy (eg choppers, temp controlled cold junctions) that itself became a suspicious thing to some sorts of people (it is remarkably easy to cheat or fool oneself on this kind of thing).

It's not like any of this is going to be super simple. The chip itself, since it dissipates power, heats itself up some, and is never perfectly thermally coupled to the cold junction. National Semiconductor app notes going back to at least 1978 (I guess I'm dating myself on that, since those were new when I got them) - mention just how hard it is to measure say, the offset of an opamp under even much simpler conditions. (for example, small fractions of a degree across the copper PCB trace and the kovar IC pin from side to side of the same chip can exceed other error sources).

The hope of course is that I can get that water hot enough to not worry too much about the minor error sources. But if you've lurked around here or fusor.net, you know that there are a lot of folks who rightly are claiming that I need some real serious proof of what I think I discovered and it got "leaked" a little prematurely. I thought this might help with that. FWIW, I agree with the skeptics that extraordinary claims require extraordinary proof - I'm working to provide just that. Just "me knowing" doesn't fly outside my house. We are and will continue to be dedicated to real science around here.

Ah, browsing on Adafruit I see the thing, and yes, it's also for thermocouples - not RTDs. Interesting that they mention a "degrees" amount of resolution...semi-meaningless I believe due to the very different curves (mv/c) for different TC types. Though they don't say, I could suppose they mean degrees Kelvin or Centigrade, but they don't say. Obviously I'll have to look into it more. I'm right now awaiting some more ESP8266 thingies. They are indeed nice, and while a better one might be forthcoming, this thing is loafing doing this as is, and the code for this is pretty darned simple stuff.
Once you figure out how to use the wifi stuff libraries, that is, and then even that is pretty simple.

To tell the truth, other errors are going to swamp the errors here, as I mention. Even air currents that aren't quite the same over the cold junction vs the chip internals are going to be bigger than the noise post low-pass filtering, I believe. Using even simple signal processing and the inevitable noise as a source of "dither" I can have whatever precision the floating point format in the chip will alllow over the time periods of interest here -
Say we run this for 24 hours (at least, a week would be much better, and with heat on or off in the lab) to baseline things, and to see the thermal leakage time constants of the themos jug itself.
Then we do say, a 5 minute high output fusor run, see a temperature shift, averaged over some minutes (assuming the thermous has an hours long time constant, which we are trying for), and watch that decay back to ambient. I think that'd be pretty decent proof. Peter Schmelcher who also lurks here and who I talk to on google+ now and then also suggests I do a run with just plain H to have a baseline without neutrons....not a dumb idea at all. And it turns out we have a big bottle of 6 nines pure H in house. It probably has a little D in it, but that shouldn't be a big enough amount to matter to this comparison.

This is how "open source" is supposed to work - I have all these guys helping "hold my head" and yes, I listen. And then I give whatever works the best back to the community and world at large. It's kind of cool, or in this case, hot.

And of course, part of the reason for this forum is to record who thought of what and when so proper credit goes where due.

Thanks!
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: ESP8266 with landns and thermocouple

Postby Doug Coulter » Mon Nov 14, 2016 10:00 am

I did just order a couple of those "better" thermocouple boards along with a host of other stuff. We'll see in a real A-B comparison. I suspect that for this application, where we just want to measure things that move around a few degrees from ambient and don't really care about absolute temperature at all - just the change, that other sources of error and noise will dominate in the fusor calorimeter application (and simply not matter in the woodstove control one). I'll have to put the board and the ESP in a "good" box to control air currents and the "sneak path" of variable ambient temperature along the TC wire into the cold junction, which like all things, isn't perfectly coupled to the inside of the chip. We know the devil is in the details on this kind of thing.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: ESP8266 with landns and thermocouple

Postby Doug Coulter » Fri Nov 18, 2016 5:52 pm

Aaaaaaannnnd....the "better" board is no better, in fact it's conditionally worse.
I haven't done a pure A-B compare yet...
But using Ada's lib and example, it's noisier, and hardware SPI does not work (it does on the 31855 but on just a Huzzah, not a Feather Huzzah as I'm testing with that now).

The max8156 needs a data input, where the 8155 does not (for one thing, to tell it what kind of TC you've got).
The 8156 lib has a couple of odd things in it - one is a (line 116) delay(250); // MEME fix autocalculate based on oversampling
(whatever that means, but no way you want a delay like that inside blocking calls!)
and later, on line 127 : tempfloat /=128.0;
Really? Anyone who knows crap won't do either that delay or a float divide (particularly on a float that was just cast from a nice binary integer)...you'd either shift the integer, or multiply by 1/128, either of which is far faster in almost any CPU. Or heck, back in the day we just bit-fiddled the exponent if it was a power of 2 anyway....doh.

I will get on their case about these and see what I see. Usually if I show them the bug and provide the patch, they put it in their code very quickly. Evidently this wasn't done by their best coder(s) or someone was in far too much hurry to get something out the door.

I do not yet know if the hardware SPI not working on the Feather Huzzah is that version of the board, or something else. It might work fine (it does with the 31855) on a "regular" Huzzah, which are slightly more painful to upload to - you have to push buttons at the right times, which is why I sprung for the extra $ for a Feather for development. I will report on that testing when I get it done.

It's not like software SPI is a dog on this - it's a 500khz clock. But that delay and that nutty divide....make me suspicious of the rest of the programming quality. Not to mention the increased noise (several hundredths of a deg C per sample - it's bigger than even the default Serial.pring() resolution, much less the higher precistion I got "by hand" on the other implementation).

Jury is out on this. Seems this chip heats itself out a couple degrees hotter than ambient as well, as measured by the CJ temp reading - even with the actual end of the thermocouple practically touching the chip, it's telling me it's nearly 2 C colder than the chip.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: ESP8266 with landns and thermocouple

Postby Doug Coulter » Fri Nov 18, 2016 7:06 pm

OK, just completed the A<>B test with another Huzzah, this one not a feather with the extra gadgets. Same result, no hardware SPI. Given that code, I kind of suspect that it's the code, not the SPI hardware, as the max 31855 does work with the hardware. It's simpler, and doesn't need a data-in, but that doesn't seem to be the issue, though it'll take awhile with a scope etc to find the real issue.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA


Return to Embedded software

Who is online

Users browsing this forum: No registered users and 2 guests