OpenEMC - An EmonTH mod for woodworkers

Hey Guys and Gals,

We’ve been using Open Energy Monitoring components for the past few months for power monitoring and love its open source flexibility.  We recently received an EmonTH to monitor Temp and Humidity values in our workshop and have developed a useful modification to the firmware.

As any woodworker knows, wood expands and contracts with changes in moisture content.  Most people notice this when normally free-swinging doors begin to stick in the humid summer.  However, moisture content can be a tricky thing to measure accurately.  There are 2-prong probes that measure MC by testing the wood’s electrical resistance, but the calibration varies depending on the density of the species and the probes damage the wood because they have to be firmly pressed into the surface.  They are also not very accurate.  You can use an RF based meter but these are tricky to use with thinner pieces of wood like veneers and the meters themselves are expensive.   Furthermore, neither one of these methods allow for any data logging to record the MC over time.

​Wood that I’ve bought at the local lumber yard can range anywhere from 9% to 18% Moisture Content, depending on where it’s stored and if it got rained on.  The ideal target MC for a finished wood product depends largely on the application but also on the region where the product will be installed or used.   For example, a lawn chair in Florida should be made at 11% MC while cabinetry in Nevada might be better suited at closer to 6% MC.  Failure to anticipate these changes in expansion and contraction can result in failed joints, poorly fitted drawers, and warped or cracked surfaces.

It has become my preferred method to measure the MC of the wood indirectly by recording the environmental conditions.   Depending on the thickness of the wood, it will eventually reach an equilibrium moisture content based a complex relationship between temperature and humidity.  This is most commonly used in kiln drying, where charts allow the operator to follow a prescribed schedule to drive the wood towards its target MC.

I do this in my shop using a more passive method.  I have a sealed box with a wireless temp/humidity sensor inside and one located outside the shop.  If it’s a hot/dry day, I’ll take the box outside and open it up.  Sometimes the outside EMC can be as low as 3.5%  (on a 90F day with 15% relative humidity).   A 3.5% EMC means that if the wood stayed in those conditions for a long enough period of time, it would eventually reach a moisture content of 3.5%.  By strategically opening and closing this box I can get my wood to within 0.1% of my target EMC which in my application is about 7.8%.

I’ve been using the environmental EMC method since before I received the EmonTH, using standard wireless weather station TH sensors.  However, this required me to frequently enter the T/H values into a calculator, and then manually log the results.

The relationship between temperature, humidity, and the resulting EMC is too complex to do with simple rules of thumb or head math.  Here’s the formula for calculating the Equilibrium Moisture Content based on Temp and Humidity.  As you can see it’s quite complex:

M = 1800/W [ KH/(1-KH) + (K1KH + 2K1K2K2H2) / (1 + K1KH + K1K2K2H2)

Soon after receiving the EmonTH, we realized the opportunity for this little device to perform these calculations automatically.  We did this by editing the Arduino sketch to include the formula and to output the EMC value as a third “virtual” channel that could be logged directly to EmonCMS.  This is a major improvement to our workflow, because for the first time we can visually see the environmental conditions that are affecting our wood materials.

We think this will be very useful for the following applications:

  • Operating a solar drying kiln, that uses sunlight to dry green wood instead of burning coal or oil. 
  • Logging the ambient conditions of a wood shop or factory space for quality control purposes, such as warehouses that store wood flooring products or for contractors that are equalizing wood flooring on site prior to installation.  Improper MC control in flooring products is the number one cause of loss and can result in thousands of dollars of damage if installed at the wrong MC.
  • Using a sealed box to stabilize smaller pieces of wood that need highly accurate MC, such as pen blanks, wood knife handles (often called scales), or thin veneers used for inlay or marquetry.  
  • Restoration purposes like old houses or antique furniture.
  • Museums that display delicate wood items to keep them from cracking and falling apart.
  • Book repositories.  We imagine that EMC has a similar effect on paper and that keeping it stable and controlled is critical for valuable collections.

We have posted our modified code to GitHub and it’s immediately available for public use.   Our summer engineering intern Andy will be writing a follow up post with a technical description of how we achieved this mod, officially known as OpenEMC.

Please use, share, modify as needed, and enjoy!  

-Bert Green

Founder, SolarMill
“we make things with sunshine”

SolarMill's picture

Re: OpenEMC - An EmonTH mod for woodworkers


This is a follow up to the previous post about OpenEMC - our modification of the emonTH arduino sketch to output Equilibrium Moisture Content, aka EMC data.  If you haven't read the previous post, definitely start there to learn about why EMC values are needed, and how an automated EMC sensor can help improve your processes.

I'm Andy the intern, and my task for the week was to implement this system, or more specifically:

  • fork the emonTH repository and set up a branch for our EMC code
  • modify the emonTH software to emit an EMC value along with Temperature and Humidity during each measurement
  • test this on our emonTH module and emonCMS website
  • publish our code publicly on GitHub and offer it back to OpenEnergyMonitor
  • write this article explaining how it was it done

Getting Started

We started by forking the emonTH repo in GitHub, creating a private copy of the repo that is properly linked to the parent.  This linkage is crucial not just for giving credit where credit's due, but also for being able to follow upstream changes.  If the upstream code is updated, we need to be able to pull that update into our private code, and forking does this.  Next we created a branch called "emc" to give a label to the changes we were making.


First, we created a function to do the EMC calculation from measured temperature and humidity values.  Many thanks to the captivatingly-named Wood Equilibrium Moisture Content Table and Calculator ( for their excellent tutorial on this calculation.

float EMCfromTH(float T, float H) { 
  // formula from this page: 
  H /= 100; 
  float Tsquared = T * T; 
  float W = 330 + 0.452 * T + 0.00415 * Tsquared; 
  float K = 0.791 + 0.000463 * T - 0.000000844 * Tsquared; 
  float Ka = 6.34 + 0.000775 * T - 0.0000935 * Tsquared; 
  float Kb = 1.09 + 0.0284 * T - 0.0000904 * Tsquared; 
  float M = 1800 / W * ( K * H / (1 - K * H) 
          + (Ka * K * H + 2 * Ka * Kb * K * K * H * H) 
          / (1 + Ka * K * H + Ka * Kb * K * K * H * H)); 
  return M; 

That formula expects temperature to be in Fahrenheit, so we added this helper function to do the conversion:

float CtoF(float C) { 
  return C * 1.8 + 32.0; 

Now that we have a working calculator, we need to connect this to the emonTH system, to feed temperature and humidity into it with each cycle, and get EMC out of it to transmit to emonCMS.  That means two things: modifying the data structure that holds the output variables, and inserting a call to EMCfromTH into each cycle.  Modifying the data structure is as easy as add adding an extra variable:

typedef struct { 
  int temp; 
  int temp_external; 
  int humidity; 
  int battery; 
  int emc; 
} Payload; 
Payload emonth;

Finally, the line that makes it all work:

emonth.emc = EMCfromTH(CtoF(emonth.temp / 10.0), emonth.humidity / 10.0) * 10.0;


In addition to the code highlighted above, we added debugging output.   By running the emonTH while connected to a serial port, we can see a stream of messages about the status of its systems, and the calculations it's performing.

Once we were able to verify that our calculated values matched the numbers on the Wood Equilibrium Moisture Content Table and Calculator Website, and that our emonTH+EMC was communicating reliably with the CMS website, we pushed our code back to github and invited the OpenEnergyMonitor folks to include the code in their system.


Full source code is available here, on the SolarMill GitHub page:

We'll be following this post to answer any questions or to fix any bugs.

-Andy Fabian

Engineering Intern, SolarMill
“we make things with sunshine”

Paul Reed's picture

Re: OpenEMC - An EmonTH mod for woodworkers

An interesting post guys, and very well structured. I didn't know that the moisture content of wood was so technical! but having read your post and some of the links I can see why it's so important.

One thing I didn't understand was why a sealed box, and why take it outside and open it on hot day's? Wouldn't it just be sufficient to monitor the temperature & humidity (and thereby calculate the EMC) by having the sensors permanently sited in the same environment as the wood?

Also, as the EMC fluctuates according to the temp & humidity, how will you determine the actual fixed figure, is it averaged?


SolarMill's picture

Re: OpenEMC - An EmonTH mod for woodworkers

The box curing method is specific to small pieces that need high accuracy.  Say for example my piece of wood is currently at 12% MC and I need to get it to 7% MC.  My shop might be at 9% EMC, which is better than 12% but not as dry as my target condition of 7.  Now if it's 4% EMC outside, that will drive me towards my target condition faster, so I take my box outside and open it up.  However, as the sun sets and the temperature drops, the humidity rises, and so does the EMC, maybe as high as 14% which is WORSE than when I started!   So I have to watch the values and as soon at the ambient EMC rises above my target I close the box, locking in the drier air.    More than likely my wood has still not fully reached my target.  So over a couple hours the closed box will creep up in EMC to equalize with what my wood is currently at.   Let's say it's at 9% now.  I'm almost there.   After a couple of sessions using this method, I can reach my target MC.  

After I reach my target MC, I keep it in the closed box until I need to shape/machine the wood.   

This curing method is just one way of using EMC.  There are several other applications, like knowing when the wood in a solar kiln has reached peak cure.  (you can see the graph flat line when no more drying is happening).

SolarMill's picture

Re: OpenEMC - An EmonTH mod for woodworkers

That's only for a situation when the wood is not as dry as I want it to be.  If it's already at the target condition, then you're correct, nothing needs to be done but to monitor the environment.   

Paul Reed's picture

Re: OpenEMC - An EmonTH mod for woodworkers

From your first post I hadn't realised that the wood was in the sealed box as well as the sensor! 
This looks like a fairly labour intensive process, couldn't you monitor & control the environment where the wood is stored, rather than relying on prevailing environmental conditions? e.g. use a Dehumidifier on a controlled cycle?
That way you could almost set the desired MC, and just sit back and wait for it to reach target.
Power costs could be minimal, especially if solar powered.


SolarMill's picture

Re: OpenEMC - An EmonTH mod for woodworkers

Which is easier: heating/cooling and dehumidifying a 2,000sq/ft workshop or opening and closing a well sealed weatherproof box?  It's not really that labor intensive.  I do it in the background as I'm working on other things.  It's as simple as "oh look, it's really dry today, i'm gonna set the box outside"  [which takes 30sec tops] and then later in the day "Hey look, the sun's setting, I need to close the box and bring it in."   I do this occasionally over the course of a several weeks to maintain my inventory of ~80 iPhone case blanks (which are 3.5" x 12" pieces of THIN wood that get milled into our iPhone cases).  Since the blanks are so thin, they are easily influenced by daily swings, but likewise can be easily adjusted with passive, energy free methods.

A normal business might do as you suggest and install dehumidifiers and AC units, but to understand why I choose to simply open and close a box you'd have to understand our business philosophy.  We operate completely off the grid on solar power.   We have limited energy available, certainly not enough to waste on running a dehumidifier or a heating element for a kiln.   But also take into account the wood is already very dry.  This is usually just to stabilize and equalize a box of small parts from 10%MC to 7.5% MC, which is only a few percentage points.  We're not doing the initial drying cycle like this.  However, those last few points are critical for our application and this simple method gets us better results than just leaving the wood laying around in the moist air of an unconditioned concrete wood shop.  This is mostly about consistency and control, and working with a material at a known MC gives repeatable results!  (these wood blanks get CNC milled to tolerances of 3thou)

Paul Reed's picture

Re: OpenEMC - An EmonTH mod for woodworkers

I never suggested 'heating/cooling and dehumidifying a 2,000sq/ft workshop! I suggested controlling the environment where your wood is stored - you're 'sealed box' which I presume is fairly minimal capacity.

I suppose, it's whatever works for you.


SolarMill's picture

Re: OpenEMC - An EmonTH mod for woodworkers

I reread your post and I see that now.  We're pretty much on the same page, it's just that I don't have enough room in my box to squeeze in a dehumidifier and prefer to use a method that requires no additional electricity usage.  Regardless of the method, you still need to know the EMC of the controlled space to know at what MC the wood will eventually equalize.   Before this OpenEMC mod, we used weather sensors and had to put the data in manually.  Now it's automatic!  

Picture of our drying box attached.   Fancy new sensor on the left, dumb old sensor on the right.

Bill Thomson's picture

Re: OpenEMC - An EmonTH mod for woodworkers

it's just that I don't have enough room in my box to squeeze in a dehumidifier.

Hi Bert,

Would desiccant crystals work? Say, on a day that's not sunny and dry, but you'd like to get your project material to target MC with minimal delay.





pb66's picture

Re: OpenEMC - An EmonTH mod for woodworkers

Interesting project thanks for sharing.

Could the next step be to use that data to automate the opening/closing using mini linear actuators for a self regulating version ??


glyn.hudson's picture

Re: OpenEMC - An EmonTH mod for woodworkers

This is great! Thanks for sharing. I would love to do a blog post on the OpenEnergyMonitor blog about this. Have you got some more photos showing the hardware in action and some general cool shots of your workshop? Happy to include links to your website / social page. Would you be happy for me to copy and paste your post above into a blog post, include some photos and link back to this thread. Great application we would never have thought of! This is open-source at it's best :-D 

Keep up the good work.

SolarMill's picture

Re: OpenEMC - An EmonTH mod for woodworkers

Bill - Desiccant crystals might work ok, but there's a big difference between removing minor vapors in a sealed plastic bag with steel parts that don't absorb water and the actual drying of 20 lbs of wood which requires the removal of several milliliters of water.  It would require a lot of crystals.  I think it would be a little like trying to use desiccants to dry damp socks.   However, it might be useful in keeping already dried wood in a slightly drier state.  The other issue is that we don't want to over-dry our wood.   We want to hit a set point and keep it there.  When the wood gets below 5%MC, it's gets too dry to machine and is prone to splintering.  

Paul-  YES!   We love this idea and had been thinking about something similar.  Right now our needs are small enough that it's not worth it to fully automate but with OpenEMC used as part of a control loop, you could very easily set an Arduino up with something similar to PID control to open and close vents on a sealed box for drying, tempering, and equalizing batches of wood product.  This could scale up larger to operate as the control system for a solar kiln.   It could also be used for storage warehouses.  Maybe the manager of a lumber or flooring warehouse gets an alert when the environment the product is stored in exceeds a certain set point, and to turn on a dehumidifier or fan to protect the product.

Glyn-  Thanks for included our mods into the main development!  We're very excited to be able to contribute to the awesome work your team is doing.

Everyone else-  A lot of the discussion so far has focused on our wood drying box method, but I think the potential is much broader than this.   For example, tobacco humidors need to be kept between 65-74% RH at a temperature below 68F.  However, people can be very particular about the specific moisture of their fine cigars.   If kept at a constant temp of 64°F, the difference between 65%RH and 74%RH is the difference between 12.1%MC and 14.3%MC ***(see footnote).  Wouldn't it be easier to know the actual MC we're trying to achieve instead of guessing based on humidity?  And yet, the average hygrometer gives us the separate values without telling us what this really means in terms of MC.  I'm not even into tobacco, I'm just using this as an example where people are looking for a specific outcome but using indirect means to achieve it.

Flooring installers may want to temporarily place a meter in rooms where a concrete slab has been recently poured.  Especially if the space is unconditioned, the T&H may swing widely, but by watching the EMC graph and looking for the line to flatten out they can know when the concrete is fully cured and no longer releasing large amounts of moisture.  At that point it's ready for installation but before then you're looking for trouble.

Cabinet makers might want to monitor their general work area, if that also happens to be the space they store their lumber, to better understand where their wood is in terms of MC.  If they know their shop is on the dry end and their project is shipping to rainforest, they might want to consider giving more allowance for the wood to expand.  If the shop is on the wetter end and the project is going somewhere dry, they might want their tenons to be a little extra tight, knowing they will shrink.  If you really want to be scientific about it, you can look up the species and the grain orientation (flat or plain sawn) and calculate the amount of movement.  There's a LOT of data out there on this.

The general public might be interested in how EMC can better represent the general feeling of the weather.  We all know how miserable a hot humid day is, but it's good validation when you can see it change from 3%EMC to 18%EMC over just a few hours as a storm rolls in.

The point about EMC is it gives a better representation of what's happening to wood products than temperature and humidity can tell us independently of each other.

We're looking forward to seeing how other people can use this

Bert and Andy

***Tobacco leaves, and leaves in general, have a higher cellulose to lignin ratio and the formula for EMC is based on a higher lignin ratio, the dominant fiber in solid woods.  Even so, it seems to be a really close approximation.  Also, from what I've read you don't want the tobacco to ever go above a certain temperature regardless of the humidity, because at 77°F tobacco beetle eggs hatch.  I guess there's always a chance they are in the product and you keep it cool to prevent any possible damage.

glyn.hudson's picture

Re: OpenEMC - An EmonTH mod for woodworkers

Blog post is up!

Let me know if you want me to make any corrections.

SolarMill's picture

Re: OpenEMC - An EmonTH mod for woodworkers

The blog looks awesome!  Thanks for the shout out.   We're working on other OpenEnergyMonitor extensions/mods as well.  Currently we're trying to get a good DC monitoring setup going.   We've seen on the forum several other people working on this.  We're using an arduino running a modified sketch connected to a 5 channel hall effect board.   The hardest part of course is monitoring voltages.  We have a 48v battery bank.  It seems that measuring 48v DC is trickier than measuring 120v AC.  At least with AC you can use a step down transformer.   With DC the most common solution appears to be a voltage divider.  Either the resistor values are spec'd too low and a lot of power is wasted or the resistors are spec'd too high and the impedance of the measuring circuit starts to affect the accuracy.

One post I saw recently solved this problem by using the data output from their inverters.  I like this solution, but also recognize there's a need for people without such hardware to be able to monitor their battery voltages.  Our setup is completely off grid, and it's clear that most of the intent behind the OpenEmon ecosystem is grid tied with a focus on import/export so someone out there needs to hash out the off-grid details.

When we get our version worked out, we'll be doing a thorough write-up on it as well.  Always happy to contribute to a community that's passionate about clean energy.


Ian Eagland's picture

Re: OpenEMC - An EmonTH mod for woodworkers


I am no electronics engineer but when I faced this problem on 24V DC I am sure I found a reference to using an opamp to solve the impedance problem. I built a circuit some time ago and as far as I know it is working perfectly, the battery voltage in emon tracks the Inverter reading close enough for me.



Robert Wall's picture

Re: OpenEMC - An EmonTH mod for woodworkers

I don't understand where the problem is - unless it is one of isolation (which can be a very serious issue, and where it gets tricky). For an isolated voltage transducer, you might like to look at the LEM LV 25-P, which was found by dominator99, see

It does have a fairly high current draw on the DC side, requiring 10 mA to operate, but at 48 V that implies only ½W of dissipated power in the dropper resistor, which is not all that onerous.

SolarMill's picture

Re: OpenEMC - An EmonTH mod for woodworkers

We've made great progress the past two weeks figuring out the details of a voltage monitoring device we're planning to build.  Our final solution is very much like what Ian Eagland suggested, which is a voltage divider to an opamp.   We considered Robert Wall's suggestion of the LEM LV 25-P, but deemed it to be too expensive.   We'll be starting a new thread for this topic in the coming days.

Back to the Original Post-  Has anyone else out there tried our EMC sketch?   Have you found it to be stable and  functional?  
We're excited to see what applications this may find.   What have people been using it for?



Comment viewing options

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