lrswss / tasmota-am2320-i2c-driver

Driver for Sonoff-Tasmota to support the temperature/humidity sensor AM2320 (I2C)
GNU General Public License v3.0
6 stars 4 forks source link

Fix for compatibility with Tasmota 7.0.0.4 #2

Open arovak opened 4 years ago

arovak commented 4 years ago

I have made modifications so that this driver can be used with Tasmota 7.0.0.4. I have tested this in 7.0.0.4 and in 6.7.1.

OberfragGER commented 4 years ago

Hi, thanks for the driver. Due missing skills, can you please provide a complete .bin files with Tasmota 7.0.0.4 ???

How is it possible to download the fixed .ino file? I just see some commits from Nov. 2019. The files are still from Jan 2019...!?!

Thanks in advance

arovak commented 4 years ago

Just use the portable VSC found here and follow the instructions to compile yourself. The fix will also work on the newest 8.1.x tasmota builds.

Klugschieter commented 4 years ago

Hi, I´m too not shure if I have the actual fix. I have 3 Sonoff SVs, only one of them can read the AM2320. The one that works has been flashed some time ago. But after all that testing with the new Sonoff SVs, I´m not sure anymore, if the fix I´m using is the correct one .... So, like OberfragGER the question: Where to get the actual fix?

PS: The SV thats works runs like charm. Great work! Because of that and the fact that I have two more AM2320 here, I have ordered two more SV,. Sadly I had spend the weekend on getting them to run with the AM2320, thats why I jumped on this open train ...

OberfragGER commented 4 years ago

Hi, i just found the actual fix on arovaks github repo! The one which is 3 month old.

I dont installed the AM2320 yet. I just wanted to...

If you have compiled a 8.1 tasmota- please let me know!!! Or write me. Im very interested!

Wäre Klasse! Hier schreiben ja eh nur Deutsche ;) Avorak scheint ja auch ein Deutscher zu sein ;)

Klugschieter commented 4 years ago

Ok, I have the fix from November, it is the one I tested with. But sadly don´t work for me. Tested with Tasmota 7.1 + 7.2 + 8.1 I´m out of ideas.

PS: Gerne deutsch, aber 1. abwarten, ob Avorak auch Deutsch spricht und 2. ist englisch natürlich hilfreicher für spätere Leser.

OberfragGER commented 4 years ago

I think i have some time on the weekend for further testing.

Wich sonoff do you have? I habe the sonoff basic r3 rf- looking for right gpios is quite a challenge but seems that i can use rx&tx for gpio 2 and 3.

Meanwhile maybe i have the time to compile. Are you using the Arduino IDE? Im quite new with that so i dont have any clue how to import 2 .inos.

Hopefully the internet is helpful.

OberfragGER commented 4 years ago

Aah. @Klugschieter! Did you turned off the serial logging feature? I found the hint that this is blocking the I2C data.

OberfragGER commented 4 years ago

...just found out- there is also an I2Ccommand... not sure if you have to use this.

Klugschieter commented 4 years ago

Serial logging has been deactivated, but no change. I have now test the hard way, to proof that it is a software problem, not an hardware problem. I have flashed the working one with the new bin and it has then no Temp/Hum too. Which I2C Command you mean? Thanks for helping by the way. In Deutsch wäre es wirklich einfacher .... :-D

OberfragGER commented 4 years ago

https://github.com/arendst/Tasmota/commit/d2e152f91b1d722e1ce41b96c47dded2f5332ac9#commitcomment-35791139

Klugschieter commented 4 years ago

01:23:20 RSL: stat/tasmota/RESULT = {"I2CDriver":"7,8,9,10,11,15,20,92"} Thats looks to me like 92 is active ?! but 01:24:27 CMD: I2Cscan 01:24:27 RSL: RESULT = {"I2CScan":"No devices found"}

Can it be, that there is a missing library? Only see `#ifdef USE_I2C

include

endif // USE_I2C`

Are there other needed libraries?

OberfragGER commented 4 years ago

For me its looking that 92 is active. I just sent the same commando to a "clean" Sonoff Basic R3 RF with Tasmota 8.1 with the following result: stat/tasmota/RESULT = {"I2CDriver":"7,8,9,10,11,15,20"}

Klugschieter commented 4 years ago

Thanks OberfragGER, I have the same output on other Sonoffs without the driver. So, the driver is active, but why is it not showing the values?

I now have tested the gpios with a switch, it works correctly on all gpios.

@arovak: Looks like only you can help at this point ....

@OberfragGER: Weil Du es oben erwähntest, der Sonoff SV ist natürlich ideal für diesen Sensor, weil er von Haus aus 3 offen zugängliche gpio-Steckplätze hat, ohne erst zu löten. Ich liebe ihn, auch habe ich immer einen auf dem Schreibtisch zum rumtesten. Kann ich nur empfehlen. Und ja, ich nutze Arduino IDE.

arovak commented 4 years ago

please try #undef USE_BH1750 in my_user_config.h just before #define USE_AM2320

the driver for BH1750 (driver 11) uses the same address as AM2320 so there is a conflict the active drivers should not contain driver 11 [17:35:39] stat/esp07/RESULT {"I2CDriver":"7,8,9,10,15,20,22,92"}

It should work when driver 11 is not loaded and driver 92 is loaded. image

Klugschieter commented 4 years ago

Yeah, that did the trick! :-) Flashed it with that change on all 3 Sonoff SVs and all of them now show Temp+Hum. @arovak: Thanks a lot ! You made my day ...

Maybe interesting for later users: On two of the Sonoffs I have to configure the gpios, save and restart the device, go to settings again and save the same gpio settings again. After that second restart the sensors works fine, even after restart of the sonoff.

arovak commented 4 years ago

I'll update my PR later to include the #undef USE_BH1750 so it is more clear for future reference

OberfragGER commented 4 years ago

thx a lot to arovak and Klugschieter. I think i´ll have some time at the weekend.

@Klugschieter: Mal so ne blöde frage für ganz faule... kann man mit der Arduino-Ide nicht auch einfach eine .bin erstellen? Hast ja alles fertig. Dann würde ich mir viel Arbeit ersparen...

nett gefragt

Klugschieter commented 4 years ago

@OberfragGER .bin kannst Du haben. Allerdings denke ich, dass es nicht erwünscht es hier als Anhang. Sonst hättest Du die .bin schon lange :-) Gibt´s hier bei GitHub Messaging oder Mails?

OberfragGER commented 4 years ago

Danke im Vorraus. Dann spare ich mir das flashen via FTDI. Dann mache ich mal ein OTA Flash mit den SOnoff Tools und kann den DHT direkt ranlöten.

OberfragGER commented 4 years ago

Hey all, i will confim - its working with the Sonoff Basic R3 RF. I used the pinouts of gnd, vcc, rx and tx for this sensor. rx and tx is the GPIO1 and GPIO3 and its usable with the "Sonoff RF" Layout.

OberfragGER commented 3 years ago

Hey all together,

it is possible to use this driver with Tasmota 9.2, including BH1750! I have used Visual Studio with PlatformIO.

For adress conflicts i pulled the 'adress' Pin from the BH1750 to low/ ground. So no 2 devices have the 0X0.5 adress. Just for Information- DHT12 also uses the same adress and no possibilty to change that.

I hope someone will read this.... i had do uncomment 2 variables and maybe we get this fixed. Just 2 small codes pieces...

The 2 undeclared variables are: log_data and uptime

Error code: undefined in scope...

Maybe someone has any idea. I think these 2 variables are need for error handling. Something i dont need. I hope my small code change doesnt affect the stability.

image

arovak commented 3 years ago

Hello, yes you can use the driver with tasmota 9.2. you will need to get the updated file from my fork as the original repo here does not get updated.

I am running it without problems in 9.2.0.2. afbeelding

As for using this driver together with BH1750, I believe it is possible but I cannot test because I do not have a BH1750 sensor.

You have pulled the address pin on BH1750 low, so it has address 0x23 now. So what I would try is to change BH1750_ADDR2 in tasmota driver xns_10_bh1750.ino For example try to change line 37 from #define BH1750_ADDR2 0x5C to #define BH1750_ADDR2 0x5D This way tasmota will not look for a BH1750 sensor on the same address as the AM2320.

Hope it helps

OberfragGER commented 3 years ago

Great and thanks a lot. Found the file in your repo! Its working very fine. Also with the dew point!!! I uncomment also the DHT_12 to avoid strange behavior. I learned a lot within the last days... to geht the BH1750 working. For some reasons its not needed to pull the BH1750 to ground. thanks a lot with the pointing how to change the adress. Works fine out of the box. Just found the 9.2.0.0 Tasmoat-Version.

I also found the same solution than you: uptime -> TasmotaGlobal.uptime ;)

image

Klugschieter commented 2 years ago

Hi, old thread, new question: Tasmota 9.2 with AM2320 runs without problems. Except the unprecise values from the AM2320. If I want to adjust the values and use the "TempOffset" or "HumOffset"-Command in Tasmota-Console that will be without a change in the values, though the Offset was accepted from Tasmota image Is there another way to adjust?