Append values to MySQL column and delete old values
First, you can use the VALUES() syntax to update. No need to send parameters twice:

$sql = "
    INSERT INTO multi
        (unitid, value, date_time)
    VALUES
        (?,?,?)
    ON DUPLICATE KEY UPDATE
        presence_value = CONCAT(value, VALUES(value)), 
        date_time = VALUES(date_time);
";


To keep only the last three, you can use some string functions:

        presence_value = CONCAT_WS(','                                -- separator
                                   SUBSTRING_INDEX(value, ',', -2),   -- last two 
                                   VALUES(value)),                    -- new one 


The code becomes:

$sql = "
    INSERT INTO multi
        (unitid, value, date_time)
    VALUES
        (?,?,?)
    ON DUPLICATE KEY UPDATE
        presence_value = CONCAT_WS(','                                -- separator
                                   SUBSTRING_INDEX(value, ',', -2),   -- last two 
                                   VALUES(value)),                    -- new one 
        date_time = VALUES(date_time);
";
$stmt = $db-&gt;prepare($sql);
$stmt-&gt;execute([$unit, $value, $time]);



No CRON jobs, no events, no triggers needed.
You need to make sure that that the 3 concatenated values will not exceed the 21 characters combined or increase the size of the column.