[Unformatted code removed by moderator]
Some information about what does and does not work would be useful.
Is your device showing as Online in Blynk?
Are your sensor values showing in the serial monitor and on your LCD?
How are your V4 to V9 datastreams configured?
Why are you using delays in your myTimerEvent
function?
Pete.
i learn that from my teacher, may i show you my project code by my self
for sensor values is showing on serial monitor and my lcd.
my V9 : interger min 0 max 1
my v4 : interger min 0 max 1000
my trouble is just the sensor values not showing on blynk web and blynk app on android.
this my project code.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define SENSOR_PIN_A0 36 // Pin A0 (GPIO 36)
#define SENSOR_PIN_A1 34 // Pin A1 (GPIO 34)
#define PinRelay 5 // Pin D5 sebagai penggerak relay
#define S0 13 // Pin D13 sebagai S0 untuk sensor TCS3200
#define S1 12 // Pin D12 sebagai S1 untuk sensor TCS3200
#define S2 27 // Pin D27 sebagai S2 untuk sensor TCS3200
#define S3 26 // Pin D6 sebagai S3 untuk sensor TCS3200
#define sensorOut 14 // Pin D14 sebagai SensorOut untuk sensor TCS3200
#define BLYNK_TEMPLATE_ID "TMPL6R2vQmul9"
#define BLYNK_TEMPLATE_NAME "kumohon berhasil"
#define BLYNK_AUTH_TOKEN "v4aPowk1abXoB6I7vk3MdZiPLbaxBc_-"
BlynkTimer timer;
bool Relay = false;
char auth[] = "v4aPowk1abXoB6I7vk3MdZiPLbaxBc_-"; // Enter your Auth token
char ssid[] = "Travshopp"; // Enter your WIFI SSID
char pass[] = "cuanterus27"; // Enter your WIFI password
void setup() {
Serial.begin(115200);
Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
pinMode(SENSOR_PIN_A0, INPUT);
pinMode(SENSOR_PIN_A1, INPUT);
pinMode(PinRelay, OUTPUT);
digitalWrite(PinRelay, HIGH); // Relay dimatikan saat awal program berjalan
lcd.begin();
lcd.backlight();
lcd.setCursor(1, 0);
lcd.print("Sistem Penyiram");
lcd.setCursor(1, 1);
lcd.print("Tanaman Otomatis");
delay(3000); // Tahan tampilan selama 3 detik
WiFi.begin(ssid, pass); // Menghubungkan ESP32 dengan WiFi
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(sensorOut, INPUT);
digitalWrite(S0, HIGH);
digitalWrite(S1, LOW);
timer.setInterval(5000L, sensorYL69);
timer.setInterval(5000L, PhSensor);
timer.setInterval(5000L, colorSensor);
}
BLYNK_WRITE(V9) {
Relay = param.asInt();
if (Relay == 1) {
digitalWrite(PinRelay, LOW);
} else {
digitalWrite(PinRelay, HIGH);
}
}
void sensorYL69() {
float sensorValueA0 = analogRead(SENSOR_PIN_A0)/ 1023.0 * 100.0;
int soilPersen = (100.00 - ((sensorValueA0 / 1023.00) * 100.00));
Blynk.virtualWrite(V6, sensorValueA0);
Serial.print("ADC Soil: ");
Serial.println(sensorValueA0);
Serial.print("Kelembaban Tanah: ");
Serial.print(soilPersen);
Serial.println("%");
if (sensorValueA0 > 300) {
digitalWrite(PinRelay, LOW);
lcd.clear();
lcd.setCursor(10, 0);
lcd.print("KERING");
Blynk.virtualWrite(V9, PinRelay, LOW);
} else {
digitalWrite(PinRelay, HIGH);
lcd.clear();
lcd.setCursor(10, 0);
lcd.print("BASAH");
Blynk.virtualWrite(V9, PinRelay, HIGH);
}
lcd.setCursor(0, 0);
lcd.print("Adc=");
lcd.print(sensorValueA0);
delay(5000); // Menunggu 5 detik sebelum membaca kembali kelembapan
}
void PhSensor() {
int sensorValueA1 = analogRead(SENSOR_PIN_A1);
delay(1000);
// Rumus didapat berdasarkan datasheet
float outputValueA1 = (-0.0693 * sensorValueA1) + 7.3855;
Blynk.virtualWrite(V7, outputValueA1);
lcd.setCursor(0, 1);
lcd.print("pH = ");
lcd.print(outputValueA1);
delay(5000);
// Print the results to the serial monitor
Serial.print("sensor ADC= ");
Serial.print(sensorValueA1);
Serial.print(" output pH= ");
Serial.println(outputValueA1);
}
void colorSensor() {
// Setting the outputs
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
// Setting the sensorOut as an input
pinMode(sensorOut, INPUT);
// Setting frequency scaling to 20%
digitalWrite(S0, HIGH);
digitalWrite(S1, LOW);
// Begins serial communication
Serial.begin(115200);
// Setting RED (R) filtered photodiodes to be read
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
// Reading the output frequency
int redFrequency = pulseIn(sensorOut, LOW);
Blynk.virtualWrite(V8, redFrequency);
// Printing the RED (R) value
Serial.print("R = ");
Serial.print(redFrequency);
delay(100);
// Setting GREEN (G) filtered photodiodes to be read
digitalWrite(S2, HIGH);
digitalWrite(S3, HIGH);
// Reading the output frequency
int greenFrequency = pulseIn(sensorOut, LOW);
Blynk.virtualWrite(V4, greenFrequency);
// Printing the GREEN (G) value
Serial.print(" G = ");
Serial.print(greenFrequency);
delay(100);
// Setting BLUE (B) filtered photodiodes to be read
digitalWrite(S2, LOW);
digitalWrite(S3, HIGH);
// Reading the output frequency
int blueFrequency = pulseIn(sensorOut, LOW);
Blynk.virtualWrite(V5, blueFrequency);
// Printing the BLUE (B) value
Serial.print(" B = ");
Serial.println(blueFrequency);
delay(100);
lcd.setCursor(0, 1);
lcd.print("R:");
lcd.print(redFrequency);
lcd.print("G:");
lcd.print(greenFrequency);
lcd.print("B:");
lcd.print(blueFrequency);
delay(5000);
}
void loop() {
Blynk.run();
timer.run();
}
@chis Please edit your posts, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
Copy and paste these if you can’t find the correct symbol on your keyboard.
Pete.
okey, done sir
You’ve done the second one, but not post #1 in this topic.
You’ve also not answered my questions.
Pete.
Is your device showing as Online in Blynk?
A : online but just 25 sec and then offline. repeat
Are your sensor values showing in the serial monitor and on your LCD?
A: yes,
How are your V4 to V9 datastreams configured?
A: the datastreams my V9 : interger min 0 max 1
my v4 : interger min 0 max 1000
Why are you using delays in your myTimerEvent
function?
A: because my teacher told me to use this myTimerEvent
sir.
and then i change my code on reply #3
i hope someone can help my project sir, i was try every tutorial on yt but still not working sir
“V4 to V9” means V4, V5, V6, V7, V8 and V9
The syntax of these Blynk.virtualWrite() commands is incorrect…
Time to get a new teacher then!
You, and your teacher, should read this…
Also this is very bad practice…
Because all of your timed functions are trying to execute at the same time, but you aren’t using a multi-tasking MCU.
You should read the “Staggering Timers” part of this tutorial…
Pete.
Can you give me an example of the code I provided sir? just 1 example to move 1 sensor please
v4 : interger
v5 : interger
v6 : double
v7 : double
v8 : interger
v9 : interger