Answers:
您可以检查一下Tweet-a-Watt,看看它是否可以在220V电源线上使用。该项目至少应该给您一个入门的思路。
看一下这些项目:
足够?;-)
创建准确的功率计并非易事。您需要一种以足够的精度和速度感测电压和电流的方法,以检测它们之间的相位差(功率因数)并计算有功功率和视在功率。您几乎需要使用DSP。
创建基本的功率计可以通过感应和直流平均电压和电流来完成,而无需考虑无功功率和高速采样的需求。精度将随负载质量的变化而变化。
市场上有专门用于功率计量的IC,例如Microchip MCP3909,您可以将其与Arduino一起使用。
来自Smart Energy Groups的此系统可能很有趣,它基于Arduino硬件等。
我一直在广泛使用ESP8266(带有Arduino IDE)以及各种ADC和专用的能源监控DSP(ATM90E26和ADE7763)来构建网络连接的能源监控器。
基本ADC + Wifi启用Arduino兼容NodeMCU的Fritzing图如下所示:
上面说明了使用ESP8266能源监控器的代码。请注意,这是一种低精度的方法,很容易实现使用变压器对电压和CT电流进行采样的解决方案。更高精度的解决方案需要直接采样240V(使用分压器阶梯和分流电阻器),并需要考虑其他设计因素,以处理高压工作引起的问题。
/*
* This sketch sends ads1115 current sensor data via HTTP POST request to thingspeak server.
* It needs the following libraries to work (besides the esp8266 standard libraries supplied with the IDE):
*
* - https://github.com/adafruit/Adafruit_ADS1X15
*
* designed to run directly on esp8266-01 module, to where it can be uploaded using this marvelous piece of software:
*
* https://github.com/esp8266/Arduino
*
* 2015 Tisham Dhar
* licensed under GNU GPL
*/
#include <ESP8266WiFi.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
// replace with your channel's thingspeak API key,
String apiKey = "XXXXXXXXXXXXX";
//WIFI credentials go here
const char* ssid = "XXXXXXXXXXX";
const char* password = "XXXXXXXXXXXXXXXXXXXXX";
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
const char* server = "api.thingspeak.com";
WiFiClient client;
double offsetI;
double filteredI;
double sqI,sumI;
int16_t sampleI;
double Irms;
double squareRoot(double fg)
{
double n = fg / 2.0;
double lstX = 0.0;
while (n != lstX)
{
lstX = n;
n = (n + fg / n) / 2.0;
}
return n;
}
double calcIrms(unsigned int Number_of_Samples)
{
/* Be sure to update this value based on the IC and the gain settings! */
float multiplier = 0.125F; /* ADS1115 @ +/- 4.096V gain (16-bit results) */
for (unsigned int n = 0; n < Number_of_Samples; n++)
{
sampleI = ads.readADC_Differential_0_1();
// Digital low pass filter extracts the 2.5 V or 1.65 V dc offset,
// then subtract this - signal is now centered on 0 counts.
offsetI = (offsetI + (sampleI-offsetI)/1024);
filteredI = sampleI - offsetI;
//filteredI = sampleI * multiplier;
// Root-mean-square method current
// 1) square current values
sqI = filteredI * filteredI;
// 2) sum
sumI += sqI;
}
Irms = squareRoot(sumI / Number_of_Samples)*multiplier;
//Reset accumulators
sumI = 0;
//--------------------------------------------------------------------------------------
return Irms;
}
void setup() {
Serial.begin(115200);
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
ads.begin();
}
void loop() {
//Serial.print("Differential: "); Serial.print(results); Serial.print("("); Serial.print(trans_volt); Serial.println("mV)");
double current = calcIrms(2048);
if (client.connect(server,80)) { // "184.106.153.149" or api.thingspeak.com
String postStr = apiKey;
postStr +="&field1=";
postStr += String(current);
postStr += "\r\n\r\n";
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
}
client.stop();
//Serial.println("Waiting...");
// thingspeak needs minimum 15 sec delay between updates
delay(20000);
}