Editor Version ×
Standard

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

Profession

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

Ongoing

STD esp ammeter

License: Public Domain

Mode: Editors' pick

  • 553
  • 0
  • 0
Update time: 2021-12-25 22:43:07
Creation time: 2021-12-24 21:43:34
Description
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() {
}
 
Design Drawing
schematic diagram
1 /
PCB
1 /
The preview image was not generated, please save it again in the editor.
Project Attachments
Empty
Project Members
Related Projects
Change a batch
Loading...
Add to album ×

Loading...

reminder ×

Do you need to add this project to the album?

服务时间

周一至周五 9:00~18:00
  • 0755 - 2382 4495
  • 153 6159 2675

服务时间

周一至周五 9:00~18:00
  • 立创EDA微信号

    easyeda

  • QQ交流群

    664186054

  • 立创EDA公众号

    lceda-cn