You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EN - I have an Arduino UNO with SKECTH:
PT-Br - Tenho um Arduino UNO com o SKECTH:
#include <Wire.h>
#include "EmonLib.h"
#define VOLT_CAL 211.6
#define PIN_Voltagem A0
#define PIN_Corrente A1
#define INTERVALO_LEITURA 5000 // Intervalo de leitura em milissegundos (5 segundos)
float Irms =0;
float Vrms = 0;
float Watts = 0; // Cálculo da potência ativa
float kWh = 0; // Cálculo do consumo de energia
float FP = 0; // Cálc
unsigned long tempoEmSegundos; // Tempo em segundos
unsigned long tempoAnterior = 0; // Armazena o tempo da última leitura
EnergyMonitor energyMonitor;
void setup() {
Serial.begin(9600);
Wire.begin(8); // join I2C bus with address #8
Wire.onRequest(requestEvent); // register event
tempoEmSegundos = 0;
energyMonitor.current(PIN_Corrente, 60.607); // Calibração da corrente
energyMonitor.voltage(PIN_Voltagem, VOLT_CAL, 1.7); //PASSA PARA A FUNÇÃO OS PARÂMETROS (PINO ANALÓGIO / VALOR DE CALIBRAÇÃO / MUDANÇA DE FASE)
}
void loop(){
unsigned long tempoAtual = millis();
// Verifica se o intervalo de leitura foi atingido
if (tempoAtual - tempoAnterior >= INTERVALO_LEITURA)
{
// Atualiza o tempo da última leitura
tempoAnterior = tempoAtual;
// Atualiza os valores
energyMonitor.calcVI(17, 2000); // Cálculo de V e I
Irms = energyMonitor.calcIrms(1480); // Correção da corrente RMS
Vrms = energyMonitor.Vrms; // Leitura da tensão RMS
Watts = energyMonitor.realPower; // Cálculo da potência ativa
kWh = (Watts * (tempoAtual / 3600000.0)); //Cálculo do consumo de energia em kWh
FP = energyMonitor.powerFactor; // Cálculo do fator de potência
// Atualizar saídas
digitalWrite(LED_BUILTIN, HIGH); // Ligar o LED interno (apenas para fins de teste)
// Adicione aqui a lógica para controlar outros dispositivos de saída, se necessário
// Log dos valores no Serial Monitor
Serial.print("Vrms: ");
Serial.println(Vrms);
Serial.print("Irms: ");
Serial.println(Irms);
Serial.print("Watts: ");
Serial.println(Watts);
Serial.print("kWh: ");
Serial.println(kWh);
Serial.print("FP: ");
Serial.println(FP);
Serial.println("----------");
}
// Outras tarefas podem ser adicionadas aqui
}
void requestEvent() {
// Enviar os valores via I2C
Wire.write((byte*)&Vrms, sizeof(Vrms));
Wire.write((byte*)&Irms, sizeof(Irms));
Wire.write((byte*)&Watts, sizeof(Watts));
Wire.write((byte*)&kWh, sizeof(kWh));
Wire.write((byte*)&FP, sizeof(FP));
}
PT[bR] - Também tenho um Esp8266(12-E) rodando no espHome e conectado ao: arduino_port_expander.h
EN - I also have an Esp8266(12-E) running on espHome and connected to: arduino_port_expander.h
esphome:
name: esp12e-bulbasaur
friendly_name: esp12e-bulbasaur
# includes:
# - arduino_port_expander.h
libraries:
- ESP8266WiFi
- https://github.com/akaJes/AsyncPing #95ac7e4
- https://github.com/openenergymonitor/EmonLib
esp8266:
board: esp01_1m
# Enable logging
logger:
level: DEBUG
# deep_sleep:
# run_duration: 1min
# sleep_duration: 3min
# id: sleep_esp8266
# Enable Home Assistant API
api:
encryption:
key: "+dJzfYOLYyENb7og6f7gVDKhiG7XOgUE4DEZQYGApjg="
ota:
password: "d92927574545cc20303e8c2dd1ff1578"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp12E-Bulbasaur"
password: "rVkne1a5T8pE"
manual_ip:
# Set this to the IP of the ESP
static_ip: 192.168.2.23
# Set this to the IP address of the router. Often ends with .1
gateway: 192.168.2.1
# The subnet of the network. 255.255.255.0 works for most home networks.
subnet: 255.255.255.0
# dns1: 192.168.2.1
# dns2: 8.8.8.8
captive_portal:
external_components:
- source: github://ayufan/esphome-components
- source:
type: git
url: https://github.com/trombik/esphome-component-ping
ref: main
- source:
type: git
url: https://github.com/gaitolini/esphome/
ref: my-new-feature
components: [zmpt101b]
refresh: 1min
- source: github://glmnet/esphome@ape-external-component
components: [arduino_port_expander]
refresh: 1min
mqtt:
broker: 192.168.2.75
port: 1883
username: mqtt-gaitolini
password: gaitolini
discovery: true
discovery_retain: true
birth_message:
topic: bulbasaur/status
payload: online
will_message:
topic: bulbasaur/status
payload: offline"
log_topic:
topic: bulbasaur/log
level: ERROR
qos: 1
# uart:
# tx_pin: 1
# rx_pin: 3
# baud_rate: 9600
memory:
i2c:
id: i2c_arduino
sda: GPIO04
scl: GPIO05
scan: True
arduino_port_expander:
id: x
i2c_id: i2c_arduino
address: 0x08
analog_reference: DEFAULT
PT[Br] - Gostaria de ler os dados do Arduino no esp8266 via I2C pelo arduino_port_expander
Mas não consigo abstrair o código, não se é possível
Aceito sugestões
EN - I would like to read Arduino data on esp8266 via I2C by arduino_port_expander
But I can't abstract the code, I don't know if it's possible
Context:
On the Arduino I want to use the Analog pin inputs with SCT013 100a and ZMPT101B sensors
They both provide me with data about my electrical network in Home Assistant.
I decided to mount this shield on the Arduino.
I accept suggestions
The text was updated successfully, but these errors were encountered:
EN - I have an Arduino UNO with SKECTH:
PT-Br - Tenho um Arduino UNO com o SKECTH:
PT[bR] - Também tenho um Esp8266(12-E) rodando no espHome e conectado ao: arduino_port_expander.h
EN - I also have an Esp8266(12-E) running on espHome and connected to: arduino_port_expander.h
PT[Br] - Gostaria de ler os dados do Arduino no esp8266 via I2C pelo arduino_port_expander
Mas não consigo abstrair o código, não se é possível
Aceito sugestões
EN - I would like to read Arduino data on esp8266 via I2C by arduino_port_expander
But I can't abstract the code, I don't know if it's possible
Context:
On the Arduino I want to use the Analog pin inputs with SCT013 100a and ZMPT101B sensors
They both provide me with data about my electrical network in Home Assistant.
I decided to mount this shield on the Arduino.
I accept suggestions
The text was updated successfully, but these errors were encountered: