© 2024 EasyEDA Some rights reserved ISO/IEC
1.Easy to use and quick to get started
2.The process supports design scales of 300 devices or 1000 pads
3.Supports simple circuit simulation
4.For students, teachers, creators
1.Brand new interactions and interfaces
2.Smooth support for design sizes of over 5,000 devices or 10,000 pads
3.More rigorous design constraints, more standardized processes
4.For enterprises, more professional users
STD esp ammeter
License: Public Domain
Mode: Editors' pick
ammeter esp
arduino code
#include <ESP8266WiFi.h>
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#define WIFI_SSID "yours" //имя сети
#define WIFI_PASS "yours" //пароль сети
#define DEVICE_ID "client" //ид устройства
#define TCP_HOST 127.0.0.1 //ип сервера
#define TCP_PORT 80 //порт сервера
#define ADC_ICAL 80 //кофицент катушки, подстраивается для каждой
#define ADC_COUNTS (1<<10)
WiFiClient client;
char allDroid[16] = {'\0'};
uint16_t sampleI;
double offsetI;
double filteredI;
double sumI = 0;
void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
delay(1000);
WiFi.hostname(DEVICE_ID);
offsetI = ADC_COUNTS>>1;
sbigin();
}
void sbigin() {
WiFi.begin(WIFI_SSID, WIFI_PASS);
while(WiFi.status() != WL_CONNECTED) Serial.print(".");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
if(!client.connect(TCP_HOST, TCP_PORT)) {
WiFi.disconnect();
Serial.println("Не удалось поключится к серверу");
delay(100);
return sbigin();
}
for (unsigned int n = 0; n < 1000; n++) {
sampleI = analogRead(A0);
offsetI = (offsetI + (sampleI-offsetI)/1024);
filteredI = sampleI - offsetI;
sumI += (filteredI * filteredI);
}
double ratio = ADC_ICAL *(3.3 / (ADC_COUNTS));
ratio = ratio * sqrt(sumI / 1000);
sumI = 0;
Serial.print("Амперы ");
Serial.println(ratio);
sprintf(allDroid, "%s,%i,%f", DEVICE_ID, WiFi.RSSI(), ratio);
Serial.print("Пакет даных ");
Serial.println(allDroid);
client.println(allDroid);
client.stop();
memset(allDroid, 0, sizeof(allDroid));
WiFi.disconnect();
delay(20000);
return sbigin();
}
void loop() {
}
ID | Name | Designator | Footprint | Quantity |
---|---|---|---|---|
1 | power | 5V | HDR-M-2.54_1X2 | 1 |
2 | 10uF | C1 | CASE-A_3216 | 1 |
3 | 4.7uF 6v | C2 | CASE-A_3216 | 1 |
4 | 0.1u | C3 | C1206 | 1 |
5 | 10nf 6v | C4 | CASE-A_3216 | 1 |
6 | K2-3.6×6.1_SMD | FLASH,RESET | KEY-SMD_2P-L6.2-W3.6-LS8.0 | 2 |
7 | rt tx | J1 | HDR-M-2.54_1X2 | 1 |
8 | ESP-12 | MK1 | WIFIM-SMD_ESP-12E-BR | 1 |
9 | 10k | R1,R2,R4,R5 | R0402 | 4 |
10 | 22 1w | R3 | R2512 | 1 |
11 | tran | TRA | HDR-M-2.54_1X2 | 1 |
12 | AMS1117-3.3V | U1 | SOT-223-4_L6.5-W3.5-P2.30-LS7.0-BR | 1 |
Unfold
Loading...
Do you need to add this project to the album?