Jak wyświetlić V zamiast stopni w woltomierzu?

piomar2
Posts: 369
Joined: Fri Apr 26, 2019 5:32 pm
Location: Bukowice

Post

Witam!

Jak wyświetlić V zamiast stopni w woltomierzu?

"Do V jest kanał „licznik energii” - tak podpowiedział mi pzygmunt.

Nie bardzo wiem jak to zrobić. To szczegół, ale byłoby pięknie - woltomierz i V.

program:

Code: Select all

//Wemos D1 mini
//A0 - pomiar napięcia (max 3,2 V)
//Dzielnik 90k+10k(potencjometr)/10k (max 30 V)


#include <srpc.h>
#include <log.h>
#include <eh.h>
#include <proto.h>
#include <IEEE754tools.h>
#define SUPLADEVICE_CPP
#include <SuplaDevice.h>
#include <lck.h>

#include <WiFiClient.h>
#include <ESP8266WiFi.h>
#include <WiFiServer.h>

#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>

WiFiClient client;

const char* ssid     = "xxxx";
const char* password = "xxxx";

int analogInput = 0;
float vout = 0.0;
float vin = 0.0;
float R1 = 100000.0; // R1 - 100K
float R2 = 10000.0; // R2 - 10K
int value = 0;

//--------------------------------------------------------------
double get_temperature(int channelNumber, double last_val) {

    double t = -275;
    value = analogRead(analogInput);
    vout = (value * 3.3) / 1024.0;
    vin = vout / (R2/(R1+R2)); 
      if (vin<0.09) {
          vin=0.0;
         } 
        t=vin;
    return t;  
}
//-------------------------------------------------------------
void setup() {
  
  // Replace the falowing GUID
char GUID[SUPLA_GUID_SIZE] = {0x3B,0x84,0x77,0xCC,0xE0,0xC9,0xC1,0xA3,0x69,0x39,0x73,0x7D,0xDF,0xFC,0x07,0x4F};
 
 // with GUID that you can retrieve from https://www.supla.org/arduino/get-guid
  
  // Ethernet MAC address
  uint8_t mac[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

  // CHANNEL 0 -woltomierz
    SuplaDevice.addDS18B20Thermometer();
   
     
  SuplaDevice.begin(GUID,              // Global Unique Identifier 
                    mac,               // Ethernet MAC address
                    "xxxx",  // SUPLA server address
                    xxxx                 // Location ID 
                    "xxxx");             // Location Password}
}
//--------------------------------------------------------
void loop() {
  
  SuplaDevice.iterate(); 
}
 
// Supla.org ethernet layer
int supla_arduino_tcp_read(void *buf, int count) {
  _supla_int_t size = client.available();

  if ( size > 0 ) {
    if ( size > count ) size = count;
    return client.read((uint8_t *)buf, size);
  };

  return -1;
};

int supla_arduino_tcp_write(void *buf, int count) {
  return client.write((const uint8_t *)buf, count);
};

bool supla_arduino_svr_connect(const char *server, int port) {
  return client.connect(server, 2015);
}

bool supla_arduino_svr_connected(void) {
  return client.connected();
}

void supla_arduino_svr_disconnect(void) {
  client.stop();
}

void supla_arduino_eth_setup(uint8_t mac[6], IPAddress *ip) {

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
            delay(500);
  }
}

SuplaDeviceCallbacks supla_arduino_get_callbacks(void) {
  SuplaDeviceCallbacks cb;

  cb.tcp_read = &supla_arduino_tcp_read;
  cb.tcp_write = &supla_arduino_tcp_write;
  cb.eth_setup = &supla_arduino_eth_setup;
  cb.svr_connected = &supla_arduino_svr_connected;
  cb.svr_connect = &supla_arduino_svr_connect;
  cb.svr_disconnect = &supla_arduino_svr_disconnect;
  cb.get_temperature = &get_temperature;
  cb.get_temperature_and_humidity = NULL;
  cb.get_rgbw_value = NULL;
  cb.set_rgbw_value = NULL;

  return cb;
}
 

Ikonka i schemat (dla chętnych)

Pozdrawiam
User avatar
shimano73
Posts: 2174
Joined: Sun Feb 28, 2016 12:27 pm
Location: Orzesze
Been thanked: 1 time

Post

Arduino jeszcze nie wspiera tego kanału, chyba że czegoś nie wiem :D
W elektronice jak nie wiadomo o co chodzi to zwykle chodzi o zasilanie

Wezmę udział w Supla Offline Party 2024 :)
piomar2
Posts: 369
Joined: Fri Apr 26, 2019 5:32 pm
Location: Bukowice

Post

Też mi się tak wydawało ale pzygmunt "wzniecił" mój niepokój...
Myślałem, że czegoś nie doczytałem...dzięki

Return to “Pomoc”