Fout in h bestand?

IDE gerelateerde berichten
Berichten: 6
Geregistreerd: 14 Jan 2024, 15:45

Fout in h bestand?

Berichtdoor Cees » 20 Jan 2024, 16:09

Beste mensen,

Sinds kort ben ik met arduino begonnen. Ik heb een startset gekocht en een aantal aanvullingen hierop. Met plezier de projectjes gemaakt en tot een goed einde gebracht. Vervolgen een smarthome set gekocht, met een esp32 plus bordje. Als ik de schets in het bordje wil laden dan krijg ik onderstaande melding. Het is mij onduidelijk hoe ik hier mee om moet gaan als beginner. Zouden jullie mij op weg willen helpen om dit probleem te verhelpen?


In file included from /home/cees/Bureaublad/keyestudio09/3. Arduino Tutorials/arduino Code/pj13_2_IoT_smart_home/pj13_2_IoT_smart_home.ino:16:
/home/cees/Bureaublad/sketch/libraries/Wire/src/Wire.h:44:5: error: 'i2c_t' does not name a type; did you mean 'ino_t'?
i2c_t * i2c;
^~~~~
ino_t
/home/cees/Bureaublad/sketch/libraries/Wire/src/Wire.h:64:5: error: 'i2c_err_t' does not name a type; did you mean 'esp_err_t'?
i2c_err_t last_error; // @stickBreaker from esp32-hal-i2c.h
^~~~~~~~~
esp_err_t
/home/cees/Bureaublad/sketch/libraries/Wire/src/Wire.h:87:5: error: 'i2c_err_t' does not name a type; did you mean 'esp_err_t'?
i2c_err_t writeTransmission(uint16_t address, uint8_t* buff, uint16_t size, bool sendStop=true);
^~~~~~~~~
esp_err_t
/home/cees/Bureaublad/sketch/libraries/Wire/src/Wire.h:88:5: error: 'i2c_err_t' does not name a type; did you mean 'esp_err_t'?
i2c_err_t readTransmission(uint16_t address, uint8_t* buff, uint16_t size, bool sendStop=true, uint32_t *readCount=NULL);
^~~~~~~~~
esp_err_t

exit status 1

Compilation error: exit status 1

Mocht ik naar de bekende weg vragen dan bied ik op voorhand mijn excuses aan en met vriendelijke groeten,

Cees

Advertisement

Berichten: 4067
Geregistreerd: 16 Okt 2013, 14:31
Woonplaats: s hertogenbosch

Re: Fout in h bestand?

Berichtdoor shooter » 21 Jan 2024, 16:41

Cees dat is vrij normaal hoor dat als je direct een library aanroept, en er staat iets in zoals in jouw geval een wire die naar een variabele zoekt i2c_t, als eerste even zoeken naar een juiste librarie (wire) en dan ook kijken of deze voor jouw esp werkt want de pinnen zitten vaak op een andere plek.
paul deelen
shooter@home.nl

Berichten: 80
Geregistreerd: 02 Nov 2022, 13:03

Re: Fout in h bestand?

Berichtdoor ThHe » 22 Jan 2024, 17:10

Het lezen van een foutmelding is soms lastig.
Bij een foutmelding van een compiler geldt "los de problemen op in de volgorde zoals zij zich aandienen".
Dus alleen de eerste foutmelding oplossen en de rest komt later.

Melding: In file included from /home/cees/Bureaublad/keyestudio09/3. Arduino Tutorials/arduino Code/pj13_2_IoT_smart_home/pj13_2_IoT_smart_home.ino:16:
/home/cees/Bureaublad/sketch/libraries/Wire/src/Wire.h:44:5: error: 'i2c_t' does not name a type; did you mean 'ino_t'?
i2c_t * i2c;
^~~~~
In de eerste regel staat de code waarmee de compiler bezig is in dit geval: "pj13_2_IoT_smart_home.ino"
en dat de fout optreedt regel 16.
Op internet de code opgezocht staat op regel 16 inderdaad de include van Wire.h waarin de de foutmelding wordt gemeld.
De wire.h file staat bij jouw in de map libraries/Wire/src maar die versie met de fout op regel 44 kan ik niet vinden.
Twee mogelijkheden:
1. geef het bestand wire.h en wire.cpp een andere tijdelijke naam bv xwire.h en xwire.cpp en dan proberen te compileren.
(misschien is de versie die met arduino standaard wordt meegeleverd degene die je moet hebben.)
2. plaatst de text van wire.h op het forum.

Berichten: 6
Geregistreerd: 14 Jan 2024, 15:45

Re: Fout in h bestand?

Berichtdoor Cees » 22 Jan 2024, 17:24

Naar aanleiding van het bericht van Shooter op zoek gegaan naar een ander wire bestand. Ik heb het niet kunnen vinden. Mogelijk speelt mijn onbekendheid met de materie hierin een rol. In de bibliotheek van de Arduino IDE stonden wel bestanden welke richting wire wezen, echter gaven deze weer andere problemen bij gebruik hiervan. Is er iemand die het smarthome KS5009 setje van keyestudio, met alle bijgeleverde schetsen en libraryś aan de praat heeft gekregen?

Een zich ten einde geen raad meer wetende beginner en met vriendelijke groet,

Cees

Berichten: 6
Geregistreerd: 14 Jan 2024, 15:45

Re: Fout in h bestand?

Berichtdoor Cees » 23 Jan 2024, 15:35

Beste mensen, ik heb de suggestie van ThHe over genomen en uitgevoerd. Als ik de naam van het wire bestand verander, kan er geen wire bestand gevonden worden door de IDE. Er is er dus maar één beschikbaar op mijn computer. Zoals aanbevolen voeg ik het bestand hier bij.


/*
TwoWire.h - TWI/I2C library for Arduino & Wiring
Copyright (c) 2006 Nicholas Zambetti. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
Modified December 2014 by Ivan Grokhotkov (ivan@esp8266.com) - esp8266 support
Modified April 2015 by Hrsto Gochkov (ficeto@ficeto.com) - alternative esp8266 support
Modified November 2017 by Chuck Todd <stickbreaker on GitHub> to use ISR and increase stability.
*/

#ifndef TwoWire_h
#define TwoWire_h

#include <esp32-hal.h>
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "Stream.h"

#define STICKBREAKER 'V1.1.0'
#define I2C_BUFFER_LENGTH 128
typedef void(*user_onRequest)(void);
typedef void(*user_onReceive)(uint8_t*, int);

class TwoWire: public Stream
{
protected:
uint8_t num;
int8_t sda;
int8_t scl;
i2c_t * i2c;

uint8_t rxBuffer[I2C_BUFFER_LENGTH];
uint16_t rxIndex;
uint16_t rxLength;
uint16_t rxQueued; //@stickBreaker

uint8_t txBuffer[I2C_BUFFER_LENGTH];
uint16_t txIndex;
uint16_t txLength;
uint16_t txAddress;
uint16_t txQueued; //@stickbreaker

uint8_t transmitting;
/* slave Mode, not yet Stickbreaker
static user_onRequest uReq[2];
static user_onReceive uRcv[2];
void onRequestService(void);
void onReceiveService(uint8_t*, int);
*/
i2c_err_t last_error; // @stickBreaker from esp32-hal-i2c.h
uint16_t _timeOutMillis;

public:
TwoWire(uint8_t bus_num);
~TwoWire();

//call setPins() first, so that begin() can be called without arguments from libraries
bool setPins(int sda, int scl);

bool begin(int sda=-1, int scl=-1, uint32_t frequency=0); // returns true, if successful init of i2c bus
// calling will attemp to recover hung bus

void setClock(uint32_t frequency); // change bus clock without initing hardware
size_t getClock(); // current bus clock rate in hz

void setTimeOut(uint16_t timeOutMillis); // default timeout of i2c transactions is 50ms
uint16_t getTimeOut();

uint8_t lastError();
char * getErrorText(uint8_t err);

//@stickBreaker for big blocks and ISR model
i2c_err_t writeTransmission(uint16_t address, uint8_t* buff, uint16_t size, bool sendStop=true);
i2c_err_t readTransmission(uint16_t address, uint8_t* buff, uint16_t size, bool sendStop=true, uint32_t *readCount=NULL);

void beginTransmission(uint16_t address);
void beginTransmission(uint8_t address);
void beginTransmission(int address);

uint8_t endTransmission(bool sendStop);
uint8_t endTransmission(void);

uint8_t requestFrom(uint16_t address, uint8_t size, bool sendStop);
uint8_t requestFrom(uint16_t address, uint8_t size, uint8_t sendStop);
uint8_t requestFrom(uint16_t address, uint8_t size);
uint8_t requestFrom(uint8_t address, uint8_t size, uint8_t sendStop);
uint8_t requestFrom(uint8_t address, uint8_t size);
uint8_t requestFrom(int address, int size, int sendStop);
uint8_t requestFrom(int address, int size);

size_t write(uint8_t);
size_t write(const uint8_t *, size_t);
int available(void);
int read(void);
int peek(void);
void flush(void);

inline size_t write(const char * s)
{
return write((uint8_t*) s, strlen(s));
}
inline size_t write(unsigned long n)
{
return write((uint8_t)n);
}
inline size_t write(long n)
{
return write((uint8_t)n);
}
inline size_t write(unsigned int n)
{
return write((uint8_t)n);
}
inline size_t write(int n)
{
return write((uint8_t)n);
}

void onReceive( void (*)(int) );
void onRequest( void (*)(void) );

uint32_t setDebugFlags( uint32_t setBits, uint32_t resetBits);
bool busy();
};

extern TwoWire Wire;
extern TwoWire Wire1;


/*
V1.1.0 08JAN2019 Support CPU Clock frequency changes
V1.0.2 30NOV2018 stop returning I2C_ERROR_CONTINUE on ReSTART operations, regain compatibility with Arduino libs
V1.0.1 02AUG2018 First Fix after release, Correct ReSTART handling, change Debug control, change begin()
to a function, this allow reporting if bus cannot be initialized, Wire.begin() can be used to recover
a hung bus busy condition.
V0.2.2 13APR2018 preserve custom SCL,SDA,Frequency when no parameters passed to begin()
V0.2.1 15MAR2018 Hardware reset, Glitch prevention, adding destructor for second i2c testing
*/
#endif

Berichten: 62
Geregistreerd: 05 Feb 2023, 13:30

Re: Fout in h bestand?

Berichtdoor sterretjeToo » 24 Jan 2024, 19:25

Voor welk bord compileer je het programma? Ik denk dat i2c_t alleen bekend is in de ESP wereld hetgeen dan de vraag brengt of je voor het juiste board compileert. Je kunt een programma dat specifiek geschreven is voor een ESP32 of dat gebruik maakt van ESP specifieke bibliotheken niet compileren voor b.v. een Uno.

Laat je programma hier zien; vergeet niet om code tags te gebruiken
Code: Alles selecteren
[code]
programma hier
[/code]

Berichten: 6
Geregistreerd: 14 Jan 2024, 15:45

Re: Fout in h bestand?

Berichtdoor Cees » 25 Jan 2024, 15:40

SterretjeToo,
Het bordje dat gebruikt wordt is een Keyestudio ESP32 plus development board. Artikelnummer KS5016. Op het bordje zijn drie aansluitingen bij elkaar met de benaming bus I2C. Hierop is de RFID en het LCD1602 display op aangesloten. Als IDE gebruik ik arduino 2.2.1. Besturingssysteem is linux mint. Met windows krijg ik overgens ook de foutmeldingen. Het board dat geselecteerd is, is ESP32 Dev module. In de handleiding van het setje wordt hier naar verwezen.

Code: Alles selecteren
#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiClient.h>
#include <Adafruit_NeoPixel.h>
#define LED_PIN    26
// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 4
// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

String item = "0";
const char* ssid = "ChinaNet-2.4G-0DF0";
const char* password = "ChinaNet@233";
WiFiServer server(80);

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C mylcd(0x27,16,2);
#include <analogWrite.h>
#include "xht11.h"
xht11 xht(17);
//#include <ESP32_Servo.h>
//Servo Wservo;
//Servo Dservo;
#include <ESP32Tone.h>
#define buzzer_pin 25
//#define windowServo 5
//#define doorServo 13
#define waterPin 34
#define fanPin1 19
#define fanPin2 18
#define led_y 12  //Define the yellow led pin to 12

#define waterPin 34
#define gasPin 23
#define pyroelectric 14

unsigned char dht[4] = {0, 0, 0, 0};//Only the first 32 bits of data are received, not the parity bits

//Servo channel
int channel_PWM = 13;
int channel_PWM2 = 10;
int freq_PWM = 50;
int resolution_PWM = 10;
const int PWM_Pin1 = 5;
const int PWM_Pin2 = 13;




void setup() {
  Serial.begin(115200);
  mylcd.init();
  mylcd.backlight();
  pinMode(led_y, OUTPUT);
  pinMode(fanPin1, OUTPUT);
  pinMode(fanPin2, OUTPUT);
  ledcSetup(5, 1200, 8);//Set the frequency of LEDC channel 1 to 1200 and PWM resolution to 8, that is duty cycle to 256. 
  ledcAttachPin(fanPin2, 5);  //Bind the LEDC channel 1 to the specified left motor pin GPIO26 for output. 
  pinMode(waterPin, INPUT);
  pinMode(buzzer_pin, OUTPUT);
  pinMode(gasPin, INPUT);
  pinMode(pyroelectric, INPUT);
  ledcSetup(channel_PWM, freq_PWM, resolution_PWM); //Set servo channel and frequency as well as PWM resolution.
  ledcSetup(channel_PWM2, freq_PWM, resolution_PWM);
  ledcAttachPin(PWM_Pin1, channel_PWM);  //Binds the LEDC channel to the specified IO port for output
  ledcAttachPin(PWM_Pin2, channel_PWM2);  //Binds the LEDC channel to the specified IO port for output
//  Wservo.attach(windowServo);
//  Dservo.attach(doorServo);
//  #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
//    clock_prescale_set(clock_div_1);
//  #endif
//    // END of Trinket-specific code.
//  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
//  strip.show();            // Turn OFF all pixels ASAP
//  strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
 
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  server.begin();
  Serial.println("TCP server started");
  MDNS.addService("http", "tcp", 80);
  mylcd.setCursor(0, 0);
  mylcd.print("ip:");
  mylcd.setCursor(0, 1);
  mylcd.print(WiFi.localIP());  //LCD displays ip adress
}

void loop() {
  WiFiClient client = server.available();
  if (!client) {
      return;
  }
  while(client.connected() && !client.available()){
      delay(1);
  }
  String req = client.readStringUntil('\r');
  int addr_start = req.indexOf(' ');
  int addr_end = req.indexOf(' ', addr_start + 1);
  if (addr_start == -1 || addr_end == -1) {
      Serial.print("Invalid request: ");
      Serial.println(req);
      return;
  }
  req = req.substring(addr_start + 1, addr_end);
  item=req;
  Serial.println(item);
  String s;
  if (req == "/")  //Browser accesses address can read the information sent by the client.println(s);
  {
      IPAddress ip = WiFi.localIP();
      String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
      s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>ESP32 ip:";
      s += ipStr;
      s += "</html>\r\n\r\n";
      Serial.println("Sending 200");
      client.println(s);  //Send the string S, then you can read the information when visiting the address of E smart home using the browser.
  }
  if(req == "/led/on") //Browser accesses address ip address/led/on
  {
    client.println("turn on the LED");
    digitalWrite(led_y, HIGH);
  }
  if(req == "/led/off") //Browser accesses address ip address/led/off
  {
    client.println("turn off the LED");
    digitalWrite(led_y, LOW);
  }
  if(req == "/window/on")
  {
    client.println("open the window");
    ledcWrite(channel_PWM, 100);  //The high level of 20ms is about 2.5ms, that is, 2.5/20*1024, at this time, the servo angle is 180°. 
    //Wservo.write(175);
  }
  if(req == "/window/off")
  {
    client.println("close the window");
    ledcWrite(channel_PWM, 60);  //The high level of 20ms is about 0.5ms,that is, 0.5/20*1024,at this time, the servo angle is 0°.
    //Wservo.write(0);
  }
  if(req == "/music/on")
  {
    //client.println("play music");
  }
  if(req == "/music/off")
  {
    client.println("play music");
    birthday();
    noTone(buzzer_pin,0);
  }
  if(req == "/buz/on")
  {
    client.println("buzzer");
    tone(buzzer_pin,392,250,0);
    Serial.println("1");
  }
  if(req == "/buz/off")
  {
    client.println("off");
    noTone(buzzer_pin,0);
  }
  if(req == "/door/on")
  {
    client.println("open the door");
    ledcWrite(channel_PWM2, 120);
//    Dservo.write(180);
  }
  if(req == "/door/off")
  {
    client.println("close the door");
     ledcWrite(channel_PWM2, 20);
//    Dservo.write(0);
  }
  if(req == "/fan/on")
  {
    client.println("turn on the fan");
    digitalWrite(fanPin1, LOW); //pwm = 0
    ledcWrite(5, 100); //The LEDC channel 1 is bound to the specified left motor output PWM value of 100.
  }
  if(req == "/fan/off")
  {
    client.println("turn off the fan");
    digitalWrite(fanPin1, LOW); //pwm = 0
    ledcWrite(5, 0); //The LEDC channel 1 is bound to the specified left motor output PWM value of 0.
  }
  if(req == "/red/on")
  {
    client.println("red on");
    colorWipe(strip.Color(255,   0,   0), 50);
  }
  if(req == "/red/off")
  {
    client.println("red off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if(req == "/oringe/on")
  {
    client.println("oringe on");
    colorWipe(strip.Color(200,   100,   0), 50);
  }
  if(req == "/oringe/off")
  {
    client.println("oringe off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if(req == "/yellow/on")
  {
    client.println("yellow on");
    colorWipe(strip.Color(200,   200,   0), 50);
  }
  if(req == "/yellow/off")
  {
    client.println("yellow off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if(req == "/green/on")
  {
    client.println("green on");
    colorWipe(strip.Color(0,   255,   0), 50);
  }
  if(req == "/green/off")
  {
    client.println("green off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if(req == "/cyan/on")
  {
    client.println("cyan on");
    colorWipe(strip.Color(0,   100,   255), 50);
  }
  if(req == "/cyan/off")
  {
    client.println("cyan off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if(req == "/blue/on")
  {
    client.println("blue on");
    colorWipe(strip.Color(0,   0,   255), 50);
  }
  if(req == "/blue/off")
  {
    client.println("blue off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if(req == "/purple/on")
  {
    client.println("purple on");
    colorWipe(strip.Color(100,   0,   255), 50);
  }
  if(req == "/purple/off")
  {
    client.println("purple off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if(req == "/white/on")
  {
    client.println("white on");
    colorWipe(strip.Color(255,   255,   255), 50);
  }
  if(req == "/white/off")
  {
    client.println("white off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if(req == "/sfx1/on")
  {
    client.println("sfx1 on");
    rainbow(10);
  }
  if(req == "/sfx1/off")
  {
    client.println("sfx1 off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if(req == "/sfx2/on")
  {
    client.println("sfx2 on");
    theaterChaseRainbow(50);
  }
  if(req == "/sfx2/off")
  {
    client.println("sfx2 off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }


  if(req == "/rain/on")
  {
    int rainVal = analogRead(waterPin);
    client.println(rainVal);
  }
  if(req == "/rain/off")
  {
    client.println("off");
  }
  if(req == "/gas/on")
  {
    boolean gasVal = analogRead(gasPin);
    if(gasVal == 0)
    {
      client.println("safety");
    }
    else
    {
      client.println("dangerous");
    }
  }
  if(req == "/gas/off")
  {
    client.println("off");
  }
  if(req == "/body/on")
  {
    boolean pyroelectric_val = digitalRead(pyroelectric);
    if(pyroelectric_val == 1)
    {
      client.println("someone");
    }
    else
    {
      client.println("no one");
    }
  }
  if(req == "/body/off")
  {
    client.println("off");
  }
  if(req == "/temp/on")
  {
    if (xht.receive(dht)) { //Returns true when checked correctly
      Serial.print("Temp:");
      Serial.print(dht[2]); //The integral part of temperature, DHT [3] is the fractional part
      Serial.println("C");
      delay(200);
    } else {    //Read error
      Serial.println("sensor error");
    }
    client.println(dht[2]);
    delay(1000);  //It takes 1000ms to wait for the device to read
  }
  if(req == "/temp/off")
  {
    client.println("off");
  }
  if(req == "/humidity/on")
  {
    if (xht.receive(dht)) { //Returns true when checked correctly
      Serial.print("Temp:");
      Serial.print(dht[0]); //The integral part of temperature, DHT [3] is the fractional part
      Serial.println("%");
      delay(200);
    } else {    //Read error
      Serial.println("sensor error");
    }
    client.println(dht[0]);
    delay(1000);  //It takes 1000ms to wait for the device to read
  }
  if(req == "/humidity/off")
  {
    client.println("off");
  }

 
  //client.stop();
}


void birthday()
{
  tone(buzzer_pin,294,250,0);  //The four parameters are pin, frequency, delay and channel
  tone(buzzer_pin,440,250,0);
  tone(buzzer_pin,392,250,0);
  tone(buzzer_pin,532,250,0);
  tone(buzzer_pin,494,250,0);
  tone(buzzer_pin,392,250,0);
  tone(buzzer_pin,440,250,0);
  tone(buzzer_pin,392,250,0);
  tone(buzzer_pin,587,250,0);
  tone(buzzer_pin,532,250,0);
  tone(buzzer_pin,392,250,0);
  tone(buzzer_pin,784,250,0);
  tone(buzzer_pin,659,250,0);
  tone(buzzer_pin,532,250,0);
  tone(buzzer_pin,494,250,0);
  tone(buzzer_pin,440,250,0);
  tone(buzzer_pin,698,250,0);
  tone(buzzer_pin,659,250,0);
  tone(buzzer_pin,532,250,0);
  tone(buzzer_pin,587,250,0);
  tone(buzzer_pin,532,500,0);
  noTone(buzzer_pin,0);  //关闭
}

void colorWipe(uint32_t color, int wait) {
  for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
    strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
    strip.show();                          //  Update strip to match
    delay(wait);                           //  Pause for a moment
  }
}

// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
void rainbow(int wait) {
  for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) {
    for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
      int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
      strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
    }
    strip.show(); // Update strip with new contents
    delay(wait);  // Pause for a moment
  }
}

// Rainbow-enhanced theater marquee. Pass delay time (in ms) between frames.
void theaterChaseRainbow(int wait) {
  int firstPixelHue = 0;     // First pixel starts at red (hue 0)
  for(int a=0; a<30; a++) {  // Repeat 30 times...
    for(int b=0; b<3; b++) { //  'b' counts from 0 to 2...
      strip.clear();         //   Set all pixels in RAM to 0 (off)
      // 'c' counts up from 'b' to end of strip in increments of 3...
      for(int c=b; c<strip.numPixels(); c += 3) {
        int      hue   = firstPixelHue + c * 65536L / strip.numPixels();
        uint32_t color = strip.gamma32(strip.ColorHSV(hue)); // hue -> RGB
        strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
      }
      strip.show();                // Update strip with new contents
      delay(wait);                 // Pause for a moment
      firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames
    }
  }
}



Berichten: 62
Geregistreerd: 05 Feb 2023, 13:30

Re: Fout in h bestand?

Berichtdoor sterretjeToo » 28 Jan 2024, 12:19

Ik ben geen ESP32 gebruiker. De eerste vraag is wat je board url is in file → preferences.

https://dl.espressif.com/dl/package_esp32_index.json zoals gevonden op via de jeyesstudio site (https://www.dropbox.com/sh/drzeuimi0a4a ... tracking=1)

of iets anders. Op mijn systeem staat deze op https://espressif.github.io/arduino-esp32/package_esp32_index.json

Ik kon twee bibliotheken niet vinden (IDE / github)
1) xht11
2) ESP32Tone

Als ik alles eruit sloop gerelateerd aan die bibliotheken en ook de '#include <analogWrite.h>' eruit sloop compileert het op mijn system. Ik moest de laatste eruit slopen omdat, na het installeren van die bibliotheek, de linker een conflict gaf.

Kun je a.u.b. aangeven waar ik die kan vinden. Kun je ook aangeven welke LiquidCrystal_I2C bibliotheek je gebruikt; er zijn er teveel en voor degene die ik geinstalleerd hebt krijg ik een melding dat deze mogelijk niet compatibel is.

Nu is dit niet een juiste test; maar je LiquidCrystal_I2C zou de foutmelding moeten reproduceren vermoed ik.

Laatste opmerking
Ik weet niet of de ssid en password je echte gegevens zijn; indien ja, wees zo verstandig die in de toekomst niet meer te publiceren. Verander ze naar een paar sterretjes of zo.

Getest sketch die op mijn system (Windows 10, IDE 1.8.19 portable install), compileert
Code: Alles selecteren
#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiClient.h>
#include <Adafruit_NeoPixel.h>
#define LED_PIN    26
// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 4
// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

String item = "0";
const char* ssid = "ChinaNet-2.4G-0DF0";
const char* password = "ChinaNet@233";
WiFiServer server(80);

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C mylcd(0x27, 16, 2);
//#include <analogWrite.h>
//#include "xht11.h"
//xht11 xht(17);
//#include <ESP32_Servo.h>
//Servo Wservo;
//Servo Dservo;
//#include <ESP32Tone.h>
#define buzzer_pin 25
//#define windowServo 5
//#define doorServo 13
#define waterPin 34
#define fanPin1 19
#define fanPin2 18
#define led_y 12  //Define the yellow led pin to 12

#define waterPin 34
#define gasPin 23
#define pyroelectric 14

unsigned char dht[4] = {0, 0, 0, 0};//Only the first 32 bits of data are received, not the parity bits

//Servo channel
int channel_PWM = 13;
int channel_PWM2 = 10;
int freq_PWM = 50;
int resolution_PWM = 10;
const int PWM_Pin1 = 5;
const int PWM_Pin2 = 13;




void setup() {
  Serial.begin(115200);
  mylcd.init();
  mylcd.backlight();
  pinMode(led_y, OUTPUT);
  pinMode(fanPin1, OUTPUT);
  pinMode(fanPin2, OUTPUT);
  ledcSetup(5, 1200, 8);//Set the frequency of LEDC channel 1 to 1200 and PWM resolution to 8, that is duty cycle to 256.
  ledcAttachPin(fanPin2, 5);  //Bind the LEDC channel 1 to the specified left motor pin GPIO26 for output.
  pinMode(waterPin, INPUT);
  pinMode(buzzer_pin, OUTPUT);
  pinMode(gasPin, INPUT);
  pinMode(pyroelectric, INPUT);
  ledcSetup(channel_PWM, freq_PWM, resolution_PWM); //Set servo channel and frequency as well as PWM resolution.
  ledcSetup(channel_PWM2, freq_PWM, resolution_PWM);
  ledcAttachPin(PWM_Pin1, channel_PWM);  //Binds the LEDC channel to the specified IO port for output
  ledcAttachPin(PWM_Pin2, channel_PWM2);  //Binds the LEDC channel to the specified IO port for output
  //  Wservo.attach(windowServo);
  //  Dservo.attach(doorServo);
  //  #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  //    clock_prescale_set(clock_div_1);
  //  #endif
  //    // END of Trinket-specific code.
  //  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  //  strip.show();            // Turn OFF all pixels ASAP
  //  strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  server.begin();
  Serial.println("TCP server started");
  MDNS.addService("http", "tcp", 80);
  mylcd.setCursor(0, 0);
  mylcd.print("ip:");
  mylcd.setCursor(0, 1);
  mylcd.print(WiFi.localIP());  //LCD displays ip adress
}

void loop() {
  WiFiClient client = server.available();
  if (!client) {
    return;
  }
  while (client.connected() && !client.available()) {
    delay(1);
  }
  String req = client.readStringUntil('\r');
  int addr_start = req.indexOf(' ');
  int addr_end = req.indexOf(' ', addr_start + 1);
  if (addr_start == -1 || addr_end == -1) {
    Serial.print("Invalid request: ");
    Serial.println(req);
    return;
  }
  req = req.substring(addr_start + 1, addr_end);
  item = req;
  Serial.println(item);
  String s;
  if (req == "/")  //Browser accesses address can read the information sent by the client.println(s);
  {
    IPAddress ip = WiFi.localIP();
    String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
    s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>ESP32 ip:";
    s += ipStr;
    s += "</html>\r\n\r\n";
    Serial.println("Sending 200");
    client.println(s);  //Send the string S, then you can read the information when visiting the address of E smart home using the browser.
  }
  if (req == "/led/on") //Browser accesses address ip address/led/on
  {
    client.println("turn on the LED");
    digitalWrite(led_y, HIGH);
  }
  if (req == "/led/off") //Browser accesses address ip address/led/off
  {
    client.println("turn off the LED");
    digitalWrite(led_y, LOW);
  }
  if (req == "/window/on")
  {
    client.println("open the window");
    ledcWrite(channel_PWM, 100);  //The high level of 20ms is about 2.5ms, that is, 2.5/20*1024, at this time, the servo angle is 180°.
    //Wservo.write(175);
  }
  if (req == "/window/off")
  {
    client.println("close the window");
    ledcWrite(channel_PWM, 60);  //The high level of 20ms is about 0.5ms,that is, 0.5/20*1024,at this time, the servo angle is 0°.
    //Wservo.write(0);
  }
  if (req == "/music/on")
  {
    //client.println("play music");
  }
  if (req == "/music/off")
  {
    client.println("play music");
    birthday();
    //noTone(buzzer_pin,0);
  }
  if (req == "/buz/on")
  {
    client.println("buzzer");
    //tone(buzzer_pin,392,250,0);
    Serial.println("1");
  }
  if (req == "/buz/off")
  {
    client.println("off");
    //noTone(buzzer_pin,0);
  }
  if (req == "/door/on")
  {
    client.println("open the door");
    ledcWrite(channel_PWM2, 120);
    //    Dservo.write(180);
  }
  if (req == "/door/off")
  {
    client.println("close the door");
    ledcWrite(channel_PWM2, 20);
    //    Dservo.write(0);
  }
  if (req == "/fan/on")
  {
    client.println("turn on the fan");
    digitalWrite(fanPin1, LOW); //pwm = 0
    ledcWrite(5, 100); //The LEDC channel 1 is bound to the specified left motor output PWM value of 100.
  }
  if (req == "/fan/off")
  {
    client.println("turn off the fan");
    digitalWrite(fanPin1, LOW); //pwm = 0
    ledcWrite(5, 0); //The LEDC channel 1 is bound to the specified left motor output PWM value of 0.
  }
  if (req == "/red/on")
  {
    client.println("red on");
    colorWipe(strip.Color(255,   0,   0), 50);
  }
  if (req == "/red/off")
  {
    client.println("red off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if (req == "/oringe/on")
  {
    client.println("oringe on");
    colorWipe(strip.Color(200,   100,   0), 50);
  }
  if (req == "/oringe/off")
  {
    client.println("oringe off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if (req == "/yellow/on")
  {
    client.println("yellow on");
    colorWipe(strip.Color(200,   200,   0), 50);
  }
  if (req == "/yellow/off")
  {
    client.println("yellow off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if (req == "/green/on")
  {
    client.println("green on");
    colorWipe(strip.Color(0,   255,   0), 50);
  }
  if (req == "/green/off")
  {
    client.println("green off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if (req == "/cyan/on")
  {
    client.println("cyan on");
    colorWipe(strip.Color(0,   100,   255), 50);
  }
  if (req == "/cyan/off")
  {
    client.println("cyan off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if (req == "/blue/on")
  {
    client.println("blue on");
    colorWipe(strip.Color(0,   0,   255), 50);
  }
  if (req == "/blue/off")
  {
    client.println("blue off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if (req == "/purple/on")
  {
    client.println("purple on");
    colorWipe(strip.Color(100,   0,   255), 50);
  }
  if (req == "/purple/off")
  {
    client.println("purple off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if (req == "/white/on")
  {
    client.println("white on");
    colorWipe(strip.Color(255,   255,   255), 50);
  }
  if (req == "/white/off")
  {
    client.println("white off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if (req == "/sfx1/on")
  {
    client.println("sfx1 on");
    rainbow(10);
  }
  if (req == "/sfx1/off")
  {
    client.println("sfx1 off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }
  if (req == "/sfx2/on")
  {
    client.println("sfx2 on");
    theaterChaseRainbow(50);
  }
  if (req == "/sfx2/off")
  {
    client.println("sfx2 off");
    colorWipe(strip.Color(0,   0,   0), 50);
  }


  if (req == "/rain/on")
  {
    int rainVal = analogRead(waterPin);
    client.println(rainVal);
  }
  if (req == "/rain/off")
  {
    client.println("off");
  }
  if (req == "/gas/on")
  {
    boolean gasVal = analogRead(gasPin);
    if (gasVal == 0)
    {
      client.println("safety");
    }
    else
    {
      client.println("dangerous");
    }
  }
  if (req == "/gas/off")
  {
    client.println("off");
  }
  if (req == "/body/on")
  {
    boolean pyroelectric_val = digitalRead(pyroelectric);
    if (pyroelectric_val == 1)
    {
      client.println("someone");
    }
    else
    {
      client.println("no one");
    }
  }
  if (req == "/body/off")
  {
    client.println("off");
  }
  if (req == "/temp/on")
  {
    //    if (xht.receive(dht)) { //Returns true when checked correctly
    //      Serial.print("Temp:");
    //      Serial.print(dht[2]); //The integral part of temperature, DHT [3] is the fractional part
    //      Serial.println("C");
    //      delay(200);
    //    } else {    //Read error
    //      Serial.println("sensor error");
    //    }
    client.println(dht[2]);
    delay(1000);  //It takes 1000ms to wait for the device to read
  }
  if (req == "/temp/off")
  {
    client.println("off");
  }
  if (req == "/humidity/on")
  {
    //    if (xht.receive(dht)) { //Returns true when checked correctly
    //      Serial.print("Temp:");
    //      Serial.print(dht[0]); //The integral part of temperature, DHT [3] is the fractional part
    //      Serial.println("%");
    //      delay(200);
    //    } else {    //Read error
    //      Serial.println("sensor error");

    client.println(dht[0]);
    delay(1000);  //It takes 1000ms to wait for the device to read
  }
  if (req == "/humidity/off")
  {
    client.println("off");
  }


  //client.stop();
}


void birthday()
{
  /*
    tone(buzzer_pin,294,250,0);  //The four parameters are pin, frequency, delay and channel
    tone(buzzer_pin,440,250,0);
    tone(buzzer_pin,392,250,0);
    tone(buzzer_pin,532,250,0);
    tone(buzzer_pin,494,250,0);
    tone(buzzer_pin,392,250,0);
    tone(buzzer_pin,440,250,0);
    tone(buzzer_pin,392,250,0);
    tone(buzzer_pin,587,250,0);
    tone(buzzer_pin,532,250,0);
    tone(buzzer_pin,392,250,0);
    tone(buzzer_pin,784,250,0);
    tone(buzzer_pin,659,250,0);
    tone(buzzer_pin,532,250,0);
    tone(buzzer_pin,494,250,0);
    tone(buzzer_pin,440,250,0);
    tone(buzzer_pin,698,250,0);
    tone(buzzer_pin,659,250,0);
    tone(buzzer_pin,532,250,0);
    tone(buzzer_pin,587,250,0);
    tone(buzzer_pin,532,500,0);
    noTone(buzzer_pin,0);  //关闭
  */
}

void colorWipe(uint32_t color, int wait) {
  for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
    strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
    strip.show();                          //  Update strip to match
    delay(wait);                           //  Pause for a moment
  }
}

// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
void rainbow(int wait) {
  for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256) {
    for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
      int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
      strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
    }
    strip.show(); // Update strip with new contents
    delay(wait);  // Pause for a moment
  }
}

// Rainbow-enhanced theater marquee. Pass delay time (in ms) between frames.
void theaterChaseRainbow(int wait) {
  int firstPixelHue = 0;     // First pixel starts at red (hue 0)
  for (int a = 0; a < 30; a++) { // Repeat 30 times...
    for (int b = 0; b < 3; b++) { //  'b' counts from 0 to 2...
      strip.clear();         //   Set all pixels in RAM to 0 (off)
      // 'c' counts up from 'b' to end of strip in increments of 3...
      for (int c = b; c < strip.numPixels(); c += 3) {
        int      hue   = firstPixelHue + c * 65536L / strip.numPixels();
        uint32_t color = strip.gamma32(strip.ColorHSV(hue)); // hue -> RGB
        strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
      }
      strip.show();                // Update strip with new contents
      delay(wait);                 // Pause for a moment
      firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames
    }
  }
}

Berichten: 6
Geregistreerd: 14 Jan 2024, 15:45

Re: Fout in h bestand?

Berichtdoor Cees » 30 Jan 2024, 14:42

Als eerste wil ik melden dat ik alles wat met arduino te maken heeft van mijn computer heb verwijderd. Hierna stap voor stap de arduino IDE en het smarthome, volgens de handleiding opnieuw geinstaleerd. De url die ik gebruik, is die zoals genoemd in de handleiding; https://dl.espressif.com/dl/package_esp32_index.json.

Met deze url, https://fs.keyestudio.com/KS5009, kom je in een dropbox terecht waar het complete pakket is op te halen, ook de bibliotheken en de schetsen.

Ik gebruik de LiquidCrystal_I2C bibliotheek welke in het pakket zit. De foutmelding krijg ik ook, maar deze is weg te halen door in de properties van de bibliotheek achter de avr melding “, esp32” te plaatsen.

De issd en wachtwoord zijn van de maker van de schets, dus geen probleem. Maar bedankt voor de waarschuwing.

Als ik nu de originele schets compileer dan krijg ik ook de melding dat er een probleem is met de analogeWrite.h, hiermee zitten we nu dus op een lijn.

Als ik de aangepaste schets compileer dan gaat dit foutloos. Na het inladen krijg ik het ip adres op het display en kan ik met het tablet contact maken met het smarthome. De led, het raam en de ventilator kan ik bedienen. Alle overige projecten reageren niet.

Ik ben heel blij met de vorderingen tot nog toe. Het geeft weer moed om verder te gaan.

Met de hoop dat de analogeWrit de laatste hobbel is en dat deze kan worden opgelost, en met vriendelijke groet,

Cees

Berichten: 6
Geregistreerd: 14 Jan 2024, 15:45

Re: Fout in h bestand?

Berichtdoor Cees » 07 Feb 2024, 12:22

Op internet nog eens aan het zoeken gegaan naar commentaren/reviews over het pakket. Ik ben er één tegengekomen die het pakket beoordeelt.

De recensent heeft de losse projecten van het pakket uit geprobeerd, en daar werken een aantal niet van. Dat was bij mij ook zo. Het lijkt er op dat de schetsen wat slordig gemaakt zijn. Er ontbreken her en der wat tekens zoals haken, of puntkomma's. Na veel zoekwerk, op één na, de projecten werkend gekregen. Ook de recensent kreeg dit project niet werkend.

Omdat de aangepaste schets van Serretje Too wel werkte heb ik de originele schets weer uitgeprobeerd zoals ik in het vorige bericht heb aangegeven. De analogeWrite.h geeft dan problemen. Deze heb ik in de schets geblokkeerd. De schets lade zonder problemen op het bordje, en alle functies welke beschikbaar zijn in de wifi app gaan op commando werken.

Het resultaat is dat het smarthome project werkend is geworden met jullie hulp. Ik dank iedereen die mij met raad en daad hebben bij gestaan.

Met vriendelijke groet,

Cees.

Terug naar Arduino IDE

Wie is er online?

Gebruikers in dit forum: Geen geregistreerde gebruikers en 39 gasten