hello
i'm making the smart farm controller using raspberry pi pico + hc-06 and sensors
sensors are working well but only hc-06 is not working
->serial monitor on ide shows sensor data well.
->but when i try to control the machine through my smartphone(connected to hc-6), there is no response.
->i didn't use <Softwareserial.h> because pico doesnt support it.
just typed Serial.begin(9600)
->hc-06's each RX, TX pins are connected to GP0(UART0-TX), GP1(UART0-RX)
As I expected, It needs to work, but no working.
is there anything What I need to add??
here's my code i made
#include <DHT11.h> //activate dht library
int relay1 = 10; //PTC Heat-6A
int relay2 = 11; //PTC Heat-6A
int relay3 = 8; //LED
int relay4 = 9; //water pump
DHT11 dht11(26); //install DHT on pin26
//---setup---
void setup() {
Serial.begin(9600); //hc-06 serial begin
pinMode(relay1, OUTPUT); //PTC6A relay switch
pinMode(relay2, OUTPUT); //PTC6A relay switch
pinMode(relay3, OUTPUT); //LED relay switch
pinMode(relay4, OUTPUT); //water pump realy
}
//---loop---
void loop() {
float temp, humi;
int ht_result = dht11.read(humi, temp);
float g_humid = analogRead(27); //save soil humidity data from pin27
Serial.print("습도: ");
Serial.print(humi);
Serial.println("% ");
Serial.print("온도: ");
Serial.print(temp);
Serial.println("C ");
Serial.print("토양습도: ");
Serial.print(g_humid);
Serial.println("% ");
Serial.println("");
delay(1000); //send data each 5 sec
//send humid, temp, g_humid through hc-06
char cmd; //command through hc-06
if(Serial.available()){
cmd = (char)Serial.read();
if(cmd == '1'){ //PTC on
digitalWrite(relay1,HIGH); //PTC Active
digitalWrite(relay2,HIGH); //PTC Active
Serial.print("Heat mode Activated!");
Serial.print("Heat mode will be turn off in 30 minitue!");
}
if(cmd == '2'){ //LED on
digitalWrite(relay3,HIGH);
Serial.print("LED turned on!");
}
if(cmd == '3'){ //Water pump active
digitalWrite(relay4,HIGH);
Serial.print("Water injection!");
delay(5000); //Water pump active during 5 sec
}
if(cmd == '4'){ //PTC off
digitalWrite(relay1,LOW); //PTC Active
digitalWrite(relay2,LOW); //PTC Active
Serial.print("Heat mode Deactivated!");
}
if(cmd == '5'){ //LED off
digitalWrite(relay3,LOW);
Serial.print("LED turned off!");
}
//PTC Heater, LED, WP Control through hc-06
}
}