0

When running my code, the board resets when trying to connect with Bylnk and my phone's hotspot.

#include<Adafruit_ADS1X15.h>
#include<Wire.h>
#include "Arduino.h"
#define BLYNK_TEMPLATE_ID "TMPLyQ2Ub28b"
#define BLYNK_DEVICE_NAME "WaterController"
#define BLYNK_FIRMWARE_VERSION        "0.1.0"
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG
#define USE_NODE_MCU_BOARD
#include "BlynkEdgent.h"


#define waterPump D5
WidgetLED pump(V1);
//LOW IS ON
float soilLevel; //Get soil moisture from A0
int16_t soilR; // Read value from A0
WidgetLCD vLcd(V2);
Adafruit_ADS1115 ads;
//function to turn on and off water pump based off soil moisture levels
void sendSensor()
{
  readSoil();
  if(soilLevel>=130)
  {    
    digitalWrite(waterPump, HIGH);
    vLcd.print(0,0,"Water Pump OFF");
    pump.off();
  }
  
 if(soilLevel<60)
  {    
    digitalWrite(waterPump, LOW);
    vLcd.print(0,0, "Water Pump ON ");
    pump.on();
  }
}

void readSoil()
{
  soilR=ads.readADC_SingleEnded(0);  

  
  Serial.println(soilR);
  soilLevel=map(soilR, 0, 1024, 200,0); // adjust soil level values
  Serial.println(soilLevel);
  Blynk.virtualWrite(V0, soilLevel);
  delay(1000);
}

void setup()
{
  Serial.begin(9600);
  pinMode(waterPump, OUTPUT);
  digitalWrite(waterPump, HIGH);
  delay(100);

  BlynkEdgent.begin();

  Wire.begin(D1, D2); //SDA, SCL
  ads.begin(); //start ads
}

void loop() {
  BlynkEdgent.run();
  sendSensor();
  
}

Here is the error exception.


14:47:31.771 -> Soft WDT reset
14:47:31.771 -> 
14:47:31.771 -> Exception (4):
14:47:31.803 -> epc1=0x401071a2 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
14:47:31.899 -> 

Without using the code referring the ADS1115, there is no problem with the connection. With the ADS1115 code, the ESP8266 doesn't want to connect.

Here is the code without the ADS1115 stuff.

#include "Arduino.h"
#define BLYNK_TEMPLATE_ID "TMPLyQ2Ub28b"
#define BLYNK_DEVICE_NAME "WaterController"
#define BLYNK_FIRMWARE_VERSION        "0.1.0"
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG
#define USE_NODE_MCU_BOARD
#include "BlynkEdgent.h"

#define soil A0
#define waterPump D5
WidgetLED pump(V1);
//LOW IS ON
float soilLevel, soilR; //Get soil moisture
WidgetLCD vLcd(V2);
//function to turn on and off water pump based off soil moisture levels
void sendSensor()
{
  readSoil();
  if(soilLevel>=130)
  {    
    digitalWrite(waterPump, HIGH);
    vLcd.print(0,0,"Water Pump OFF");
    pump.off();
  }
  
 if(soilLevel<60)
  {    
    digitalWrite(waterPump, LOW);
    vLcd.print(0,0, "Water Pump ON ");
    pump.on();
  }
}

void readSoil()
{
  soilR=analogRead(soil);  
  Serial.println(soilR);
  soilLevel=map(soilR, 0, 1024, 200,0); // adjust soil level values
  Serial.println(soilLevel);
  Blynk.virtualWrite(V0, soilLevel);
  delay(1000);
}

void setup()
{
  Serial.begin(9600);
  pinMode(waterPump, OUTPUT);
  digitalWrite(waterPump, HIGH);
  delay(100);

  BlynkEdgent.begin();
}

void loop() {
  BlynkEdgent.run();
  sendSensor();
}

0 Answers0