Aquarium control help

Good evening, I wanted to make an aquarium control. This control includes a flow meter www.aliexpress.com/…/pm=2114.13010608.0.0.xKGRYd

two light-sensitive sensor ky-018

1 temperature sensor www.aliexpress.com/…/pm=2114.13010608.0.0.xKGRYd

I should be turning on the lights, a filter, a heater via relay. This I managed to do it. I can not manage to eventor the temperature sensor the flow meter and light-sensitive sensor. I combine it with a virtual pin, but do not understand how.

Your links are broken mate :slight_smile:

I’m sorry, but I don’t understand… can you clarify the issue? And perhaps include your code so we can compare it with your description.

And please format your code when posting it here:

1 Like

@Gunner, Nice illustration!

Darn dyslexic fingers :stuck_out_tongue: You are the first to notice, good catch!

Honestly I actually never use cpp when formatting my code… and have not yet ran into an issue, but now I will fix my FTFC picture :blush:

2 Likes

prejudice to excuse my English. They needed libraries for sensors above list. who can help me?

Your links are broken.

The KY-018 is a simple Light Detecting Resistor on a board, outputting an analog range of 0-1023, no library required for that.

But any libraries required by any other sensor will need to be sourced from the manufacture site, sellers site, or found through Google on some instructable or something. That is not something supplied by Blynk.

We would also need to see your existing code to even begin to understand what you are doing.

The board has not yet been received. I was carrying on the work awaiting the board

#include <SoftwareSerial.h>
#define BLYNK_PRINT Serial
#include <SPI.h>
char auth[] = "*****";
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
int sensorPin = 0; //define analog pin 1
int value = 0; 
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "******";
char pass[] = "******";

// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial

// or Software Serial on Uno, Nano...
SoftwareSerial softSerial(10, 11); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);
// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin V1
BLYNK_WRITE(V1)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable

  // process received value
}
#include <math.h>
#define Ro 10000      // Valore NTC a 25°C
#define NTCPIN A0     // Pin di collegamento NTC
#define Tnom 25       // Temperatura nominale NTC
#define B 3960        // Coeff. Beta della NTC (dai datasheet)
#define R1 10000

float Temp;     //7 serve al sensore

float RNTC;
float x;
float t;
float T;





void setup() 
{
  uint32_t baud = 115200;
  Serial.begin(baud);
  softSerial.begin(baud);
  Serial.print("SETUP!! @");
  Serial.println(baud);
   // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
}

void loop() 
{

              Serial.print("Temp=");  
              Serial.println(misTemp());
              delay(1000);

}

// Funzione che misura la temperatura
float misTemp() {
Temp=analogRead(A0);


x=(Temp/1023)*5;   // proporzione

RNTC=(R1*5/x)-R1;

t=(1/Tnom)*(log(RNTC/Ro)/B);

T=(1/t)-273,15;

        Blynk.virtualWrite(1, T);      
        Blynk.run();
   
    
    
}

what am I doing wrong? A screen appears

That is a vague question :wink:

This forum is not a code factory… or general repair depot for broken code…

However, your void loop() contains a delay that will compromise connection, and is broken… no Blynk.run(); or proper timer usage for your misTemp() loop.

#include <SoftwareSerial.h>
#define BLYNK_PRINT Serial
#include <SPI.h>
char auth[] = "bxxxxxxxxxxxxxxx6f";
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
int ThermistorPin = 0;
int Vo;
float R1 = 10000;
float logR2, R2, T, Tc, Tf;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "FAxTxWxEB-1-x";
char pass[] = "boexxxxxxxx8x8";

// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial

// or Software Serial on Uno, Nano...
SoftwareSerial softSerial(10, 11); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);
// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin V1
BLYNK_WRITE(V1)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable

  // process received value
}

void setup() 
{
   
  uint32_t baud = 115200;
  Serial.begin(baud);
  softSerial.begin(baud);
  Serial.print("SETUP!! @");
  Serial.println(baud);
   // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
}

void loop() 
{
   Blynk.run(); 

  Vo = analogRead(ThermistorPin);
  R2 = R1 * (1023.0 / (float)Vo - 1.0);
  logR2 = log(R2);
  T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  Tc = T - 273.15;
  Tf = (Tc * 9.0)/ 5.0 + 32.0; 

  Serial.print("Temperature: "); 
  Serial.print(Tf);
  Serial.print(" F; ");
  Serial.print(Tc);
  Serial.println(" C");   

 Blynk.virtualWrite(2,A1 ); //pin virtuale lampada spot

Blynk.virtualWrite(3,A2 ); //pin virtuale lampada uv
  Blynk.virtualWrite(1,Tc ); //pin virtuale lampada temp
  
   delay(10000);

      
}

But how do you disconnect from the server every 50 seconds?

@ture26488 you need to modify your loop() to use BlynkTimer.

I don’t know if these functions work with Arduino’s but they are fine with ESP’s.

Blynk.disconnect();

Blynk.connect();

With a 50s timer etc.

1 Like

If I do not have this feature I have a continuous disconnection. It’s not stable

It’s not stable because you can’t have a loop() like that.

1 Like

Can you help me? What do I write in the loop

Check out the PUSH DATA example in the Sketch Builder.

1 Like

Thanks Problem Solved. Now I add the other sensors

1 Like

Hi, I do not write the value of pin a1 in v2. Why?

 Blynk.virtualWrite(2,A1 ); //pin virtuale lampada spot

You have the following in your sketch:

#define NTCPIN A0 

and no mention of A0 as far as I can see.

If you are picking up data from the A0 port then you need:

Blynk.virtualWrite(2, NTCPIN ); //pin virtuale lampada spot

1 Like