I would use weights of 10g, 5g, 2g and 1g as the easiest solution.
In the diagram below, 1H means 1g of herb, 1W means 1g of weight and so on. In the diagram, we see how we can measure 1g to 10g of herbs. We only need this diagram because if we have more than 10g of herbs, we can always take away multiples of 10g away from the "pile" of herb and measure the remainder. An example to illustrate this is 24g of herbs: Take a pile of herb and measure 10g on the scale. Take that 10g of herb away from the main "pile" and we have 14g of herb left in the main "pile". Do the same thing again to take away another 10g of herb so we have 4g of herb left in the main "pile". So think of it as base 10. So technically this does not limit to 1 to 40g of herb, it can be done to any amount of whole number. And this is exactly the extension of the problem. Another extension we can do is using only 3 weights to measure 1 to 40g.
The thought I have when I was doing this is the monetary system we have: $10, $5, $2 and $1. These bills or coins allow us to come up with a lot of different combinations of amount.
This just keeps going until we reach 20g so I am not showing all of them. If we go over 20g, we use the same concept as the first method. Measure 20H and move it aside and measure the weight of the remaining "pile". For example, 24g: measure 20g and remove it from main "pile" then measure the remaining 4g. Note that some of the weights, we have to measure them twice in order to be sure of the weights.


