You could try this, but I would encourage you to try "smart humidity fan" app. With your way, if a storm comes through, or depending upon humidity in the house, your fan might not come on or it might not turn off. I have had the fan turn on when I opened the windows on a mild, but humid day using a simple percentage.
With the app, it watches for a change in humidity, and once it rises at a certain rate, the fan turns on. It watches for the humidity to fall a certain amount, and starts a countdown timer, and then after the time turns off. It also turns the fan off after X minutes if you turn the fan on manually.