• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 1 głosów - średnia: 4
  • 1
  • 2
  • 3
  • 4
  • 5
ESP32 czy potrzebny egzorcysta?
#1
Question 
Witam,

Zrobiłem układ OneWire na Mega2560 z którego składał się 6x DS18B20. Wszystko pięknie działało, miałem dodać tylko WiFi w niedalekiej przyszłości. Lecz przyszłość przyszła szybciej, bo burza uszkodziła zasilacz oraz wszystkie czujniki.

Więc już chcąc zrobić na gotowo projekt, kupiłem ESP32 zrobiłem specjalną płytkę, przez którą mam wszystkie podłączenia przewodowe i niby wszystko jest ok, ale na wyświetlaczach nie odświeża temperatury tylko pokazuje pierwszą odczytaną po starcie.

Schemat podłączenia wygląda mniej więcej tak jak w załączniku.

Dodam tylko, że jak zasilam ESP z USB laptopa, a całą płytkę z zasilacza to normalnie odświeża, takie cyrki dzieją się gdy zasilam go z zasilacza sieciowego. Podmieniałem już chyba 3 zasilacze i nic to nie dało.

Jeżeli ktoś ma jakiś pomysł jakie siły nieczyste tutaj panują proszę o podzielenie się opinią a może akurat pomoże Wink

Pozdrawiam, Patryk.

A i zapomniałbym. Kod:
Cytat:#include <Arduino.h>
#include <WiFi.h>
#include <TM1637Display.h>
#include <OneWire.h>
#include <DS18B20.h>

#define CLK_1 14
#define CLK_2 16
#define CLK_3 17
#define CLK_4 18
#define CLK_5 19
#define CLK_6 21

#define DIO_1 16
#define DIO_2 17
#define DIO_3 18
#define DIO_4 19
#define DIO_5 21
#define DIO_6 14

const char* ssid    = "";
const char* password = "";
//WiFiServer server(80);

TM1637Display d1(CLK_1, DIO_1);
TM1637Display d2(CLK_2, DIO_2);
TM1637Display d3(CLK_3, DIO_3);
TM1637Display d4(CLK_4, DIO_4);
TM1637Display d5(CLK_5, DIO_5);
TM1637Display d6(CLK_6, DIO_6);

OneWire ds(27);
DS18B20 sensors(&ds);
uint8_t clearMe[]={
  0,0,0,0
};
uint8_t dodajC[]{
  0,0,SEG_D,0
};

#define SENSORS_NUM 6
const byte adress[SENSORS_NUM][8] PROGMEM ={
  0x28, 0x18, 0xE, 0xB, 0xD, 0x0, 0x0, 0xC2,
  0x28, 0x9, 0x60, 0xA, 0xD, 0x0, 0x0, 0x92,
  0x28, 0xEA, 0x39, 0xC, 0xD, 0x0, 0x0, 0x8D,
  0x28, 0x4D, 0x67, 0xA, 0xD, 0x0, 0x0, 0x6A,
  0x28, 0xF6, 0x56, 0xA, 0xD, 0x0, 0x0, 0xDC,
  0x28, 0x7E, 0x15, 0xB, 0xD, 0x0, 0x0, 0xBF
};

int getTempCalkowita(float temp){
  int i = temp;
  return i;}
int getTempDziesiate(float temp){
  String s = String(temp);
  int kropka = s.indexOf('.');
  return (s.substring(kropka+1)).substring(0,1).toInt();}

//------------------------------------------------------SETUP
void setup() {
  // put your setup code here, to run once:
  while(!Serial);
  Serial.begin(115200);
  //randomSeed(analogRead(0));
  sensors.begin();
  sensors.request();
  d1.setBrightness(2);
  d2.setBrightness(2);
  d3.setBrightness(2);
  d4.setBrightness(2);
  d5.setBrightness(2);
  d6.setBrightness(2);
  delay(10);
  // We start by connecting to a WiFi network
  Serial.print("Connecting to ");
  Serial.println(ssid);
/* WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
  }
  Serial.println("WiFi connected.");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  server.begin();*/
}
//------------------------------------------------------LOOP
int value = 0;
void loop() {
 
  // put your main code here, to run repeatedly:
  if(sensors.available()){
    float temperature[6];
    for(byte i=0;i<SENSORS_NUM;i++){
      temperature[i] = sensors.readTemperature(FA(adress[i]));
      //Serial.println(String(i)+": "+String(temperature[i]));
    }
    //for(byte i=0;i<6;i++){
    //  float t = random(20,32) + random(10)/10.0;
    //  Serial.println(String(i)+": "+String(t));
    //  temperature[i] = t;
    //}
    d1.setSegments(dodajC);
    d1.showNumberDec(getTempCalkowita(temperature[0]),false,2,0);
    d1.showNumberDec(getTempDziesiate(temperature[0]),false,1,3);
    d2.setSegments(dodajC);
    d2.showNumberDec(getTempCalkowita(temperature[1]),false,2,0);
    d2.showNumberDec(getTempDziesiate(temperature[1]),false,1,3);
    d3.setSegments(dodajC);
    d3.showNumberDec(getTempCalkowita(temperature[2]),false,2,0);
    d3.showNumberDec(getTempDziesiate(temperature[2]),false,1,3);
    d4.setSegments(dodajC);
    d4.showNumberDec(getTempCalkowita(temperature[3]),false,2,0);
    d4.showNumberDec(getTempDziesiate(temperature[3]),false,1,3);
    d5.setSegments(dodajC);
    d5.showNumberDec(getTempCalkowita(temperature[4]),false,2,0);
    d5.showNumberDec(getTempDziesiate(temperature[4]),false,1,3);
    d6.setSegments(dodajC);
    d6.showNumberDec(getTempCalkowita(temperature[5]),false,2,0);
    d6.showNumberDec(getTempDziesiate(temperature[5]),false,1,3);
    delay(5000);
    d1.setSegments(clearMe);
    d2.setSegments(clearMe);
    d3.setSegments(clearMe);
    d4.setSegments(clearMe);
    d5.setSegments(clearMe);
    d6.setSegments(clearMe);
    delay(500);
  /* WiFiClient client = server.available();
    if(client){
      Serial.println("New Client.");
      String currentLine="";
      while(client.connected()){
        if(client.available()){
          char c = client.read();
          Serial.write©;
          if(c=='\n'){
            if(currentLine.length() ==0){
              client.println("HTTP/1.1 200 OK");
              client.println("Content-type:text/html");
              client.println();
              client.print("<html><head><title>Temperatura</title><style>table, td {border: 2px solid black;}</style></head><body>");
              client.print("<center><b><h1>Temperatura<h2><br><table style=\"width:30%\"><tr><th><left>Pomieszczenie</left></th><th>Odczyt</th></tr>");
              client.print("<tr><td><center>Pierwsze drzwi</td><td><center>"+String(temperature[0])+"</td></tr>");
              client.print("<tr><td><center>Warchlakarnia</td><td><center>"+String(temperature[1])+"</td></tr>");
              client.print("<tr><td><center>Piwnica</td><td><center>"+String(temperature[2])+"</td></tr>");
              client.print("<tr><td><center>Porodowka</td><td><center>"+String(temperature[3])+"</td></tr>");
              client.print("<tr><td><center>Selekcja</td><td><center>"+String(temperature[4])+"</td></tr>");
              client.print("<tr><td><center>Stodola</td><td><center>"+String(temperature[5])+"</td></tr></table>");
              client.print("</b><br><a href=\"\" onClick=\"window.location.reload()\">Refresh</a></center>");
              client.print("</body></html>");
           
              // The HTTP response ends with another blank line:
              client.println();
              // break out of the while loop:
              break;
            } else {    // if you got a newline, then clear currentLine:
            currentLine = "";
          }}
        else if (c != '\r') {  // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }}}
        client.stop();
        Serial.println("Client Disconnected.");*/
  //    }
    }
  }


Załączone pliki Miniatury
       
 
Odpowiedź
  


Wiadomości w tym wątku
ESP32 czy potrzebny egzorcysta? - przez knugi - 17-09-2021, 17:57
RE: ESP32 czy potrzebny egzorcysta? - przez kaczakat - 17-09-2021, 20:03
RE: ESP32 czy potrzebny egzorcysta? - przez knugi - 18-09-2021, 08:21
RE: ESP32 czy potrzebny egzorcysta? - przez knugi - 18-09-2021, 14:15
RE: ESP32 czy potrzebny egzorcysta? - przez kaczakat - 21-09-2021, 22:03
RE: ESP32 czy potrzebny egzorcysta? - przez Old Fony - 28-09-2021, 22:48
RE: ESP32 czy potrzebny egzorcysta? - przez knugi - 05-11-2021, 20:49

Skocz do:


Przeglądający: 2 gości