[PORADNIK] Arduino IDE

User avatar
veeroos
Posts: 1081
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

a przykład który działa wygląda tak:

Code: Select all

/*

This is example for SHT3X-DIS Digital Humidity & Temperature Sensors Arduino Library
ClosedCube SHT31-D [Digital I2C] Humidity and Temperature Sensor Breakout

Initial Date: 06-Oct-2015
Last Updated: 12-Oct-2016

Hardware connections for Arduino Uno:
VDD to 3.3V DC
SDA to A4
SCL to A5
GND to common ground

MIT License

*/

#include <Wire.h>
#include "ClosedCube_SHT31D.h"

ClosedCube_SHT31D sht3xd;

void setup()
{
	Wire.begin();

	Serial.begin(9600);
	Serial.println("ClosedCube SHT3X-D Single Shot Mode Example");
	Serial.println("supports SHT30-D, SHT31-D and SHT35-D");

	sht3xd.begin(0x44); // I2C address: 0x44 or 0x45

	Serial.print("Serial #");
	Serial.println(sht3xd.readSerialNumber());
}

void loop()
{
	printResult("ClockStrech Mode", sht3xd.readTempAndHumidity(SHT3XD_REPEATABILITY_LOW, SHT3XD_MODE_CLOCK_STRETCH, 50));
	delay(250);
	printResult("Pooling Mode", sht3xd.readTempAndHumidity(SHT3XD_REPEATABILITY_HIGH, SHT3XD_MODE_POLLING, 50));
	delay(250);
}

void printResult(String text, SHT31D result) {
	if (result.error == SHT3XD_NO_ERROR) {
		Serial.print(text);
		Serial.print(": T=");
		Serial.print(result.t);
		Serial.print("C, RH=");
		Serial.print(result.rh);
		Serial.println("%");
	} else {
		Serial.print(text);
		Serial.print(": [ERROR] Code #");
		Serial.println(result.error);
	}
}
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
User avatar
veeroos
Posts: 1081
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

Sorki za post pod postem, ale znalazłem brakowało biblioteki Wire.h w bibliotese SHT3x, chyba juz slepy jestem gapiłem się w bibliotekę 2 godziny i nie widziałem
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
User avatar
klew
Posts: 13905
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

veeroos wrote: Fri Feb 10, 2023 10:47 am Sorki za post pod postem, ale znalazłem brakowało biblioteki Wire.h w bibliotese SHT3x, chyba juz slepy jestem gapiłem się w bibliotekę 2 godziny i nie widziałem
Czyli wystarczyło dodać:

Code: Select all

Wire.begin();
w setup?
Najlepsze suple dla Twojego domu :mrgreen:
User avatar
veeroos
Posts: 1081
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

klew wrote: Fri Feb 10, 2023 10:52 am
veeroos wrote: Fri Feb 10, 2023 10:47 am Sorki za post pod postem, ale znalazłem brakowało biblioteki Wire.h w bibliotese SHT3x, chyba juz slepy jestem gapiłem się w bibliotekę 2 godziny i nie widziałem
Czyli wystarczyło dodać:

Code: Select all

Wire.begin();
w setup?
Ja do biblioteki SHT3x dodałem #include "Wire.h" oraz w inicie Wire.begin(); i odczyt ruszył poprawnie, może dodaj to do biblioteki żeby więcej nikt się nie motał 😉.
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
User avatar
klew
Posts: 13905
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

veeroos wrote: Fri Feb 10, 2023 10:59 am
klew wrote: Fri Feb 10, 2023 10:52 am
veeroos wrote: Fri Feb 10, 2023 10:47 am Sorki za post pod postem, ale znalazłem brakowało biblioteki Wire.h w bibliotese SHT3x, chyba juz slepy jestem gapiłem się w bibliotekę 2 godziny i nie widziałem
Czyli wystarczyło dodać:

Code: Select all

Wire.begin();
w setup?
Ja do biblioteki SHT3x dodałem #include "Wire.h" oraz w inicie Wire.begin(); i odczyt ruszył poprawnie, może dodaj to do biblioteki żeby więcej nikt się nie motał 😉.
Masz może dwa SHT aby sprawdzić, czy dwukrotne odpalenie Wire.begin nie spowoduje problemów?
Najlepsze suple dla Twojego domu :mrgreen:
User avatar
veeroos
Posts: 1081
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

klew wrote: Fri Feb 10, 2023 11:07 am
veeroos wrote: Fri Feb 10, 2023 10:59 am
klew wrote: Fri Feb 10, 2023 10:52 am

Czyli wystarczyło dodać:

Code: Select all

Wire.begin();
w setup?
Ja do biblioteki SHT3x dodałem #include "Wire.h" oraz w inicie Wire.begin(); i odczyt ruszył poprawnie, może dodaj to do biblioteki żeby więcej nikt się nie motał 😉.
Masz może dwa SHT aby sprawdzić, czy dwukrotne odpalenie Wire.begin nie spowoduje problemów?
Tak mam ale sprawdzę to po południu, bo w pracy mam tylko jedną sztukę
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
User avatar
veeroos
Posts: 1081
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

Ale na szybko dodałem 2 czujniki do programu, dodałem to do Clouda i jak na razie chodzi, terminal wypluwa na jednym z kanałów błąd -20 ale oba czujniki widoczne są w aplikacji
Screenshot_2023-02-10-12-19-09-983_org.supla.android.jpg
You do not have the required permissions to view the files attached to this post.
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
User avatar
klew
Posts: 13905
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

veeroos wrote: Fri Feb 10, 2023 11:19 am Ale na szybko dodałem 2 czujniki do programu, dodałem to do Clouda i jak na razie chodzi, terminal wypluwa na jednym z kanałów błąd -20 ale oba czujniki widoczne są w aplikacjiScreenshot_2023-02-10-12-19-09-983_org.supla.android.jpg
Rozumiem, że tego drugiego nie ma fizycznie podłączonego?
A mógłbyś w kodzie zamienić kolejność, tzn. najpierw podaj SHT z nieistniejącym adresem, a drugi ten istniejący?
Najlepsze suple dla Twojego domu :mrgreen:
User avatar
veeroos
Posts: 1081
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

klew wrote: Fri Feb 10, 2023 11:23 am Rozumiem, że tego drugiego nie ma fizycznie podłączonego?
A mógłbyś w kodzie zamienić kolejność, tzn. najpierw podaj SHT z nieistniejącym adresem, a drugi ten istniejący?
Fizycznie nie mam, zamieniłem ich kolejność i działa, teraz na pierwszym kanale wypluwa błąd a na drugim temperaturę i wilgotność
Screenshot_2023-02-10-12-28-29-227_org.supla.android.jpg
You do not have the required permissions to view the files attached to this post.
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
User avatar
klew
Posts: 13905
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

Ok, to czekam jeszcze jak to sprawdzisz z dwoma czujnikami i wtedy wrzucę poprawkę.
Najlepsze suple dla Twojego domu :mrgreen:

Return to “FAQ / Jak to zrobić”