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

W5100 & Pzem 004t & Blynk


#1

hi every one
i got arduino uno, w5100 ethernet shield, dht11 temp module and Pzem 004t energy module for my project
i wanna show tempreature and energy values on my phone with blynk
when i try dht11 with w5100 i can see values on my phone
or if i use Pzem 004t with w5100 i can see values on serial monitor
But i can’t see on blynk app

here is my code

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <DHT.h>
#include <SoftwareSerial.h> // Arduino IDE <1.6.6
#include <PZEM004T.h>

char auth[] = "f538833fdf264c0cbaafdb066e10aa81";

#define W5100_CS  8


#define DHTPIN 2          // What digital pin we're connected to


#define DHTTYPE DHT11     // DHT 11

DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
PZEM004T pzem(10,11);
IPAddress ips(192,168,1,1);


void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
 
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
  

  float v = pzem.voltage(ips);
   float i = pzem.current(ips);
   float p = pzem.power(ips);
   float e = pzem.energy(ips);

  Blynk.virtualWrite(V1, v);
  Blynk.virtualWrite(V2, i);
  Blynk.virtualWrite(V3, p);
  Blynk.virtualWrite(V4, e);
  
  
}



void setup()
{

  Serial.begin(9600);
  pzem.setAddress(ips);


  Blynk.begin(auth, "blynk-cloud.com", 8442);
  dht.begin();

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
 
}

void loop()
{

  
  
  Blynk.run();
  timer.run();
}

Anyone have an idea for reason
Sorry for my bad English thanx for replies


#2

Pin 10 and 11 which you are using for Software Serial is needed for W5100 SPI interface. try changing those pins for other free (2,3?) or some analog ports,as they are not used here…


#3

Thanks Marvin solved :smile: