/*************************************************************
You’ll need:
- Blynk IoT app (download from App Store or Google Play)
- ESP8266 board
- Decide how to connect to Blynk
(USB, Ethernet, Wi-Fi, Bluetooth, ...)
There is a bunch of great example sketches included to show you how to get
started. Think of them as LEGO bricks and combine them as you wish.
For example, take the Ethernet Shield sketch and combine it with the
Servo example, or choose a USB sketch and add a code from SendData
example.
*************************************************************/
/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMPL6FftOEUGf"
#define BLYNK_TEMPLATE_NAME "IOT"
#define BLYNK_AUTH_TOKEN "DtUWdySNRgGitU1Mieeq3Eta9TzzgpUk"
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "70S733";
char pass[] = "0870841702";
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
// You can also specify server:
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
}
void loop()
{
Blynk.run();
// You can inject your own code or combine it with other sketches.
// Check other examples on how to communicate with Blynk. Remember
// to avoid delay() function!
}
i try other cable and port and reinstall blynk and esp8266 core and still not work
i just remember i uploaded a code 2 month ago before it error like this.
sorry didn’t mention you earlier
here’s code i upload before it’s get error message
// Blynk Template Information
#define BLYNK_TEMPLATE_ID "TMPL6FftOEUGf"
#define BLYNK_TEMPLATE_NAME "IOT"
#define BLYNK_AUTH_TOKEN "DtUWdySNRgGitU1Mieeq3Eta9TzzgpUk"
#define BLYNK_PRINT Serial
// Lib include
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
float pHValue;
// WiFi Credentials
char ssid[] = "70S733";
char pass[] = "0870841702";
// TDS Sensor Configuration
#define TdsSensorPin A0
#define VREF 5.0
#define SCOUNT 30
int analogBuffer[SCOUNT];
int analogBufferTemp[SCOUNT];
int analogBufferIndex = 0, copyIndex = 0;
float averageVoltage = 0, tdsValue = 0, temperature = 25;
void setup() {
// Initialize Blynk and Serial
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
Serial.begin(115200);
pinMode(TdsSensorPin, INPUT);
lcd.init();
lcd.backlight();
}
void loop() {
// Run Blynk
Blynk.run();
// TDS Sensor Sampling
static unsigned long analogSampleTimepoint = millis();
if (millis() - analogSampleTimepoint > 40U) {
analogSampleTimepoint = millis();
analogBuffer[analogBufferIndex] = analogRead(TdsSensorPin);
analogBufferIndex++;
if (analogBufferIndex == SCOUNT)
analogBufferIndex = 0;
}
// TDS Sensor Processing
static unsigned long printTimepoint = millis();
if (millis() - printTimepoint > 800U) {
printTimepoint = millis();
for (copyIndex = 0; copyIndex < SCOUNT; copyIndex++)
analogBufferTemp[copyIndex] = analogBuffer[copyIndex];
// Calculate average voltage
averageVoltage = getMedianNum(analogBufferTemp, SCOUNT) * (float)VREF / 1024.0;
// Temperature Compensation
float compensationCoefficient = 1.0 + 0.02 * (temperature - 25.0);
float compensationVoltage = averageVoltage / compensationCoefficient;
// Convert voltage to TDS value
tdsValue = (133.42 * compensationVoltage * compensationVoltage * compensationVoltage - 255.86 * compensationVoltage * compensationVoltage + 857.39 * compensationVoltage) * 0.5;
// Read pH value from Serial
String pHString = Serial.readStringUntil('\n');
float pHValue = pHString.toFloat();
delay(100);
// Serial & debug
//Serial.print("voltage:");
//Serial.print(averageVoltage,2);
//Serial.print("V ");
//Serial.print("TDS Value:");
//Serial.print(tdsValue,0);
//Serial.println("ppm");
//Serial.print(pHValue);
// Update Blynk virtual pins & Lcd
Blynk.virtualWrite(V1, tdsValue);
//Serial.print("V1Sended");
lcd.setCursor(0, 0);
lcd.print("ppm");
lcd.setCursor(5, 0);
lcd.print(tdsValue);
//Serial.print("tds lcded");
Blynk.virtualWrite(V2, pHValue);
//Serial.print("V2Sended");
lcd.setCursor(0, 1);
lcd.print("pH");
lcd.setCursor(5, 1);
lcd.print(pHValue);
//Serial.print("pH lcded");
}
}
// Function to calculate median of an array
int getMedianNum(int bArray[], int iFilterLen) {
int bTab[iFilterLen];
for (byte i = 0; i < iFilterLen; i++)
bTab[i] = bArray[i];
quickSort(bTab, 0, iFilterLen - 1);
if (iFilterLen % 2 != 0) {
return bTab[iFilterLen / 2];
} else {
return (bTab[iFilterLen / 2 - 1] + bTab[iFilterLen / 2]) / 2;
}
}
void quickSort(int arr[], int left, int right) {
int i = left, j = right;
int tmp;
int pivot = arr[(left + right) / 2];
while (i <= j) {
while (arr[i] < pivot)
i++;
while (arr[j] > pivot)
j--;
if (i <= j) {
tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
i++;
j--;
}
}
if (left < j)
quickSort(arr, left, j);
if (i < right)
quickSort(arr, i, right);
}