Download????????????? ??????????????? ?????????? ?? Arduino
???? ? ?????? ?????????? ??????????? ??? ?? Ascoos OS ?????? ?? ?????????????? ??? ??? ????????????? ?????????? ???????????? ??? ???????? ???? Arduino. ?? ??????? ?????????? ?? ????????, ?????????? ????????, ??????? ??? ????? ??? ?????????? ??????? ????????.
??????
?? ?????????? ????????? ??? ???????? ??????? ??? Ascoos OS:
- TArduinoHandler: ??????????? ?? Arduino ??? ???????? ????????? ??????????.
- TValidationHandler: ????????? ??? ????? ???????????? ??? ????????.
- TArrayAnalysisHandler: ??????? ??????????? ?????????.
- TArrayGraphHandler: ?????????? ?????????? ?????.
- TEventHandler: ????????? ????????? ???????? ?????????.
- TErrorMessageHandler: ?????????? ????????? ??? ??????????.
????
? ?????? ??????????? ?? ??? ?????? PHP:
- arduino_monitoring.php: ???????????? ???????? ??????????, ?????????, ???????, ????????? ??? ?????????? ????????.
??????????????
-
??????????? ??? Ascoos OS (????? repository).
-
??????? Arduino ?? ?????????? ???????????? ??? ???????? ???? ?????????? ???????? A0 ??? A1.
-
???????? ??? ???????? ???? (?.?. `/dev/ttyACM0`) ??? ????? ??????? baud rate.
-
?????????? ???????? ????? ???????? `$AOS_LOGS_PATH` ??? `$AOS_TMP_DATA_PATH/reports/arduino/`.
-
? ?????????? phpBCL8 ????? ???????????????? ??? ?????????? ????????.
??????????
-
???????? ?? Arduino ??? ???????????? ?? ???? ??? ??? ?????????.
-
????????? ?? script ???? web server:
https://localhost/aos/examples/case-studies/iot/arduino/arduino_monitoring.php
?????????? ??????
$arduinoHandler->setPinMode(0, FIRMATA_PIN_MODE_ANALOG); // ???????????
$arduinoHandler->setPinMode(1, FIRMATA_PIN_MODE_ANALOG); // ???????
$sensorData[] = ['temperature' => $arduinoHandler->analogRead(0), 'humidity' => $arduinoHandler->analogRead(1)];
$validationHandler->validate($sensorData[0], [
'temperature' => 'required|numeric|min:0|max:1023',
'humidity' => 'required|numeric|min:0|max:1023'
]);
$realData = $arduinoHandler->convertAnalogReadings($sensorData, 'DHT11');
$temps = array_column($realData, 'temperature');
$analysisHandler->clean();
$analysisHandler->setArray($temps, ['sensor', 'temperature']);
$meanTemp = $analysisHandler->mean();
$graphHandler->clean();
$graphHandler->setArray($temps, ['sensor', 'temperature']);
$graphHandler->createLineChart($graphHandler->getDeepProperty(['file', 'baseDir']) . '/temperature_trend.png');
??????????? ??????????
?? script ?????????? ??? ?????? JSON ?? ??? ??????? ??? ??? ??????? PNG. ?????????? ??????: {
"mean_temperature": 512.3,
"data_points": 10
}
?????
??????????
?????? ?? ???????????? ?? ???? ?? ?????? ??????????; ????? fork ?? ??????????, ???????????? ? ????????? ???? ??????????? ??? arduino_monitoring.php, ??? ????????? pull request. ????? ?? CONTRIBUTING.md ??? ???????.
????? ??????
???? ? ?????? ?????????? ?????????? ??? ??? Ascoos General License (AGL). ????? ?? LICENSE.
|