A place to put your YouTube video that is ESP8266 related.

User avatar
By m33600
#45365 This is it.
ESP8266 analog port reads the analog multimeter needle coil voltage, and send to a broker.
The trick is to publish the absolute angle ( 0 to 100% analog scale = 0 to max scale voltage) tha is the same no matter what function the multimeter is set to. Now ESP measures volts, amps, uF, Ohm, AC... and so on. Depends on the quality of your analog multimeter. Best for those with common ground .
>> how to http://settima.com.br/wordpress/cloud-logger-com-multimetro-analogico/



Code: Select all/* using pinouts from copacabana ESP board (info pn www.copacabana.io)
 * 
* S13: contato seco ou saida com pullup 4k7 : gpio13, nome na placa = S13
* rele builtin: GPIO45 ( sem rele fica como OC1 ( open collector 1) digital 5
* saida OC2 : open collector 2 = GPIO 54  digital 4
* G0 = gpio0, usado na programação, depois liberado pelo programa
* led NET (vermelho) = GPIO14
* led OK (verde) = GPIO12
* led rele vinculado ao rele em GPIO45  (d5)
* ADC = analog input A0
*
*   pinMode(5, OUTPUT);  // pino do Rele... criar alias para facilitar
  digitalWrite(5, 0);
  pinMode(12, OUTPUT); // led verde, ok
  digitalWrite(12, 0);
  pinMode(14, OUTPUT);  //led vermelho, net
  digitalWrite(14, 1);
 */



#include <SPI.h>
#include <ESP8266WiFi.h>
#include <ThingerWifi.h>

#define USERNAME "yourUserNameOnThinger.io"
#define DEVICE_ID "yourDevideIdFromThinger.io"
#define DEVICE_CREDENTIAL "yourDeviceCredentialsFromThinger.io"

#define SSID "yourWifiSsid"
#define SSID_PASSWORD "wifiPassword"

ThingerWifi thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

void setup() {
  pinMode(BUILTIN_LED, OUTPUT);

  pinMode(5, OUTPUT);  // pino do Rele... criar alias para facilitar
  digitalWrite(5, 0);
  pinMode(12, OUTPUT); // led verde
  digitalWrite(12, 0);
  pinMode(14, OUTPUT);  //led vermelho
  digitalWrite(14, 1);
    pinMode(4, OUTPUT); // led verde
  digitalWrite(12, 0);

  thing.add_wifi(SSID, SSID_PASSWORD);

  // resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
     
  thing["led_esp"] << [](pson& in){ digitalWrite(BUILTIN_LED, in ? LOW : HIGH); }; // led do esp12 azul
  thing["led_ok"] << [](pson& in){ digitalWrite(12, in ? HIGH : LOW); };
  thing["rele_1"] << [](pson& in){ digitalWrite(5, in ? HIGH : LOW); };  //inverti HIGH e LOW para combinar com a API no site thinger.io
  thing["rele_2"] << [](pson& in){ digitalWrite(4, in ? HIGH : LOW); };  //inverti HIGH e LOW para combinar com a API no site thinger.io
  thing["led_net"] << [](pson& in){ digitalWrite(14, in ? HIGH : LOW); };  //inverti HIGH e LOW para combinar com a API no site thinger.io
 // thing["led-ok"] << [](pson& in){ digitalWrite(12, in ? HIGH : LOW); };  //inverti HIGH e LOW para combinar com a API no site thinger.io

  // resource output example (i.e. reading a sensor value)
  thing["millis"] >> [](pson& out){ out = millis(); };
  thing["voltagem"] >> [](pson& out){out = analogRead(A0)-8;}; // icluí por conta essa variável, na sintaxe que conhecia...

  // resource input/output example (i.e. passing input values and do some calculations)
  thing["in_out"] = [](pson& in, pson& out){
      out["sum"] = (long)in["value1"] + (long)in["value2"];
      out["mult"] = (long)in["value1"] * (long)in["value2"];
  };
}

void loop() {
  thing.handle();
}