#include <SoftwareSerial.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//const byte code[]= {0x01, 0x03, 0x00, 0x1e, 0x00, 0x03, 0x65, 0xCD};
const byte nitro[] = {0x01, 0x03, 0x00, 0x1e, 0x00, 0x01, 0xe4, 0x0c};
const byte phos[] = {0x01, 0x03, 0x00, 0x1f, 0x00, 0x01, 0xb5, 0xcc};
const byte pota[] = {0x01, 0x03, 0x00, 0x20, 0x00, 0x01, 0x85, 0xc0};
byte values[11];
SoftwareSerial mod(2, 3);
#define BLYNK_TEMPLATE_ID "TMPL37IJF_aXY"
#define BLYNK_TEMPLATE_NAME "pro"
#define BLYNK_AUTH_TOKEN "ouLl5TrL10cmysAKQlclzzG69EHa48Lc"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
#define DHT_PIN 18 // Pin connected to the DHT sensor
#define DHT_TYPE DHT22 // Type of DHT sensor (DHT11, DHT21, DHT22)
char auth[] = "ouLl5TrL10cmysAKQlclzzG69EHa48Lc"; // Your Blynk authentication token
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
DHT dht(DHT_PIN, DHT_TYPE);
void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
dht.begin();
}
void loop() {
byte val1, val2, val3;
val1 = random(0, 350); // Generate random value for nitrogen (0-255)
delay(250);
val2 = random(0, 350); // Generate random value for phosphorous (0-255)
delay(250);
val3 = random(0, 330); // Generate random value for potassium (0-255)
delay(250);
Serial.print("Nitrogen: ");
Serial.print(val1);
Serial.println(" mg/kg");
Serial.print("Phosphorous: ");
Serial.print(val2);
Serial.println(" mg/kg");
Serial.print("Potassium: ");
Serial.print(val3);
Serial.println(" mg/kg");
delay(2000);
Blynk.virtualWrite(V3, val1);
Blynk.virtualWrite(V4, val2);
Blynk.virtualWrite(V5, val3);
}