The value of the temperature and humidity sensor is measured through the Arduino and appinventor outputs it. I want to put this value in html so that the graph moves in real time.
But the runtime error still occurs.
When changing the url link, the graph does not appear.
I don't know which part is the problem.
!!!!!!!!!Below is the url link of the html I want to upload!!!!!!!!!
!!!!!!!!!Below is the full code for Arduino!!!!!!!!!
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 2 //디지털 2번핀 사용
#define DHTTYPE DHT11 //DHT 22 모델 사용
DHT dht(DHTPIN, DHTTYPE);
#include <SoftwareSerial.h>
#define BT_RXD 3
#define BT_TXD 4
SoftwareSerial hc06(BT_RXD, BT_TXD);
#include <Thread.h> //https://github.com/ivanseidel/ArduinoThread
#include <ThreadController.h>
#include<Servo.h>
Servo myservo; // 서보를 제어할 서보 오브젝트를 만듭니다.
ThreadController controll = ThreadController(); //
//My simple Thread
Thread temperature = Thread();
Thread myThread2 = Thread();
/시간 변수/
extern volatile unsigned long timer0_millis; //타이머변수
//리셋 : timer0_millis = 0;
unsigned long time_current = 0; //현재시간
unsigned long time_previous = 0; //이전시간
unsigned long delayTime = 30000; //15분(900,000) 대기시간
boolean state = false;//타이머 동작 제어
boolean ledState = false; //LED 현재상태
/3색 LED/
int RED = 8;
int GREEN = 7;
int BLUE = 6;
/모듈/
int humidifier = 11;
int moter = 12;
int pos = 0; // 서보 위치를 저장할 변수를 선언합니다.
int reset = 7;
/기본 값/
unsigned long tt;
unsigned long t;
unsigned long h;
unsigned long hh;
/* ----------------- */
void setup() {
Serial.begin(9600);
hc06.begin(9600);
dht.begin(9600);
//myservo.attach(servoPin);
pinMode(moter, OUTPUT); // 팬모터
//pinMode(humidifier, OUTPUT); // 가습기 모듈
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
digitalWrite(GREEN,HIGH);
digitalWrite(reset,HIGH);
temperature.onRun(moter);
temperature.setInterval(500);
myThread2.onRun(humidifier);
myThread2.setInterval(800);
controll.add(&temperature);
controll.add(&myThread2);
myservo.attach(12);
}
void loop() {
if (hc06.available()) {
char c = hc06.read();
}
if (isnan(t) || isnan(h)) {
//값 읽기 실패시 시리얼 모니터 출력
Serial.println("Failed to read from DHT");
}
//if (time_current = delayTime) {
//else if (time_current >= delayTime)
//Serial.println(time_current);
//}
tt = dht.readTemperature();
t = dht.readTemperature();
hh = dht.readHumidity();
h = dht.readHumidity();
// 센서의 온도와 습도 읽기
if(millis()> time_current + delayTime){
time_current = millis();
temperature.onRun(temperatureCallback);
Serial.print("\n");
Serial.println("================================");
Serial.print("온도: ");
Serial.print(t);
Serial.println(" *C");
Serial.print("습도: ");
Serial.print(h);
Serial.println(" %t");
String data = String(hh) + "," + String(tt);
hc06.print("온도: ");
hc06.print(tt,1);
hc06.println(" *C");
hc06.print("습도: ");
hc06.print(hh,1);
hc06.println(" %");
hc06.println(data);
if(t<=22){
Serial.println("측정되어 작동이 시작됩니다.");
Serial.print("온도가 낮아 히터 작동시작합니다. \n");
digitalWrite(RED,HIGH);
digitalWrite(GREEN,LOW);
digitalWrite(BLUE,LOW);
digitalWrite(moter, HIGH);
while(millis()<= time_current + delayTime){
//temperature.run();
for(pos = 0; pos < 180; pos += 1){ // 0도에서 180도로 이동합니다.
myservo.write(pos);
}
for(pos = 180; pos>0; pos-=1){ // 180도에서 0도로 이동합니다.
myservo.write(pos);
}
}
}
else if(t>=28){
Serial.println("측정되어 작동이 시작됩니다.");
Serial.print("온도가 높아 에어컨 작동시작합니다.\n ");
digitalWrite(RED,LOW);
digitalWrite(GREEN,LOW);
digitalWrite(BLUE,HIGH);
digitalWrite(moter, HIGH);
while(millis()<= time_current + delayTime){
for(pos = 0; pos < 180; pos += 1){ // 0도에서 180도로 이동합니다.
myservo.write(pos);
}
for(pos = 180; pos>0; pos-=1){ // 180도에서 0도로 이동합니다.
myservo.write(pos);
}
}
}
else{
Serial.print("적정 온도이기 때문에 작동되지 않습니다. \n");
temperature.run();
}
}
}