Before creating the topic
- Search forum for similar topics
- Check http://docs.blynk.cc and http://help.blynk.cc/
- Add details :
• Hardware model + communication type. For example: Arduino UNO with Ethernet Shield
• Smartphone OS (iOS or Android) + version
• Blynk server or local server
• Blynk Library version
• Add your sketch code.Code should be formatted as example below.
Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "9855d902dbef4926a71e25b5e0ff610a";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "LenovoA850+";
char pass[] = "88ec0b32b7ac";
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
int offset =20;// set the correction offset value
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
void setup()
{
// Debug console
Serial.begin(9600);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
}
BLYNK_WRITE(V0)
{
if (param.asInt()) {
digitalWrite(4, HIGH);
} else {
digitalWrite(4, LOW);
}}
BLYNK_WRITE(V1)
{
if (param.asInt()) {
digitalWrite(5, HIGH);
} else {
digitalWrite(5, LOW);
}}
BLYNK_WRITE(V2)
{
if (param.asInt()) {
digitalWrite(6, HIGH);
} else {
digitalWrite(6, LOW);
}}
BLYNK_WRITE(V3)
{
if (param.asInt()) {
digitalWrite(7, HIGH);
} else {
digitalWrite(7, LOW);
}}
void loop()
{
int volt = analogRead(A0);// read the input
double voltage = map(volt,0,1023, 0, 2500) + offset;// map 0-1023 to 0-2500 and add correction offset
voltage /=100;// divide by 100 to get the decimal values
Serial.print("Voltage: ");
Serial.print(voltage);//print the voltge
Serial.println("V");
Blynk.virtualWrite(V4, voltage);
delay(500);
Blynk.run();
}