diff --git a/src/ChassisIntrusionSensor.cpp b/src/ChassisIntrusionSensor.cpp
index 841259f..3066359 100644
--- a/src/ChassisIntrusionSensor.cpp
+++ b/src/ChassisIntrusionSensor.cpp
@@ -54,6 +54,9 @@
 // Status bit field masks
 const static constexpr size_t pchRegMaskIntrusion = 0x01;
 
+// Value to clear intrusion status hwmon file
+const static constexpr size_t intrusionStatusHwmonClearValue = 0;
+
 void ChassisIntrusionSensor::updateValue(const size_t& value)
 {
     std::string newValue = value != 0 ? hwIntrusionValStr : normalValStr;
@@ -124,6 +127,7 @@
 void ChassisIntrusionPchSensor::pollSensorStatus()
 {
     std::weak_ptr<ChassisIntrusionPchSensor> weakRef = weak_from_this();
+
     // setting a new experation implicitly cancels any pending async wait
     mPollTimer.expires_after(std::chrono::seconds(intrusionSensorPollSec));
 
@@ -134,12 +138,14 @@
             std::cerr << "Timer of intrusion sensor is cancelled\n";
             return;
         }
+
         std::shared_ptr<ChassisIntrusionPchSensor> self = weakRef.lock();
         if (!self)
         {
             std::cerr << "ChassisIntrusionSensor no self\n";
             return;
         }
+
         int value = self->readSensor();
         if (value < 0)
         {
@@ -150,6 +156,7 @@
             intrusionSensorPollSec = defaultPollSec;
             self->updateValue(value);
         }
+
         // trigger next polling
         self->pollSensorStatus();
     });
@@ -174,6 +181,7 @@
         {
             return; // we're being destroyed
         }
+
         if (ec)
         {
             std::cerr << "Error on GPIO based intrusion sensor wait event\n";
@@ -191,6 +199,83 @@
     });
 }
 
+int ChassisIntrusionHwmonSensor::readSensor()
+{
+    int value = 0;
+
+    std::fstream stream(mHwmonPath, std::ios::in | std::ios::out);
+    if (!stream.good())
+    {
+        std::cerr << "Error reading status at " << mHwmonPath << "\n";
+        return -1;
+    }
+
+    std::string line;
+    if (!std::getline(stream, line))
+    {
+        std::cerr << "Error reading status at " << mHwmonPath << "\n";
+        return -1;
+    }
+
+    try
+    {
+        value = std::stoi(line);
+        if constexpr (debug)
+        {
+            std::cout << "Hwmon type: raw value is " << value << "\n";
+        }
+    }
+    catch (const std::invalid_argument& e)
+    {
+        std::cerr << "Error reading status at " << mHwmonPath << " : "
+                  << e.what() << "\n";
+        return -1;
+    }
+
+    // Reset chassis intrusion status after every reading
+    stream << intrusionStatusHwmonClearValue;
+
+    return value;
+}
+
+void ChassisIntrusionHwmonSensor::pollSensorStatus()
+{
+    std::weak_ptr<ChassisIntrusionHwmonSensor> weakRef = weak_from_this();
+
+    // setting a new experation implicitly cancels any pending async wait
+    mPollTimer.expires_after(std::chrono::seconds(intrusionSensorPollSec));
+
+    mPollTimer.async_wait([weakRef](const boost::system::error_code& ec) {
+        // case of being canceled
+        if (ec == boost::asio::error::operation_aborted)
+        {
+            std::cerr << "Timer of intrusion sensor is cancelled\n";
+            return;
+        }
+
+        std::shared_ptr<ChassisIntrusionHwmonSensor> self = weakRef.lock();
+        if (!self)
+        {
+            std::cerr << "ChassisIntrusionSensor no self\n";
+            return;
+        }
+
+        int value = self->readSensor();
+        if (value < 0)
+        {
+            intrusionSensorPollSec = sensorFailedPollSec;
+        }
+        else
+        {
+            intrusionSensorPollSec = defaultPollSec;
+            self->updateValue(value);
+        }
+
+        // trigger next polling
+        self->pollSensorStatus();
+    });
+}
+
 int ChassisIntrusionSensor::setSensorValue(const std::string& req,
                                            std::string& propertyValue)
 {
@@ -237,7 +322,9 @@
                                     " address " + std::to_string(slaveAddr) +
                                     "\n");
     }
+
     mSlaveAddr = slaveAddr;
+
     std::string devPath = "/dev/i2c-" + std::to_string(busId);
     // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
     mBusFd = open(devPath.c_str(), O_RDWR | O_CLOEXEC);
@@ -288,9 +375,46 @@
     {
         throw std::invalid_argument("Failed to get " + mPinName + " fd\n");
     }
+
     mGpioFd.assign(gpioLineFd);
 }
 
+ChassisIntrusionHwmonSensor::ChassisIntrusionHwmonSensor(
+    boost::asio::io_context& io, sdbusplus::asio::object_server& objServer,
+    std::string hwmonName) :
+    ChassisIntrusionSensor(objServer),
+    mHwmonName(std::move(hwmonName)), mPollTimer(io)
+{
+    std::vector<fs::path> paths;
+
+    if (!findFiles(fs::path("/sys/class/hwmon"), mHwmonName, paths))
+    {
+        throw std::invalid_argument("Failed to find hwmon path in sysfs\n");
+    }
+
+    if (paths.empty())
+    {
+        throw std::invalid_argument("Hwmon file " + mHwmonName +
+                                    " can't be found in sysfs\n");
+    }
+
+    if (paths.size() > 1)
+    {
+        std::cerr << "Found more than 1 hwmon file to read chassis intrusion"
+                  << " status. Taking the first one. \n";
+    }
+
+    // Expecting only one hwmon file for one given chassis
+    mHwmonPath = paths[0].string();
+
+    if constexpr (debug)
+    {
+        std::cout << "Found " << paths.size()
+                  << " paths for intrusion status \n"
+                  << " The first path is: " << mHwmonPath << "\n";
+    }
+}
+
 ChassisIntrusionSensor::~ChassisIntrusionSensor()
 {
     mObjServer.remove_interface(mIface);
@@ -313,3 +437,8 @@
         mGpioLine.release();
     }
 }
+
+ChassisIntrusionHwmonSensor::~ChassisIntrusionHwmonSensor()
+{
+    mPollTimer.cancel();
+}
diff --git a/src/ChassisIntrusionSensor.hpp b/src/ChassisIntrusionSensor.hpp
index e690bd2..b8ac953 100644
--- a/src/ChassisIntrusionSensor.hpp
+++ b/src/ChassisIntrusionSensor.hpp
@@ -74,3 +74,22 @@
     int readSensor() override;
     void pollSensorStatus() override;
 };
+
+class ChassisIntrusionHwmonSensor :
+    public ChassisIntrusionSensor,
+    public std::enable_shared_from_this<ChassisIntrusionHwmonSensor>
+{
+  public:
+    ChassisIntrusionHwmonSensor(boost::asio::io_context& io,
+                                sdbusplus::asio::object_server& objServer,
+                                std::string hwmonName);
+
+    ~ChassisIntrusionHwmonSensor() override;
+
+  private:
+    std::string mHwmonName;
+    std::string mHwmonPath;
+    boost::asio::steady_timer mPollTimer;
+    int readSensor() override;
+    void pollSensorStatus() override;
+};
diff --git a/src/IntrusionSensorMain.cpp b/src/IntrusionSensorMain.cpp
index c2783b7..3545233 100644
--- a/src/IntrusionSensorMain.cpp
+++ b/src/IntrusionSensorMain.cpp
@@ -47,6 +47,13 @@
 static constexpr const char* nicType = "NIC";
 static constexpr auto nicTypes{std::to_array<const char*>({nicType})};
 
+static const std::map<std::string, std::string> compatibleHwmonNames = {
+    {"Aspeed2600_Hwmon", "intrusion0_alarm"}
+    // Add compatible strings here for new hwmon intrusion detection
+    // drivers that have different hwmon names but would also like to
+    // use the available Hwmon class.
+};
+
 static void createSensorsFromConfig(
     boost::asio::io_context& io, sdbusplus::asio::object_server& objServer,
     const std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
@@ -67,7 +74,6 @@
     const std::pair<std::string, SensorBaseConfigMap>* baseConfiguration =
         nullptr;
 
-    // Get bus and addr of matched configuration
     for (const auto& [path, cfgData] : sensorConfigurations)
     {
         baseConfiguration = nullptr;
@@ -83,85 +89,121 @@
 
         baseConfiguration = &(*sensorBase);
 
-        // judge class, "Gpio" or "I2C"
+        // judge class, "Gpio", "Hwmon" or "I2C"
         auto findClass = baseConfiguration->second.find("Class");
-        if (findClass != baseConfiguration->second.end() &&
-            std::get<std::string>(findClass->second) == "Gpio")
+        if (findClass != baseConfiguration->second.end())
         {
-            auto findGpioPolarity =
-                baseConfiguration->second.find("GpioPolarity");
+            auto classString = std::get<std::string>(findClass->second);
+            if (classString == "Gpio")
+            {
+                auto findGpioPolarity =
+                    baseConfiguration->second.find("GpioPolarity");
 
-            if (findGpioPolarity == baseConfiguration->second.end())
-            {
-                std::cerr << "error finding gpio polarity in configuration \n";
-                continue;
-            }
+                if (findGpioPolarity == baseConfiguration->second.end())
+                {
+                    std::cerr
+                        << "error finding gpio polarity in configuration \n";
+                    continue;
+                }
 
-            try
-            {
-                bool gpioInverted =
-                    (std::get<std::string>(findGpioPolarity->second) == "Low");
-                pSensor = std::make_shared<ChassisIntrusionGpioSensor>(
-                    io, objServer, gpioInverted);
-                pSensor->start();
-                if (debug)
+                try
                 {
-                    std::cout
-                        << "find chassis intrusion sensor polarity inverted "
-                           "flag is "
-                        << gpioInverted << "\n";
+                    bool gpioInverted =
+                        (std::get<std::string>(findGpioPolarity->second) ==
+                         "Low");
+                    pSensor = std::make_shared<ChassisIntrusionGpioSensor>(
+                        io, objServer, gpioInverted);
+                    pSensor->start();
+                    if (debug)
+                    {
+                        std::cout
+                            << "find chassis intrusion sensor polarity inverted "
+                               "flag is "
+                            << gpioInverted << "\n";
+                    }
+                    return;
                 }
-                return;
-            }
-            catch (const std::bad_variant_access& e)
-            {
-                std::cerr << "invalid value for gpio info in config. \n";
-                continue;
-            }
-            catch (const std::exception& e)
-            {
-                std::cerr << e.what() << std::endl;
-                continue;
-            }
-        }
-        else
-        {
-            auto findBus = baseConfiguration->second.find("Bus");
-            auto findAddress = baseConfiguration->second.find("Address");
-            if (findBus == baseConfiguration->second.end() ||
-                findAddress == baseConfiguration->second.end())
-            {
-                std::cerr << "error finding bus or address in configuration \n";
-                continue;
-            }
-            try
-            {
-                int busId = std::get<uint64_t>(findBus->second);
-                int slaveAddr = std::get<uint64_t>(findAddress->second);
-                pSensor = std::make_shared<ChassisIntrusionPchSensor>(
-                    io, objServer, busId, slaveAddr);
-                pSensor->start();
-                if (debug)
+                catch (const std::bad_variant_access& e)
                 {
-                    std::cout << "find matched bus " << busId
-                              << ", matched slave addr " << slaveAddr << "\n";
+                    std::cerr << "invalid value for gpio info in config. \n";
+                    continue;
                 }
-                return;
+                catch (const std::exception& e)
+                {
+                    std::cerr << e.what() << std::endl;
+                    continue;
+                }
             }
-            catch (const std::bad_variant_access& e)
+            // If class string contains Hwmon string
+            else if (classString.find("Hwmon") != std::string::npos)
             {
-                std::cerr << "invalid value for bus or address in config. \n";
-                continue;
+                std::string hwmonName;
+                std::map<std::string, std::string>::const_iterator
+                    compatIterator = compatibleHwmonNames.find(classString);
+
+                if (compatIterator == compatibleHwmonNames.end())
+                {
+                    std::cerr << "Hwmon Class string is not supported\n";
+                    continue;
+                }
+
+                hwmonName = compatIterator->second;
+
+                try
+                {
+                    pSensor = std::make_shared<ChassisIntrusionHwmonSensor>(
+                        io, objServer, hwmonName);
+                    pSensor->start();
+                    return;
+                }
+                catch (const std::exception& e)
+                {
+                    std::cerr << e.what() << std::endl;
+                    continue;
+                }
             }
-            catch (const std::exception& e)
+            else
             {
-                std::cerr << e.what() << std::endl;
-                continue;
+                auto findBus = baseConfiguration->second.find("Bus");
+                auto findAddress = baseConfiguration->second.find("Address");
+                if (findBus == baseConfiguration->second.end() ||
+                    findAddress == baseConfiguration->second.end())
+                {
+                    std::cerr
+                        << "error finding bus or address in configuration \n";
+                    continue;
+                }
+                try
+                {
+                    int busId = std::get<uint64_t>(findBus->second);
+                    int slaveAddr = std::get<uint64_t>(findAddress->second);
+                    pSensor = std::make_shared<ChassisIntrusionPchSensor>(
+                        io, objServer, busId, slaveAddr);
+                    pSensor->start();
+                    if (debug)
+                    {
+                        std::cout << "find matched bus " << busId
+                                  << ", matched slave addr " << slaveAddr
+                                  << "\n";
+                    }
+                    return;
+                }
+                catch (const std::bad_variant_access& e)
+                {
+                    std::cerr
+                        << "invalid value for bus or address in config. \n";
+                    continue;
+                }
+                catch (const std::exception& e)
+                {
+                    std::cerr << e.what() << std::endl;
+                    continue;
+                }
             }
         }
     }
 
-    std::cerr << " Can't find matched I2C, GPIO configuration\n";
+    std::cerr << " Can't find matched I2C, GPIO or Hwmon configuration\n";
 
     // Make sure nothing runs when there's failure in configuration for the
     // sensor after rescan
