PHP code example of cronox / serial-php
1. Go to this page and download the library: Download cronox/serial-php library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cronox / serial-php example snippets
$phone = '321321321';
$message = 'Test SMS'
try {
$serial = new \Cronox\SerialPHP\SerialPHP();
$serial->setSerialPort('/dev/ttyS0');
$serial->openSerialPort();
$serial->setBaudRate(9600);
$serial->send('AT', 2);
$serial->send('AT+CMGF=1', 2);
$serial->send('AT+CMGS="'.$phone.'"', 2);
$serial->send($message.chr(26), 4);
return $serial->read();
} catch (\Exception $exception) {
throw $exception;
}
json
"cronox/serial-php": "^1.0"