VAWT ThingSpeak : o solutie de vizualizare online a parametrilor de functionare a unei turbine eoliene verticale .
https://thingspeak.com/channels/22793
Codul pentru Arduino
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
#include <dht.h> #include <Ethernet.h> #include <SPI.h> #include <Wire.h> #include <avr/wdt.h> #include "ThingSpeak.h" int t = 0; int h = 0; float val11=0; float val2=0; float i1 = 0; float i = 0; float curent=0; float tensiune=0; float sample1=0; float sample2=0; float sample3=0; float p=0; int turatie = 0; int AC = 0; int lastAC = 0; dht DHT; byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; IPAddress ip(192, 168, 1, 100); IPAddress myDNS(192, 168, 1, 1); IPAddress Gateway(192, 168, 1, 1); // char server[] = "www.thingspeak.com"; IPAddress server(184, 106, 153, 149); EthernetClient client; unsigned long myChannelNumber = 22793; const char * myWriteAPIKey = "xxxxxxxxxx"; void setup() { Serial.begin(9600); Ethernet.begin(mac, ip, myDNS, Gateway); ThingSpeak.begin(client); } void loop() { DHT.read11(A0); // se citeste senzorul de temperatura si umiditate h = DHT.humidity; t = DHT.temperature; /// se stabileste numarul de valori care se mediaza si timpul dintre doua masuratori for(int i=0;i<2500;i++) { sample1+=analogRead(A1); //se citeste sensorul de tensiune sample2+=analogRead(A2); //se citeste senzorul de curent AC = digitalRead(2); // Se contorizeaza trecerea prin "0" if ((AC == LOW) && (AC != lastAC )) { sample3++; } lastAC= digitalRead(2); delay(5); } sample1=sample1/2500; sample2=sample2/2500; //////////////////////////////////////////// ///se calculeaza valorile float temp; val11=sample1; temp=val11/4.092; val2=(temp/10); i1 = sample2; i = ((.0049 * i1) - 2.5)/.066; p=i*val2; turatie=sample3*60/8/15; ThingSpeak.setField(1,val2); ThingSpeak.setField(2,i); ThingSpeak.setField(3,p); ThingSpeak.setField(4,turatie); ThingSpeak.setField(5,t); ThingSpeak.setField(6,h); ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); } |