iDRY Vacuum Kilns

Sponsors:

Kiln temp and humidity logger using the Raspberry Pi platform

Started by btulloh, December 31, 2017, 02:05:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

btulloh

That's useful information Gene.  Thanks for weighing in.
HM126

scsmith42

Peterson 10" WPF with 65' of track
Smith - Gallagher dedicated slabber
Tom's 3638D Baker band mill
and a mix of log handling heavy equipment.

GeneWengert-WoodDoc

I have been asked to explain this paragraph from above in more detail...
"Note that very precise MC is not usually required in lumber drying.  Further, most of the time, precise temperatures and humidity is not required.  Further, almost all defects occur at high MCs, so fancy controls for air dried lumber are a waste of money as they do NOT improve drying quality or time."

To run a kiln using moisture content, we use the average of the wettest half of the samples.  Even then, the schedule does not use decimal points when referring to MC, so 1/2% MC will work.  It is only in getting the final MC that we do try to be more accurate sometimes.

The schedule temperature for air dried can be plus or minus one or two degrees and the humidity within 5% RH during much of the schedule.  We are somewhat concerned about overdrying, so we do try to get the correct humidity at the final stages, within a few percent RH.

The schedules were developed in the early 1950s.  At that time they were usually used with equipment that measured within 1/2 degree F.  Billions and maybe trillions of board feet were dried successfully with that equipment.  Obviously a safety factor was built into the schedule, recognizing the limits of the equipment.  Today, with better controls, we know what temperature we have to 1/10 F.  So, the old schedules can be accelerated a small bit with better controls without jeopardizing quality.  However, most operations do not appreciate a gain if the lumber is ready a few hours earlier.
Gene - Author of articles in Sawmill & Woodlot and books: Drying Hardwood Lumber; VA Tech Solar Kiln; Sawing Edging & Trimming Hardwood Lumber. And more

ChugiakTinkerer

I'm successful connecting all my sensors up and running basic tests.  Next up is some actual programming, not the monkey-see examples I've used so far.  The DS18B20 were giving me fits originally, even after replacing my resistor with a 4.7k one.  It turns out my little expansion board was causing the problem.  I ditched it and wired directly to the Pi and now all is well.
Woodland Mills HM130

btulloh

Good going, CT.

What other sensors did you get besides the DS18B20's?

I'm thinking there must be a humidity sensor out there that will stand up pretty well, but I haven't taken the time to look around yet.  If the wb thermo can be avoided, that's not a bad thing.  For now I'm installing both the 18B20's and DHT22's in the kiln.  I'll use the DHT22's for humidity and see how long they last.  In the mean time I can work on the wick and wb setup OR find some more robust humidity sensors.

I've been working on the installation, but haven't been able to spend a lot of time on it.  Finding ways to mount and shade the sensors takes a little time and creativity.  I still haven't come up with the box I'm going to use to house the electronics.  It's all progressing, but there other things on the agenda right now.

The software is pretty much done.  Right now it's set up to send 8 data fields up to Thingspeak and also store data locally in a csv file.  It will start a new file every Sunday morning at 5:00 a.m., so there will one week's data in each file.  The recording interval is set for 15 minutes, although that can be changed easily.  15 minute intervals seems about right - we'll see.  There's no problem making the sample interval shorter or longer.
HM126

ChugiakTinkerer

I have a BME280 that I purchased from SparkFun.  It's on a little breakout board, not a package that seems like it would hold up well.  I got that because it provides barometric pressure as well as temp and humidity.

The 1-wire device is real easy to use and code for.  Configuring your system for it is a bit more of a hassle but the coding is nothing.  The BME280 on the other hand is easier to set up the system but the code is a mess.  I downloaded a python script to read it and am using that, but I haven't even attempted to understand it.  I'll delve into it later if the need arises.

Here's the code I started from to read the DS18B20:
[spoiler]def read_temp_raw():
   f = open(device_file, 'r')
   lines = f.readlines()                                   # read the device details
   f.close()
   return lines

def read_temp():
   lines = read_temp_raw()
   while lines[0].strip()[-3:] != 'YES':                   # ignore first line
      time.sleep(0.2)
      lines = read_temp_raw()
   equals_pos = lines[1].find('t=')                        # find temperature in the details
   if equals_pos != -1:
      temp_string = lines[1][equals_pos+2:]
      temp_c = float(temp_string) / 1000.0                 # convert to Celsius
      temp_f = temp_c * 9.0 / 5.0 + 32.0                   # convert to Fahrenheit
      return temp_c, temp_f

[/spoiler]

And here's the code I used for the reading the BME280.  Granted, I am reading three sensors here, so some additional complexity is expected.

[spoiler]def readBME280All(addr=DEVICE):
  # Register Addresses
  REG_DATA = 0xF7
  REG_CONTROL = 0xF4
  REG_CONFIG  = 0xF5

  REG_CONTROL_HUM = 0xF2
  REG_HUM_MSB = 0xFD
  REG_HUM_LSB = 0xFE

  # Oversample setting - page 27
  OVERSAMPLE_TEMP = 2
  OVERSAMPLE_PRES = 2
  MODE = 1

  # Oversample setting for humidity register - page 26
  OVERSAMPLE_HUM = 2
  bus.write_byte_data(addr, REG_CONTROL_HUM, OVERSAMPLE_HUM)

  control = OVERSAMPLE_TEMP<<5 | OVERSAMPLE_PRES<<2 | MODE
  bus.write_byte_data(addr, REG_CONTROL, control)

  # Read blocks of calibration data from EEPROM
  # See Page 22 data sheet
  cal1 = bus.read_i2c_block_data(addr, 0x88, 24)
  cal2 = bus.read_i2c_block_data(addr, 0xA1, 1)
  cal3 = bus.read_i2c_block_data(addr, 0xE1, 7)

  # Convert byte data to word values
  dig_T1 = getUShort(cal1, 0)
  dig_T2 = getShort(cal1, 2)
  dig_T3 = getShort(cal1, 4)

  dig_P1 = getUShort(cal1, 6)
  dig_P2 = getShort(cal1, 8)
  dig_P3 = getShort(cal1, 10)
  dig_P4 = getShort(cal1, 12)
  dig_P5 = getShort(cal1, 14)
  dig_P6 = getShort(cal1, 16)
  dig_P7 = getShort(cal1, 18)
  dig_P8 = getShort(cal1, 20)
  dig_P9 = getShort(cal1, 22)

  dig_H1 = getUChar(cal2, 0)
  dig_H2 = getShort(cal3, 0)
  dig_H3 = getUChar(cal3, 2)

  dig_H4 = getChar(cal3, 3)
  dig_H4 = (dig_H4 << 24) >> 20
  dig_H4 = dig_H4 | (getChar(cal3, 4) & 0x0F)

  dig_H5 = getChar(cal3, 5)
  dig_H5 = (dig_H5 << 24) >> 20
  dig_H5 = dig_H5 | (getUChar(cal3, 4) >> 4 & 0x0F)

  dig_H6 = getChar(cal3, 6)

  # Wait in ms (Datasheet Appendix B: Measurement time and current calculation)
  wait_time = 1.25 + (2.3 * OVERSAMPLE_TEMP) + ((2.3 * OVERSAMPLE_PRES) + 0.575) + ((2.3 * OVERSAMPLE_HUM)+0.575)
  time.sleep(wait_time/1000)  # Wait the required time 

  # Read temperature/pressure/humidity
  data = bus.read_i2c_block_data(addr, REG_DATA, 8)
  pres_raw = (data[0] << 12) | (data[1] << 4) | (data[2] >> 4)
  temp_raw = (data[3] << 12) | (data[4] << 4) | (data[5] >> 4)
  hum_raw = (data[6] << 8) | data[7]

  #Refine temperature
  var1 = ((((temp_raw>>3)-(dig_T1<<1)))*(dig_T2)) >> 11
  var2 = (((((temp_raw>>4) - (dig_T1)) * ((temp_raw>>4) - (dig_T1))) >> 12) * (dig_T3)) >> 14
  t_fine = var1+var2
  temperature = float(((t_fine * 5) + 128) >> 8);

  # Refine pressure and adjust for temperature
  var1 = t_fine / 2.0 - 64000.0
  var2 = var1 * var1 * dig_P6 / 32768.0
  var2 = var2 + var1 * dig_P5 * 2.0
  var2 = var2 / 4.0 + dig_P4 * 65536.0
  var1 = (dig_P3 * var1 * var1 / 524288.0 + dig_P2 * var1) / 524288.0
  var1 = (1.0 + var1 / 32768.0) * dig_P1
  if var1 == 0:
    pressure=0
  else:
    pressure = 1048576.0 - pres_raw
    pressure = ((pressure - var2 / 4096.0) * 6250.0) / var1
    var1 = dig_P9 * pressure * pressure / 2147483648.0
    var2 = pressure * dig_P8 / 32768.0
    pressure = pressure + (var1 + var2 + dig_P7) / 16.0

  # Refine humidity
  humidity = t_fine - 76800.0
  humidity = (hum_raw - (dig_H4 * 64.0 + dig_H5 / 16384.0 * humidity)) * (dig_H2 / 65536.0 * (1.0 + dig_H6 / 67108864.0 * humidity * (1.0 + dig_H3 / 67108864.0 * humidity)))
  humidity = humidity * (1.0 - dig_H1 * humidity / 524288.0)
  if humidity > 100:
    humidity = 100
  elif humidity < 0:
    humidity = 0

  return temperature/100.0,pressure/100.0,humidity

[/spoiler]

This is my one and only I2C device, but I think the complexity lies with the device and not the use of the I2C bus.  It's not a big deal, once the routine is written it's good to go.  But it has the feel of a kludge.
Woodland Mills HM130

ChugiakTinkerer

Somewhere in my internet travels I saw a humidity sensor chip that was packaged on a small board that was protected with a shrink-wrap cover.  A small hole in the shrink-wrap exposed the surface of the sensor itself.  I'm not able to find that now.  >:(

There's a good article on the different types of humidity sensors at https://www.sensorsmag.com/components/choosing-a-humidity-sensor-a-review-three-technologies
Woodland Mills HM130

GeneWengert-WoodDoc

Chugiak...the article you cited is 18 years old.  I am curious if any advances or changes in humidity measurement have been made since then, or is this still state-of-the-art-the-art information.
Gene - Author of articles in Sawmill & Woodlot and books: Drying Hardwood Lumber; VA Tech Solar Kiln; Sawing Edging & Trimming Hardwood Lumber. And more

ChugiakTinkerer

Thanks for pointing that out, I hadn't noticed the date.  I don't claim a lick of expertise in this area, but I doubt there's been any fundamental breakthroughs, at least that have gotten to the production stage.  Advancements have probably been in the realm of power draw, smaller and more sensitive sensors, improved operating temps, etc.  Evolutionary rather than revolutionary changes, I suspect.  But I am married, so that's proof right there that I am wrong on just about anything on a regular basis.   :laugh:
Woodland Mills HM130

PA_Walnut

We run by an adage an old woodworker taught me, which is now almost gospel:

I own my own small piece of the world on an 8 acre plot on the side of a mountain with walnut, hickory, ash and spruce.
LT40HD Wide 35HP Diesel
Peterson Dedicated Wide Slabber
Kubota M62 Tractor/Backhoe
WoodMizer KD250 Kiln
Northland 800 Kiln

btulloh

Good point, PA_Walnut.  Perfect is the enemy of done, also.  Since this is just an experimental thing, I've stopped worrying about some of the long-term issues and I'm just going with what I've got on hand.  If a few $3 sensors get consumed - oh well.  Some of those issues can be dealt with if and when they come up.  I'm using plain old cat5 cable and hard wiring the sensors that I have and we'll see how they fare.  It's not going to be difficult to deal with any failures that occur.  Besides, this thing might get retired after a year or so.  Collecting this data is just a matter of curiosity for me.  It's not necessary to do all this just to run the kiln and dry lumber.  We may even find some robust humidity sensors along the way.  There are many industrial processes being monitored and controlled with various sensors.  This has been figured out already somewhere.  I'm installing a couple temp sensors that can be turned into wet bulb sensors, but the mechanics of that can be figured out later, if at all.  The DHT22 sensors will work for now - maybe forever.  The BME280 that Chugiak is using is probably a better choice for measuring humidity.  We'll find out about all that.  It's easy enough to change some of this after the thing is up and running.  The only thing slowing me down right now is lack of time to sort out some of the installation issues, like finding the right size enclosure for the electronics at the right price.
HM126

Crusarius

instead of thinking of it as temporary I would think of it as a stepping stone to a fully automatic kiln that automatically adjusts the fans and vents to keep it at optimal drying conditions.

ChugiakTinkerer

Sensors are all connected and reading accurately, as far as I can tell.  Here's a screen capture of my test program.  The Pi and sensors are still sitting on my desk and should report the same temperature, although there is a slight draft from the window in my office so some variation is expected.  Still, for any sort of accurate measurements each sensor should be individually calibrated.



A couple things I've figured out regarding the BME280:

  • The heart of the board is a Bosch BME280 multi-sensor chip that has an operating range of -40 to 85 C.

  • I can download and install the AdaFruit python library and that would clean up my code considerably.  It might also make it easier to access any additional features of the chip, if they exist.

  • The I2C controller is accessed at its internal address of 0x76 or 0x77.  That is controlled by a jumper on the underside of the breakout board.  That limits any system to two Bosch BME280 chips at a time.
Regarding the DS18B20 temp sensors:

  • I'm using encased waterproof versions of the Dallas Semiconductor DS18B20.

  • Each sensor has a unique serial number that is its address on the 1-Wire bus.

  • The sensors can be connected in parallel such that there is no prior limit to how many probes you connect.

  • Serial numbers are polled by the system, but if the probes are used for different functions you must know the serial number for each and make sure it's placed correctly.

  • I'm beginning to appreciate the elegance of the Dallas 1-Wire bus.  I'm sure I'll soon learn the shortcomings for it too, but for limited sensors and low bandwidth monitoring it seems well suited.

On wet bulb calculations of relative humidity:

  • There is no easy way to do this.  For a hot humid and corrosive environment, old school could end up being the most reliable.
  • There needs to be sufficient airflow over the wet bulb to ensure maximal evaporation.
  • In a kiln with fans running, that would probably be adequate.
  • If fans aren't running, or for desktop prototyping, a small computer case fan would suffice.
  • Calculating RH using a lookup table is cumbersome to code, but quite doable.

https://www.youtube.com/watch?v=mB9VTmQ5V4o

Edit to add:  I've been thinking about the potential for corrosion on the BME280 breakout board.  When I get to the stage that I am ready to install a remote weather station I will try coating the board in silicone.  The chip itself would need to be exposed to the environment, so a little blutack tape over that will protect it while I apply the silicone.  That's my thinking at least.  The housing for the chip will be exposed, allowing measurement of the humidity.  I don't think the rest of the components on the board will generate any heat to worry about.
Woodland Mills HM130

ChugiakTinkerer

I've set aside wet bulb measurement and the DS18B20 temperature sensors while I focus on local network reporting.  I started out doing my monitoring with a Python script and running that on a timer.  I installed sqlite3 and can easily dump records into a table.  My next challenge was to enable a local web service for monitoring from my desktop.

The Raspbian operating system comes with Node-Red installed, which is a visual programming tool well suited for remote data monitoring.  It makes use of Javascript and uses workflows to pass messages from one node to the next.  It's a different paradigm from what I'm used to so it's taking some time to learn new methods.

One of the problems I had was the difference in timestamps between Python, sqlite3, and Node-Red.  I bypassed that issue by having Node-Red do all the work.  I've dropped Python completely and am polling the BME280 with Node-Red, then passing the resulting data to a function that splits the temp, humidity, and pressure into three different messages.  The messages are then sent to dashboard nodes for display on the dashboard web page.

I've got the Pi sitting on my back deck sampling every 5 minutes.  Currently temps are around 10 F so the relative humidity reading is wacky.  I'm still working on understanding if it's just a wonky sensor or if the high relative humidity is because the air can hold so little water.  Here''s a snapshot from a few minutes ago...



Edit to add: Temp is in Celsius, relative humidity is percent, and pressure is in millibars.
Woodland Mills HM130

btulloh

Very cool, CT.  That's a nice looking dashboard.

I saw NodeRed on the programming tools menu, but I had no idea what it was.  I'm an embedded systems guy, so I tend to go in that direction.  I better investigate.  Besides, Jack Nicholson didn't fare well after ordering a Node Red in A Few Good Men.  I can't handle the truth!

Anyway, that looks good.  Can something like fan control be handled from NodeRed?  I don't have time to investigate right now.  I am neck deep in a bunch of things unrelated to any of this.   My logger is all done, except for the dashboard, and I'm working on installing and wiring it whenever I have a few minutes to put into it.  I must say that wiring and housing issues are not that interesting, but they are what's next for me.  By the way - I'm using hot-melt glue instead of silicon for weather-proofing little sensor pcbs.  I find it easier than silicon.  Just another means to the same end.

One of the data points I'm really interested in seeing when this thing gets installed is the difference between kiln rH and the rH figure that would be the result of raising outside air to the temp of the kiln.  That delta would show how much of the kiln rH is contributed by the evaporation of the moisture in the stack.  One of the challenges for the ambient air sensor is getting them far enough away from the kiln so the heat and escaping humidity doesn't spoil the reading.  It doesn't sound like a big problem, but in reality it complicates things a bit.  Like everything, the devil is in the detail.
HM126

ChugiakTinkerer

I think Node Red was created for IoT and home automation, so it sure ought to be able to handle a little solar kiln management.  There are nodes for the GPIO on the Pi, so reading and writing pin status ought to be a snap.  Plus there is the module for the BME280 and probably every other major sensor.

For your ambient relative humidity, one option would be another Pi/Arduino and an accurate humidity sensor.  Or, would a reading from a nearby weather station be close enough for your needs?  Just a question that occurred to me, I have no clue how lumpy moisture distribution might be.
Woodland Mills HM130

btulloh

Seems like a perfect fit. I'm glad you brought it up. I wish I had known about it before I finished. I might still find a place to use it.

A second pi or arduino might be easier than running a wire. The sensor just needs to be away from the kiln so it's not getting heat and moisture readings affected by the kiln. Not far really. Doesn't need to be super accurate. Have you looked at some of the guidelines for placing outdoor sensors? Useful info. Noaa has guidelines. Siemens has a good white paper on all sorts of placement guidelines.

In the end, this only needs to be as accurate as the user wants it to be. I've found that temperature varies a lot around my place.  If I wanted to skew my temperature readings for a desired outcome it would be pretty easy.
HM126

btulloh

An aspirated housing seems to be the easiest way to deal with outdoor sensors. That's what the inexpensive weather stations use. Lots of examples out there mzde with pvc pipe and old cpu fans.
HM126

ChugiakTinkerer

Finally found what looks like a good enclosure without breaking the bank.

https://www.amazon.com/Orbit-57095-Weather-Resistant-Outdoor-Mounted-Controller/dp/B000VYGMF2

It has a panel inside as well as a GFCI outlet.  Will have to get one and see how it checks out.
Woodland Mills HM130

btulloh

I'd call that a perfect solution CT.  Good find.  That never turned up in my searches.  FWIW, Home Depot carries that same box for 32$ and it's in stock at the closest HD.  https://www.homedepot.com/p/Orbit-Outdoor-Timer-Box-57095/100158884  I'm going to pick one up today.  I had a box I was going to use, but it wasn't well suited to the task.  This looks perfect.

I've been completely tied up for the last week or so and unable to do anything on the installation.  This week I'll have a little time here and there to work on it and the box you found will get me over the hump.
HM126

ChugiakTinkerer

Credit weathernick at WxForum.net for that enclosure.  He's got a very detailed Pi build for his weather station.  If you haven't read that thread yet, it may have some helpful info for your kiln monitoring.

I'm jealous that you can have instant gratification at Home Depot.  There are none of those stocked in Alaska.  I've been stuck at home the last few weekends, as temperatures at the property are uncomfortably cold.  Currently -36 F out there so I'm staying home instead and working on chores and my Pi project.

I'm not sure if it's a good fit, but have you looked at WeeWX?  It looks to be a decent way of displaying your sensor data.  I'm going to dig into it when I get a chance, as it may do most of the things I need for my weather station.
Woodland Mills HM130

btulloh

I was very surprised that it turned up at HD and in stock no less.  It's probably because 50% (or more) of the homes around here have sprinkler systems.  I guess our weather is just a wee bit different than yours  ;).  I just got home with the newly acquired box.  It's going to work just fine.  Hopefully I can start fitting it up and get this thing installed.  I'm still pretty tied up on other things, but I have some cracks here and there.  The kiln is sitting empty until I get this thing installed, so I'd like to put it back in service.  The days are getting longer here now even though February is usually our worst weather.  I think maybe we got some of our  bad weather out of the way early, but the ground hog says there's still plenty of time for ugly weather.

I'll take a look at those sites.  Sounds like some interesting and useful stuff.

Stay warm.  -36 is not part of my DNA, and I don't expect that to change anytime soon.
HM126

btulloh

Seems like nothing's been going on with this thread lately. That's because I've been tied with a lot of mundane other things, but it looks like I'll be able to get the stuff installed this week hopefully.  There were lots of little details to work out with sensor housings and sunshades and wiring but most of that has been worked out.  Stay tuned.
HM126

btulloh

I finally got most of the installation completed.  The only item left is the sensor for ambient temp and rH.  It's a little more of a challenge to locate it correctly, since it needs to be far enough away from the kiln to avoid the heat island generated by the kiln.  Right now my kiln is located in the backyard in order to have proper sun exposure and reasonable access to a/c.  I plan to move it, but until then I don't want to create a big eye sore right near the house so can't just stick poles in the ground anywhere I want.

The Orbit sprinkler timer box worked pretty well as a housing for the thing.  A pretty good value all in all.  (Thanks for finding that Chugiak.)



The relays for fan control are under the mounting panel, so the high voltage is safely isolated from the low voltage wiring out front.



It's not the prettiest wiring job, but that's ok by me.  I wasn't trying to win a beauty contest, and done beats pretty right now.  It's been hard enough to carve out a little time to get this installed and functioning.

The kiln is empty right now, so the data is meaningless.  I plan to put a load in the next few days.  I will start putting the data up on ThingSpeak.com where it can be viewed easily.  More importantly, I am also storing the data locally in a file which will be useful for detailed analysis.

I'll post some data displays and links to the data files when they become relevant.


HM126

btulloh

Yesterday was the first sunny day since installing the logger.  Even though the kiln is empty, the data is interesting.  The weather and my schedule for the next week or so will probably keep me from putting a load in the kiln. 



 

The drop in temperature at 12:00 occurred when I opened the vents about 30%.  Before that, the vents were 99% closed.  The change in temp at 2:50 occurred when I turned on the fans with the vents still at 30% open. ??   Since there was no load in the kiln, the baffle was up and it was just a big chamber full of hot air.  This is not really indicative of typical operation, but interesting - to me at least.

HM126

Thank You Sponsors!