Mam problem z odczytem napięcia na Pin A0 ESP8266 po uruchomieniu układu pokazuje zadaną wartość na potencjometrze ale już później jak zmieniam potencjometrem to odczyt na SUPLA już się nie zmienia a jeśli odłączę DS18B20 to wtedy pokazuje zmiany napięcia i jest Ok. i nie wiem jak tu zrobić odświeżanie pomiaru napięcia.
Proszę o pomoc może jakiś krótki programik bo na tej SUPLA i ESP8266 mam problemy nie znam tych zagadnień.
Na Arduino nie mam problemu z wejściami analogowymi A0.
Jak przesłać odczyt napięcia z Pin A0 ESP8266 na SUPLA
-
- Posty: 23
- Rejestracja: wt paź 13, 2020 11:01 am
// DS18B20 Sensor read implementation
double get_temperature(int channelNumber, double last_val) {
double t = -275;
double temp0 = 0; //dopisane
switch(channelNumber)
{
case 0:
sensors.requestTemperatures();
//t = sensors.getTempC(jeden);
t = sensors.getTempCByIndex(0);
Serial.print("Temp 1 : ");
Serial.println(t);
break;
case 1:
sensors_2.requestTemperatures();
// t = sensors_2.getTempC(dwa); // Tu musi być podany Adres(DS18B20)
t = sensors_2.getTempCByIndex(0); // D5(14)->Bez Adresu
Serial.print("Temp 2 : ");
Serial.println(t);
break;
case 2:
t = WiFi.RSSI(); //SYGNAL WiFi
Serial.print("Temp 3 : ");
Serial.println(t);
break;
case 3:
temp0 = analogRead(A0); //(A0)
t = temp0;
Serial.print("Temp 4 : ");
Serial.println(t);
break;
}
return t;
}
Wykorzystałem tak jak przy wyświetleniu Sygnału WiFi i tu działa a przy A0 tylko to co przy starcie układu odczyta
i więcej już się nie zmienia mimo iż zmieniam napięcie na Pin A0.
double get_temperature(int channelNumber, double last_val) {
double t = -275;
double temp0 = 0; //dopisane
switch(channelNumber)
{
case 0:
sensors.requestTemperatures();
//t = sensors.getTempC(jeden);
t = sensors.getTempCByIndex(0);
Serial.print("Temp 1 : ");
Serial.println(t);
break;
case 1:
sensors_2.requestTemperatures();
// t = sensors_2.getTempC(dwa); // Tu musi być podany Adres(DS18B20)
t = sensors_2.getTempCByIndex(0); // D5(14)->Bez Adresu
Serial.print("Temp 2 : ");
Serial.println(t);
break;
case 2:
t = WiFi.RSSI(); //SYGNAL WiFi
Serial.print("Temp 3 : ");
Serial.println(t);
break;
case 3:
temp0 = analogRead(A0); //(A0)
t = temp0;
Serial.print("Temp 4 : ");
Serial.println(t);
break;
}
return t;
}
Wykorzystałem tak jak przy wyświetleniu Sygnału WiFi i tu działa a przy A0 tylko to co przy starcie układu odczyta
i więcej już się nie zmienia mimo iż zmieniam napięcie na Pin A0.
-
- Posty: 23
- Rejestracja: wt paź 13, 2020 11:01 am
Wkleiłem cały program tylko to co tam wcześniej pokazałem tu już tego nie ma już i w inny sposób próbowałem
i też nic z tego. Jak byś mógł mi tu dopisać żeby wyświetlało tak jak temperaturę i sygnał WiFi też i napięcie nap.z Potencjometru w jakim jest położeniu poprzez widoczne napięcie to byłbym Bardzo Wdzięczny.
i też nic z tego. Jak byś mógł mi tu dopisać żeby wyświetlało tak jak temperaturę i sygnał WiFi też i napięcie nap.z Potencjometru w jakim jest położeniu poprzez widoczne napięcie to byłbym Bardzo Wdzięczny.
Kod: Zaznacz cały
//************* DZIALA DOBRZE NA INNYM GPIO (DS)->BEZ ADRESU SPRAWDZONE ***************************
#include <ESP8266WiFi.h>
#define SUPLADEVICE_CPP
#include <SuplaDevice.h>
#include <ESP8266WebServer.h>
#include <DNSServer.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPUpdateServer.h>
extern "C" {
#include "user_interface.h"
}
//=========== DOPISANE =====================================
//int temp0 = 0;
const int analogInPin = A0; // ESP8266 Analog Pin ADC0 = A0
int sensorValue = 0; // value read from the pot
int volt = 0;
//==========================================================
// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>
// Przewód danych jest podłączony do portu 2 na Arduino
#define ONE_WIRE 2
#define ONE_WIRE_2 4 //(D2)-(4) // (D5) DOPISANE Dodatkowy DS(3)
#define TEMPERATURE_PRECISION 10 // rozdzielczość czujnika DS 9 -12 bit
// Konfiguracja wystąpienia oneWire do komunikowania się z dowolnymi urządzeniami OneWire(nie tylko Maxim/Dallas temperatury ICs)
OneWire oneWire(ONE_WIRE);
OneWire oneWire_2(ONE_WIRE_2); //Dopisane
// Przekaż nasze odniesienie oneWire do Dallas Temperature.
DallasTemperature sensors(&oneWire);
DallasTemperature sensors_2(&oneWire_2); //Dopisane
// tablica do przechowywania adresów urządzeń
DeviceAddress jeden; //= { 0x28, 0x1B, 0x9D, 0x83, 0x32, 0x14, 0x1, 0xAF }; //DS(1)->(D4)-(2)
DeviceAddress dwa; //= { 0x28, 0xEE, 0xDE, 0x79, 0xA2, 0x1, 0x3, 0x7C }; //DS(2)->(D4)-(2)
DeviceAddress trzy; //= { 0x28, 0xAA, 0xA3, 0x2D, 0x42, 0x14, 0x1, 0xEA }; //DS(3)->(D5)-(14) BEZ ADRESU
DeviceAddress cztery; //= { 0x28, 0xFF, 0x8, 0x7E, 0xC1, 0x17, 0x2, 0xD }; // odczytany adres 28FF087EC117020D
// Setup Supla connection
const char* ssid = "*************";
const char* password = "************";
WiFiClient client;
const char* host = "supla";
const char* update_path = "/supla";
const char* update_username = "admin";
const char* update_password = "supla";
ESP8266WebServer httpServer(81);
ESP8266HTTPUpdateServer httpUpdater;
// DS18B20 Sensor read implementation
double get_temperature(int channelNumber, double last_val ) {
double t = -275;
switch(channelNumber)
{
case 0:
sensors.requestTemperatures();
//t = sensors.getTempC(jeden);
t = sensors.getTempCByIndex(0);
Serial.print("Temp 1 : ");
Serial.println(t);
break;
//----------------------------------------
case 1:
sensors_2.requestTemperatures(); //Dopisane
// t = sensors_2.getTempC(dwa); // Tu musi byc podany Adres(DS18B20)
t = sensors_2.getTempCByIndex(0); // D5(14)->Bez Adresu
Serial.print("Temp 2 : ");
Serial.println(t);
break;
//----------------------------------------
case 2:
t = WiFi.RSSI(); //SYGNAL WiFi
Serial.print("Temp 3 : ");
Serial.println(t);
break;
}
return t;
}
//***************************************************************************************
//=======================================================================================
void setup() {
Serial.begin(115200);
delay(10);
wifi_station_set_hostname("Supla-PIEC"); //nazwa w sieci lokalnej
WiFi.softAPdisconnect(true); // wyłączenie rozgłaszania sieci ESP
digitalWrite(15, LOW); //D8->(15) Przekaznik
pinMode(analogInPin, INPUT); //LM35->Czuj.Temp.
// Inicjalizacja DS18B20
sensors.begin();
sensors_2.begin();
SuplaDevice.setTemperatureCallback(&get_temperature);
//***************************************************************************************
// Replace the falowing GUID
uint8_t mac[WL_MAC_ADDR_LENGTH]; //BYLO
WiFi.macAddress(mac);
// Replace the falowing GUID
char GUID[SUPLA_GUID_SIZE] = {*******************************************************};
// with GUID that you can retrieve from https://www.supla.org/arduino/get-guid
//****************************************************************************************
// CHANNEL0,1,2 - DS //BYLO-> CHANNEL0,1,2,3...8 - DS
SuplaDevice.addDS18B20Thermometer(); // DS na GPIO 02->(D4)
SuplaDevice.addDS18B20Thermometer(); // DS na GPIO 4->(D2)
SuplaDevice.addDS18B20Thermometer(); //SYGNAL WiFi
//SuplaDevice.addDS18B20Thermometer(); //A0 //(A0)volt
// CHANNEL4 - RELAY
SuplaDevice.addRelay(15); //D8->(15)Przekaznik
// CHANNEL5-8 - Opening sensor (Normal Open)
SuplaDevice.addSensorNO(5, true); //D1->(5) //senor styk
//SuplaDevice.addSensorNO(4, true); //D2->(4) //senor styk //DS18B20
SuplaDevice.addSensorNO(14, true); //D5->(14) //senor styk
SuplaDevice.addSensorNO(12, true); //D6->(12) //senor styk
SuplaDevice.addSensorNO(13, true); //D7->(13) //senor styk
//SuplaDevice.addSensorNO(A0, true); //A0
//***************************************************************************
SuplaDevice.setName("supla_PIEC");
SuplaDevice.begin(GUID, // Global Unique Identifier
mac, // Ethernet MAC address
"svr.supla.org", // SUPLA server address
***, // Location ID
"****"); // Location Password
//***************************************************************************
Serial.println();
Serial.println("Uruchamianie serwera aktualizacji...");
WiFi.mode(WIFI_STA);
MDNS.begin(host);
httpUpdater.setup(&httpServer, update_path, update_username, update_password);
httpServer.begin();
MDNS.addService("http", "tcp", 81);
Serial.printf("HTTPUpdateServer ready! Open http://%s.local%s in your browser and login with username '%s' and password '%s'\n", host, update_path, update_username, update_password);
} //KONIEC-> setup()
//===============================================================================
void loop() {
SuplaDevice.iterate();
SuplaDevice.setTemperatureCallback(&get_temperature);
httpServer.handleClient();
//------------ DOPISANE ------------------------------------------
// read the analog in value
sensorValue = analogRead(analogInPin);
volt = sensorValue;
// print the readings in the Serial Monitor
Serial.print("sensor = ");
Serial.println(sensorValue);
delay(100);
//------------------------------------------------------
} //KONIEC-> loop()
//================================================================
// 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) {
Serial.println("WiFi init");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.print("\nlocalIP: ");
Serial.println(WiFi.localIP());
Serial.print("subnetMask: ");
Serial.println(WiFi.subnetMask());
Serial.print("gatewayIP: ");
Serial.println(WiFi.gatewayIP());
}
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;
return cb;
}
//======== KONIEC PROGRAMU ============================
Przepisałem to na nową biblitekę i opakowałem odczyt analogowy w nową klasę. Zakomentowałem też kod od "update server".elektronik9 pisze: ↑śr paź 28, 2020 9:40 pm Wkleiłem cały program tylko to co tam wcześniej pokazałem tu już tego nie ma już i w inny sposób próbowałem
i też nic z tego. Jak byś mógł mi tu dopisać żeby wyświetlało tak jak temperaturę i sygnał WiFi też i napięcie nap.z Potencjometru w jakim jest położeniu poprzez widoczne napięcie to byłbym Bardzo Wdzięczny.
Tylko zmień bibliotekę SuplaDevice w Arduino na:
https://github.com/SUPLA/arduino/tree/develop
lub:
https://github.com/klew/arduino
Kod: Zaznacz cały
#include <SuplaDevice.h>
#include <supla/network/esp_wifi.h>
#include <supla/sensor/DS18B20.h>
#include <supla/sensor/thermometer.h>
#include <supla/control/relay.h>
#include <supla/sensor/binary.h>
/*
#include <ESP8266WebServer.h>
#include <DNSServer.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPUpdateServer.h>
*/
//=========== DOPISANE =====================================
const int analogInPin = A0; // ESP8266 Analog Pin ADC0 = A0
// Przewód danych jest podłączony do portu 2 na Arduino
#define ONE_WIRE 2
#define ONE_WIRE_2 4 //(D2)-(4) // (D5) DOPISANE Dodatkowy DS(3)
// Setup Supla connection
const char* ssid = "*************";
const char* password = "************";
Supla::ESPWifi wifi(ssid, password);
class AnalogValue : public Supla::Sensor::Thermometer {
public:
AnalogValue(int pin) : pin(pin) {
}
void onInit() {
pinMode(pin, INPUT);
channel.setNewValue(getValue());
}
double getValue() {
return analogRead(pin);
}
protected:
int pin;
};
/*
*
WiFiClient client;
const char* host = "supla";
const char* update_path = "/supla";
const char* update_username = "admin";
const char* update_password = "supla";
ESP8266WebServer httpServer(81);
ESP8266HTTPUpdateServer httpUpdater;
*/
//=======================================================================================
void setup() {
Serial.begin(115200);
delay(10);
wifi_station_set_hostname("Supla-PIEC"); //nazwa w sieci lokalnej
WiFi.softAPdisconnect(true); // wyłączenie rozgłaszania sieci ESP
// Replace the falowing GUID
char GUID[SUPLA_GUID_SIZE] = {0xD1,0xE0,0xF5,0xB0,0x02,0x6E,0x1B,0x8F,0xF8,0xAC,0x6B,0x23,0xFD,0xB7,0x5E,0x2B};
char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {0x11,0xB7,0x0B,0xE0,0x53,0x92,0x63,0xC2,0x13,0x50,0xC2,0x84,0x98,0x38,0x42,0x6C};
// with GUID that you can retrieve from https://www.supla.org/arduino/get-guid
new Supla::Sensor::DS18B20(ONE_WIRE);
new Supla::Sensor::DS18B20(ONE_WIRE_2);
new Supla::Control::Relay(15, false);
new Supla::Sensor::Binary(5, true);
new Supla::Sensor::Binary(14, true);
new Supla::Sensor::Binary(12, true);
new Supla::Sensor::Binary(13, true);
new AnalogValue(analogInPin);
//***************************************************************************
SuplaDevice.setName("supla_PIEC");
SuplaDevice.begin(GUID, // Global Unique Identifier
"svr.supla.org", // SUPLA server address
"email@mail.com", // email
AUTHKEY);
//***************************************************************************
/*
Serial.println();
Serial.println("Uruchamianie serwera aktualizacji...");
WiFi.mode(WIFI_STA);
MDNS.begin(host);
httpUpdater.setup(&httpServer, update_path, update_username, update_password);
httpServer.begin();
MDNS.addService("http", "tcp", 81);
Serial.printf("HTTPUpdateServer ready! Open http://%s.local%s in your browser and login with username '%s' and password '%s'\n", host, update_path, update_username, update_password);
*/
} //KONIEC-> setup()
//===============================================================================
void loop() {
SuplaDevice.iterate();
//httpServer.handleClient();
}
Widzimy się na Supla Offline Party vol. 2
-
- Posty: 23
- Rejestracja: wt paź 13, 2020 11:01 am
Mam problem z tymi Bibliotekami ja już wcześniej je zgrałem ale nie mogę ich zainstalować pisze że są nie zgodne.
arduino-develop i arduino-master i nie wiem co mam zrobić? Mam zainstalowane -
Arduino 1.8.13 (windows store 1.8 42.0) tak mi wyświetla na otwartym programie.
arduino-develop i arduino-master i nie wiem co mam zrobić? Mam zainstalowane -
Arduino 1.8.13 (windows store 1.8 42.0) tak mi wyświetla na otwartym programie.
Ostatnio zmieniony czw paź 29, 2020 7:13 pm przez elektronik9, łącznie zmieniany 1 raz.
Wejdź do katalogu: C:\Users\dedwa\OneDrive\Dokumenty\Arduino\libraries\
i usuń "SuplaDevice" (albo zrób sobie kopię, jeśli chcesz jeszcze pracować na starej wersji bibiliteki).
Pobierz to: https://github.com/klew/arduino/archive/master.zip
Następnie z zipa rozpakuj katalog SuplaDevice w miejsce tego starego (trzeba w zip wejść do arduino-master/libraries/)
i usuń "SuplaDevice" (albo zrób sobie kopię, jeśli chcesz jeszcze pracować na starej wersji bibiliteki).
Pobierz to: https://github.com/klew/arduino/archive/master.zip
Następnie z zipa rozpakuj katalog SuplaDevice w miejsce tego starego (trzeba w zip wejść do arduino-master/libraries/)
Widzimy się na Supla Offline Party vol. 2
-
- Posty: 23
- Rejestracja: wt paź 13, 2020 11:01 am
Usunąłem SuplaDevice ale tam mam jeszcze SuplaDevice-Primary-master ale pousunięciu tej pierwszej to jak rozpakowałem to tylko pojawiło się arduino-master a SuplaDevice się nie pokazało i przy próbie brak było tej co usunąłem nie wiem nie mogę się w tym połapać . A jak chcę dodać tą bibliotekę w zip to jest to samo niema właściwej biblioteki.
Rozpakuj sobie tego zipa gdzieś na boku (na pulpicie) i skopiuj tylko katalog SuplaDevice do tego katalogu z biblitekami.elektronik9 pisze: ↑czw paź 29, 2020 11:15 am Usunąłem SuplaDevice ale tam mam jeszcze SuplaDevice-Primary-master ale pousunięciu tej pierwszej to jak rozpakowałem to tylko pojawiło się arduino-master a SuplaDevice się nie pokazało i przy próbie brak było tej co usunąłem nie wiem nie mogę się w tym połapać . A jak chcę dodać tą bibliotekę w zip to jest to samo niema właściwej biblioteki.
Widzimy się na Supla Offline Party vol. 2