Can anyone please help with this? I’m using an Arduino Mega and Esp-01 for this project. My wifi module doesn’t seem to connect:
9]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.6.1 on Arduino Mega
[599] Connecting to Mike
[1609] ESP is not responding
#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[] = "nli5lF1PNIgF0RFd3zhxYShPHKnvbsyU";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Mike";
char pass[] = "THEw33kend";
// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 38400
ESP8266 wifi(&EspSerial);
BlynkTimer timer;
int value = 0;
int adcValue = 0;
int sensitivity = 66;
int offsetVoltage = 2500;
double adcVoltage = 0;
double currentValue = 0;
double currentValueB = 0;
double power_solar = 0;
double power_Battery = 0;
int analogV = A3;
int analogI = A6;
int analogV_1 = A5;
int analogI_1 = A4;
float iout = 0.0;
float iin = 0.0;
float vout = 0.0;
float vin = 0.0;
float vin2 = 0.0;
float R1 = 10000.0; // resistance of R1 (100K) -see text!
float R2 = 3300.0; // resistance of R2 (10K) - see text!
float R3 = 10000.0; // resistance of R1 (100K) -see text!
float R4 = 4700.0; // resistance of R2 (10K) - see text!
int trigPin = 11; // Trigger
int echoPin = 12; // Echo
long duration, cm;
int relay_pump1 = 8;
int relay_pump2 = 9;
int relay_pump3 = 7;
int relay_reserve = 6;
void setup(){
Serial.begin(9600);
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
pinMode(analogV, INPUT );
pinMode(analogI, INPUT );
pinMode(analogV_1, INPUT );
pinMode(analogI_1, INPUT );
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
timer.setInterval(10000, sendSensors);
}
void sendSensors(){
//This sedtions deals of voltage sensor of solar
value = analogRead(A3);
vout = (value * 4.96) / 1023.0; // see text
vin = vout / (R2/(R1+R2)); // Applying voltage divider rule
// This section deals with the current sensor of solar
adcValue=analogRead(A6);
adcVoltage = (adcValue / 1023.0) * 5000;// read the value at analog input
currentValue = - ((adcVoltage - offsetVoltage) / sensitivity);
power_solar = ( vin * currentValue); // For the power coming from the solar panel
if (vin<0.09) { vin=0.0; } //statement to quash undesired reading !
// This section deals with battery voltage sensor
value = analogRead(A5);
vout = (value * 4.96) / 1023.0; // see text
vin2 = vout / (R4/(R3+R4)); // Applying voltage divider rule
//This section deals with battery current voltage
adcValue=analogRead(A4);
adcVoltage = (adcValue / 1023.0) * 5000;// read the value at analog input
currentValueB = - ((adcVoltage - offsetVoltage) / sensitivity);
power_Battery = ( vin2 * currentValueB); // For the power coming from the solar panel
if (vin<0.09) { vin=0.0; } //statement to quash undesired reading !
Serial.print("Output V = ");
Serial.println(vin);
Serial.print("Current A = ");
Serial.println(currentValue);
Serial.print("solar power W = ");
Serial.println(power_solar);
Serial.print("Output V = ");
Serial.println(vin2);
Serial.print("Current A = ");
Serial.println(currentValueB);
Serial.print("Battery power W = ");
Serial.println();
//Serial.println();
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the signal from the sensor: a HIGH pulse whose
// duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
// Convert the time into a distance
cm = (duration/2) / 29.1; // Divide by 29.1 or multiply by 0.0343
Serial.print("Distance: ");
Serial.print(cm);
Serial.print("cm to max capacity.");
Serial.println();
Serial.println();
Blynk.virtualWrite(V5, power_solar);
Blynk.virtualWrite(V6, power_Battery);
delay(3000);
}
void loop(){
Blynk.run();
timer.run();
}