[Release] HubDuino v1.1.9 - Hubitat to Arduino / ESP8266 / ESP32 / ThingShield Integration (ST_Anything)

@ogiewon I will continue to praise your efforts for this project, I have found so many ways to make use of this, many thanks!!

I recently changed wifi networks at home so I needed to update a d1 mini board for a PWM project I implemented years ago and never changed since(Link to post). When using it last i noticed that when setting the level around 25% the SSR I had attached to would just be full power not "dimmed" like it was between 0-99 (like the PWM project specifies).

After a bunch of digging and AI help I found that the ESP8266 D1 Mini boards I am using changed the PWM resolution on the core board from 0-1023 to 0-255, effectively making anything above 255 at 100% (I think I am explaining this correctly!?).

The Fix
To fix this I had to modify the EX_PWM_Dim.cpp and replace the following in 4 different places:

analogWrite(m_nPinPWM, map(m_nCurrentLevel, 0, 100, 0, 1023));

with

analogWrite(m_nPinPWM, map(m_nCurrentLevel, 0, 100, 0, 255));

I'll admit I understand logically at a high level how this all works, but I do not understand how each part works exactly, nor do I understand how to code. So while this solved my issue for now, I believe that this is more of a bandaid than a permanent fix of the PWM component due to the way the core for these ESP8266 board changed. So I am elevating to this group to see if there is someone out there that would be willing to look at and re-write the PWM component to factor in the new 1023 resolution?

Again for give my mistakes if there is anything that i misspoke or mislabeled in this post :slight_smile:. Happy to chime in more if there is anything that needs clarified.

1 Like