BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Nodemcu using ADC extender ads1115


#1

Hallo everyone!!
I’ve done a project that uses multiple sensors to send over the internet to android. but the problem is that Nodemcu has only A0 pins and I need 4 pins. I get a reference from internet that can use ADC extender ads1115 16 bit with I2C communication. can be used but can not be sent via the internet. I do not know what’s wrong. Please help me. thank you.

ADS1115_bb

#define BLYNK_PRINT Serial
#define BLYNK_MAX_SENDBYTES 256
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
/// I2C ADC EXTENDER///////////////////////
Adafruit_ADS1115 ads(0x48);
/// WIFI//////////////////////////////
char auth[] = "cba1761bec994abaac3a66a17892c8cf";
char ssid[] = "hotspotkokobodo";
char pass[] = "kokobodo1";
SimpleTimer timer;
int A=0;
int B=0;
int C=0;

///////////////////////////////////////////////////////////////////////////////////////
void setup()
{
  Serial.begin(115200);
  Wire.begin(D1,D2);
  Blynk.begin(auth, ssid, pass);
  ads.setGain(GAIN_ONE);
  ads.begin();
  }
  
///////////////////////////////////////////////////////////////////////////////////////
void sensor_kelenturan()
{ int16_t adc0,adc1,adc2,adc3; // inisialisasi pin ADC dari ads1115 alamat 0x49 - vcc
adc0 = ads.readADC_SingleEnded(4); 
adc1 = ads.readADC_SingleEnded(5); 
adc2 = ads.readADC_SingleEnded(6); 


A=map(adc0,3100,6800,0,100);
B=map(adc1,4000,9800,0,100);
C=map(adc2,3800,9900,0,100);

Blynk.virtualWrite(V5 ,A);
Blynk.virtualWrite(V6 ,B);
Blynk.virtualWrite(V7 ,C);

}
/////////////////////////////////////////////////////////////////////////////////////////////  

void loop()
{
  Blynk.run();
  timer.run();
}

#2

@Kukuh_Priambodo welcome.

Post formatted code.

Search this site for ADS1115.


#3

Or just wait for your freindly’ish neighbourhood mod to do it for you ('cuz… can’t sleep and bored :stuck_out_tongue_winking_eye: )

Blynk - FTFC

Can you clarify the actual issue?


#4

when I use this code, it works and can be seen in serial monitor ADC value. But when I combine it with code for Blynk and it does not work

#include <Wire.h>
#include <Adafruit_ADS1015.h>

Adafruit_ADS1115 ads(0x49);

void setup(void) 
{
Wire.begin();
Serial.begin(115200);
ads.begin();

}

void loop(void) {
  
int x,y,z,w;
int16_t adc0, adc1, adc2, adc3; // inisialisasi pin ADC dari ads1115
adc0 = ads.readADC_SingleEnded(0); 
adc1 = ads.readADC_SingleEnded(1); 
adc2 = ads.readADC_SingleEnded(2); 
adc3 = ads.readADC_SingleEnded(3); 

x=map(adc0,6877,10400,0,100);
y=map(adc1,6900,10500,0,100);
z=map(adc2,6900,10500,0,100);
w=map(adc3,0,17463,0,100);

Serial.println("x");
Serial.println(x);
Serial.println("y");
Serial.println(y);
Serial.println("  ");
Serial.println(w);
Serial.println("**************");
Serial.println("  ");
Serial.println("  ");
delay(1000);
}

#5

I see… well you need to create a timer (in your void setup() ) to actually call your scan and print data function :wink:


#6
timer.setInterval(1000L, value);

like that ?


#7

not quite

timer.setInterval(1000L, yourFunction);

void yourFunction(){
   // some code to establish / display value
}

#8
#define BLYNK_PRINT Serial
#define BLYNK_MAX_SENDBYTES 256
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
/// I2C ADC EXTENDER///////////////////////
Adafruit_ADS1115 ads(0x48);
/// WIFI//////////////////////////////
char auth[] = "cba1761bec994abaac3a66a17892c8cf";
char ssid[] = "hotspotkokobodo";
char pass[] = "kokobodo1";
SimpleTimer timer;
int A=0;
int B=0;
int C=0;
  
///////////////////////////////////////////////////////////////////////////////////////
void sensor()
{ int16_t adc0,adc1,adc2,adc3; // inisialisasi pin ADC dari ads1115 alamat 0x49 - vcc
adc0 = ads.readADC_SingleEnded(4); 
adc1 = ads.readADC_SingleEnded(5); 
adc2 = ads.readADC_SingleEnded(6); 


A=map(adc0,3100,6800,0,100);
B=map(adc1,4000,9800,0,100);
C=map(adc2,3800,9900,0,100);

Blynk.virtualWrite(V5 ,A);
Blynk.virtualWrite(V6 ,B);
Blynk.virtualWrite(V7 ,C);

}
/////////////////////////////////////////////////////////////////////////////////////////////  
void setup()
{
  Serial.begin(115200);
  Wire.begin(D1,D2);
  Blynk.begin(auth, ssid, pass);
  ads.setGain(GAIN_ONE);
  ads.begin();
  timer.setInterval(1000L, sensor);
  }

void loop()
{
  Blynk.run();
  timer.run();
}

Still not working on Blynk


#9

@Kukuh_Priambodo what did you learn by studying the existing ADS1115 projects?


#10

I dont know much about ads1115. I just want to add an analog pin from nodemcu, so I can send ADC value to Blynk app. That is all. Maybe you have some suggestions on this so that I can send more than one ADC value to Blynk app. Thankyou @Costas


#11

@Kukuh_Priambodo to get the most out of Blynk and the internet generally you need to be able to search.


#12

I’ve tried but cannt send to blynk


#13

#14

@Kukuh_Priambodo did you copy the sketch exactly?

Did you try a basic blink LED sketch before moving on to the ADS1115?


#15
#define BLYNK_PRINT Serial
#define BLYNK_MAX_SENDBYTES 256
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

char auth[] = "cba1761bec994abaac3a66a17892c8cf";
char ssid[] = "hotspotkokobodo";
char pass[] = "kokobodo1";
SimpleTimer timer;

void READ()
{
int x=0;
x = analogRead(A0); 
Blynk.virtualWrite(V0 ,x);
}

void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, READ);
  }

void loop()
{
  Blynk.run();
  timer.run();
}

[260] Connecting to hotspotkokobodo
[1263] Connected to WiFi
[1263] IP: 192.168.137.192
[1263] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.8 on NodeMCU

[5001] Connecting to blynk-cloud.com:8442
[5795] Ready (ping: 1ms).

Thanks for your attention @Costas