Arduino를 사용하여 공장 모니터를 만들고 처리하려고합니다. 처리는 Arduino가 입력 한 센서를 기반으로 HTML 파일을 작성합니다. WinSCP는 변경을 위해 생성 된 파일을 모니터링하고 파일이 변경되면 트로프 FTP를 직접 업로드합니다.처리 : arduino 입력에서 HTML 파일 쓰기
import processing.serial.*;
Serial myPort;
String dataReading = "";
int lol = 0;
String string0 = "<h1>Jurze Plants <img src=\"https://html-online.com/editor/tinymce/plugins/emoticons/img/smiley-laughing.gif\" alt=\"laughing\" /></h1>";
String string1 = "Moisture Level: ";
String string2 = " %<br> Motorstate: ";
String string3 = "<br> Temperature: ";
String string4 = " °C<br> Humidity: ";
String string5 = "%<br>";
void setup() {
size(500, 500);
myPort = new Serial(this, "COM4", 9600);
myPort.bufferUntil('x');
}
void draw() {
}
String [] dataOutput = {};
void serialEvent(Serial myPort) {
dataReading = myPort.readString();
if (dataReading!=null) {
dataOutput = split(dataReading, '\n');
String [] tempfile = {string0,string1,dataOutput[1],string2,dataOutput[2],string3,dataOutput[3],string4,dataOutput[4],string5 };
println("saving to html file...");
saveStrings("data/index.html",tempfile);
}
}
HTML 코드 내가 얻을 :이 데이터를 HTML 페이지를 쓰기 처리에 다음 코드를 사용하여
45
0
31
40
x
: 아두 이노 직렬를 통해 처리 다음 보내는
처음은 다음과 같습니다 :
<h1>Jurze Plants <img src="https://html-online.com/editor/tinymce/plugins/emoticons/img/smiley-laughing.gif" alt="laughing" /></h1>
Moisture Level: 46 %<br>
Motorstate: 0 <br>
Temperature:31.00 °C <br>
Humidity: 35.00% <br>
Arduino에서 데이터를 가져온 후 두 번째로 다음과 같이 보입니다.
<h1>Jurze Plants <img src="https://html-online.com/editor/tinymce/plugins/emoticons/img/smiley-laughing.gif" alt="laughing" /></h1>
Moisture Level: %<br>
Motorstate: 46 <br>
Temperature:0 °C <br>
Humidity: 31.00% <br>
배열에 문제가 있습니까? 도움이 될 것입니다. : D
승리를 위해 [espruino] (http://www.espruino.com/) !!! –
'split' 함수를 보여줄 수 있습니까? –
@ JérômeTeisseire'dataOutput = split (dataReading, '\ n'); ' – Jurze