Nano, ESP8266 , ADS1115 and Blynk - virtualwrite failure

Hi Guys,

I finally decided to change my projects to the recommended method for Blynk.run and Blynk timers to call functions with use of the timer.run.

I’ve ran into an issue with my Arduino Nano, ESP8266, ADS1115 and sending virtualwrites of data collected from the ADS1115 unit.

The below code just stops after the Ready line when watching in serial monitor:
[9253] Connected to WiFi
[20840] Ready (ping: 34ms)

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>
#include <Adafruit_ADS1015.h>

char auth[] = "***";
char ssid[] = "***";
char pass[] = "***";

SoftwareSerial EspSerial(2, 3); // RX, TX

#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);

BlynkTimer timer;
Adafruit_ADS1115 adsA(0x48);      /* Use this for the 16-bit version */

void setup()
{
  Serial.begin(9600);
  delay(100);
  
  EspSerial.begin(ESP8266_BAUD);
  delay(100);
  
  Blynk.begin(auth, wifi, ssid, pass);

  adsA.setGain(GAIN_ONE);           // 1x gain   +/- 4.096V  1 bit = 2mV      0.125mV
  adsA.begin();

  timer.setInterval(1000L, countuptime);
  timer.setInterval(2000L, systemvoltage);
}

void loop()
{
  Blynk.run();
  timer.run(); // BlynkTimer is working...
}

void systemvoltage()
{
  Serial.println("System Voltage (RAW): ");
  int16_t adcA0;
  adcA0 = adsA.readADC_SingleEnded(1);
  Serial.println(adcA0);
  Blynk.virtualWrite(V13, adcA0);
  
}

void countuptime()
{
  Serial.println("System Uptime Function: +1");
  Blynk.virtualWrite(V12, millis() / 1000);
}

In the above, the void systemvoltage() section causing the issue when attempting to read the ADC.

In the below everything works and it talks to Blynk server and the app shows +1 second increase on a wdiget.

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>
#include <Adafruit_ADS1015.h>

char auth[] = "***";
char ssid[] = "***";
char pass[] = "***";

SoftwareSerial EspSerial(2, 3); // RX, TX

#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);

BlynkTimer timer;
Adafruit_ADS1115 adsA(0x48);      /* Use this for the 16-bit version */

void setup()
{
  Serial.begin(9600);
  delay(100);
  
  EspSerial.begin(ESP8266_BAUD);
  delay(100);
  
  Blynk.begin(auth, wifi, ssid, pass);

  adsA.setGain(GAIN_ONE);           // 1x gain   +/- 4.096V  1 bit = 2mV      0.125mV
  adsA.begin();

  timer.setInterval(1000L, countuptime);
  timer.setInterval(2000L, systemvoltage);
}

void loop()
{
  Blynk.run();
  timer.run(); // BlynkTimer is working...
}

void systemvoltage()
{
  Serial.println("System Voltage (RAW): ");
  //int16_t adcA0;
  //adcA0 = adsA.readADC_SingleEnded(1);
  //Serial.println(adcA0);
  
}

void countuptime()
{
  Serial.println("System Uptime Function: +1");
  Blynk.virtualWrite(V12, millis() / 1000);
}

Thought it might have the int16_t value not being liked by Blynk, but if I just declare a fixed value using int16_t it works.

Also, interesting if i dont use the timer function and just have the code in void loop it works, seems to be a conflict with timer.run and the ads read function?

Will also post something in Blynk forums, see if its a known issue.

Cheers,

Nic

did some debuging from a BLYNK perspective:

When the unit stops after [20840] Ready (ping: 34ms) after I get the following being repeated continuesly every 5 seconds or so:

[22318] <[11|00|02|00]gver[00]0.6.1[00]h-beat[00]10[00]buff-in[00]256[00]dev
[32429] Cmd error
[42877] <[1D|00|01|00] my blynk auth key is repeated here
[53619] <[1D|00|01|00] my blynk auth key is repeated here
[64445] <[1D|00|01|00] my blynk auth key is repeated here

will post in Blynk site also;

Cheers,

Hi guys, for closure on this topic. I've changed from an ESP32-WROOM-32 to a ESP32-WROOM-32U. This now has no issues reading ADS1115s and then uploading to blyknk. I've also used an updated ESp32 library from github.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.