Sistem de monitorizare consum energie electrica(bransament trifazat) realizat cu Arduino Uno


Arduino

#include<LiquidCrystal.h>

#include<Ethernet.h>

#include<SPI.h>

#include<avr/wdt.h>

#include<OneWire.h>

#include<DallasTemperature.h>

 

//Datawireispluggedintoport6ontheArduino

#defineONE_WIRE_BUS6

#defineTEMPERATURE_PRECISION9

intDS18S20_Pin=6;//DS18S20Signalpinondigital6

 

//SetupaoneWireinstancetocommunicatewithanyOneWiredevices(notjustMaxim/DallastemperatureICs)

OneWireoneWire(ONE_WIRE_BUS);

//PassouroneWirereferencetoDallasTemperature.

DallasTemperaturesensors(&oneWire);

 

//Networkconstants

bytemac[]={0x00,0x23,0xdf,0x82,0xd4,0x01};

IPAddressip(192,168,0,177);

IPAddressserver(212,146,85,89);//free-energy-monitor.com

intport=80;

LiquidCrystallcd(9,8,5,4,3,2);

 

 

 

EthernetClientclient;

//Clientclient(server,port);

//intlightPin=0;//defineapinforPhotoresistor

floatIf=0,Ie=0,U=0;

intsequence;

floattemp_bat=0,temp_mediu=0;

 

intblocaj=0,sensorValue;

booleanflag_setat=false;

 

intreciever=0;

 

voidsetup(){

 

pinMode(2,OUTPUT);

sensors.begin();

Serial.begin(9600);

lcd.begin(16,2);

lcd.print("StartMonitor!");

sequence=0;

Ethernet.begin(mac,ip);

delay(1000);

 

if(blocaj==1){

//resethardware

blocaj=0;

digitalWrite(7,LOW);//pinuldigital3conectatprinfirlapinuldeRESET

}

wdt_enable(WDTO_8S);

}

 

voidloop(){

 

wdt_reset();

if(!flag_setat){

blocaj=1;

flag_setat=true;

}

 

sensorValue=analogRead(A5);//readanaloginputpin0

U=(float)((sensorValue)*25)/1023;

U=(float)U*4.00;

 

sensorValue=(analogRead(A4)-507);

if(sensorValue==1orsensorValue==-1)sensorValue=0;

If=(float)sensorValue*0.215;

 

sensorValue=(analogRead(A3)-507);

if(sensorValue==1orsensorValue==-1)sensorValue=0;

Ie=(float)sensorValue*0.215;

 

sensors.requestTemperatures();

temp_bat=sensors.getTempCByIndex(0);

temp_mediu=sensors.getTempCByIndex(1);

 

httpPut("http://free-energy-monitor.com/quickstart.php?lumina=");

Serial.println(sequence);

sequence++;

lcd.setCursor(0,0);

reciever=digitalRead(2);

 

delay(1000);

lcd.clear();

//Serial.flush();

}

 

voidhttpPut(char*url){

if(!client.connect(server,port)){

Serial.println("EXCEPTION:duringHTTPPUT.Couldnotconnect");

lcd.setCursor(0,0);

lcd.print("EXCEPTION:HTTPPUT.");

lcd.setCursor(0,1);

lcd.print("Couldnotconnect");

//delay(5000);

delay(2000);

return;

}

 

client.print("POST");

client.print("");

client.print(url);

client.print(If);

client.print("&tensiune=");

client.print(U);

client.print("&curent=");

client.print(Ie);

client.print("&temp_bat=");

client.print(temp_bat);

client.print("&temp_mediu=");

client.print(temp_mediu);

client.print("&tabela=data_log_securiceni");

client.println("HTTP/1.0");

client.println();

 

 

lcd.setCursor(0,0);

//lcd.print("U=");

lcd.print(U,1);

 

lcd.setCursor(4,0);

lcd.print("If=");

lcd.print(If,1);

 

lcd.setCursor(10,0);

lcd.print("Ie=");

lcd.print(Ie,1);

 

lcd.setCursor(0,1);

lcd.print("Tb=");

lcd.print(temp_bat,1);

 

lcd.setCursor(8,1);

lcd.print("Tm=");

lcd.print(temp_mediu,1);

 

 

while(!client.available()){

//Serial.read();

delay(500);

}

while(client.available()){

charc=client.read();

Serial.print(c);

}

while(client.connected()){

Serial.println("Waitingforservertodisconnect");

lcd.setCursor(0,0);

lcd.print("Waitingforserver");

lcd.setCursor(0,1);

lcd.print("todisconnect");

client.stop();

delay(500);

}

client.stop();

//Serial.end();

delay(500);

return;

 

}

Denumire componentaDenumire comerciala (ebay)Pret (ebay)
Placa Arduino Uno2013 Version ATmega32U2 ATmega328P UNO R3 Board & Free USB Cable for Arduino DIY10$
Modul ethernetEthernet Shield W5100 Network Expansion Board For Arduino UNO R3 Mega 25607.12.$
Senzor curent noninvaziv 100AHall Effect Current Sensor For Hobbyist, Arduino Compatible, AC 75A DC 100A9$
Senzor de tensiune 80VOctopus Voltage Divider Module Electronic Bricks for Arduino4.69$
Senzor de temperaturaDS18B20 Waterproof Temperature Sensors Thermistor Temperature Control hv2n2.06$

Noutati

Real-time data: monitorizare in timp real productie energie fotovoltaica/eoliana;


Romania ramane intre cele mai atractive piete din lume pentru energii regenerabile, conform noului raport Country Attractiveness Indices, lansat de Ernst & Young. . Continuare pe ziare.com...

Contact

-

Phone: +4(0740) 041 234
Address: -
E-mail: dutuc_nicolae@hotmail.com

Suport online