Closed JopWerff closed 2 years ago
Good morning Job,
Never worked with the AM2315 so I have to check the datasheet.
Hoi Job,
Sorry this is an I2C device so it cannot be controlled by the DHTNew library. The specs (error rate) of that sensor look quite good.
The data transferred resembles my DHT12 library which is I2C. It uses another fixed address (easy to patch), and the low level datatransfer might need some fixes. (I see the AM2315 has far more registers to be read)
You mention the DHTNew has some advantages over other libs. Can you specify which ones you need?
Best option is to create a new library specific for this sensor. I'm busy this week and at least part of next but if you are in a hurry we might discuss a sponsored project.
Regards, Rob
An alternative might be - https://github.com/adafruit/Adafruit_AM2315 It is basic but it will get you started.
Hoi Rob,
Thnx for your lightning fast response.
To answer your last question - the advantages of your DHTNew:
you library looks elegant, easy to implement
I see your point, AM2315 is an only-I2C-sensor - your proposed DHT12 has two options, I2C and one-wire.
The Adafruit library, you mentioned, I tested already a bit.
But you wrote about your DHT12-library. Where to find? After some wandering around on your Github I found an almost secret or hidden wealth of libraries you developed. https://github.com/RobTillaart/Arduino/tree/master/libraries
(may you should "showcase" these libraries a bit more. )
Is your DHT12-library really suitable for the AM2315? And a better alternative compared to the Adafruit_AM2315?
Unfortunately there is no budget for sponsoring development of a good library, as all this work is done for an Ice-skating club in Winterswijk (WIJV), Netherlands. And they run out of budget. The only thing that I can do is mentioning you in the credits in the software for a system that is used to sensor on many places temperatures and humidity. This natural ice rink is getting a lot of publicity (google just for the words: Winterswijk, schaatsen, ijs, natuurijs, "Wonder van Winterswijk"). As you know, as a Dutchman, Holland is getting crazy when there is frost and natural ice! Here some info: https://www.trouw.nl/binnenland/weinig-kans-op-schaatspret-op-natuurijs-behalve-in-winterswijk~b8b5b455/ https://jeugdjournaal.nl/artikel/2410373-schaatsplezier-in-winterswijk-nu-al-natuurijs.html https://www.nporadio1.nl/fragmenten/nieuws-en-co/e5982c44-4a2a-4718-8a9f-7e00289fb636/2021-12-21-in-winterswijk-kan-al-geschaatst-worden https://www.hartvannederland.nl/nieuws/weer/eerste-meters-op-natuurijs-zijn-geschaatst https://www.gelderlander.nl/achterhoek/schaatspret-op-tweede-kerstdag-in-winterswijk-we-durfden-het-niet-voor-te-stellen-aan-onze-vrouwen~afadade3/
See also this attach, a newspaper picture with short description
Regards,
Jop
DHTNew advantages Clear points,
DHT12 The DHT12 library can be found here - https://github.com/RobTillaart/DHT12 But I'm not sure if it is compatible, not read the very details yet.
AM2315 library
Unfortunately there is no budget for sponsoring development of a good library, as all this work is done for an Ice-skating club in Winterswijk (WIJV), Netherlands. And they run out of budget. The only thing that I can do is mentioning you in the credits in the software for a system that is used to sensor on many places temperatures and humidity.
OK, I understand, and a mention is fair enough. I will see what I can do this week.
What I propose is to start with the DHTNew library as interface and adapt it to meet the AM2315 specs. (deleting code is faster than typing new)
Would you be able to test the library?
PS, no skater myself, it looks pretty cool (in both ways :) to have such skating track. How long is it?
Q: which processor board do you use?
What I propose is to start with the DHTNew library as interface and adapt it to meet the AM2315 specs.
apparently I need to strip more (OK my party)
Almost created a first version of the library - https://github.com/RobTillaart/AM2315
(still in develop branch)
Please let me know if it works. If not please share the output
Hoi Rob,
I'am very pleased if you will adapt the DHTNew Library. And I assume that this will uplevel your library as suitable for more I2C-humidity sensors of this type (so using 2 pins as the DHT12 and some range in the AM-series).
I think I'm able to test. Testing in the practice of the skate rink in Winterswijk will be later. In your DHT12 library I see useful routines as: void setHumOffset(float offset) set an offset to calibrate (1st order) the sensor. float getHumOffset() return current offset, default 0. void setTempOffset(float offset) set an offset to calibrate (1st order) the sensor float getTempOffset() return current offset, default 0. Calibration: you should give me a tip how to calibrate for humidity.
I use this processor (12x): LilyGO TTGO T7 Mini32 V1.3 ESP32 - 4MB Flash
I will mention your name in the credits for this software. Moreover I will attend the guys at TinyTronics (I'm a regular customer) on your libraries as very useful for DHT and also for this AM-type sensors. Maybe they will put a link to your software at their products.
The skating tracks in Winterswijk consist of a 400m-rink (official distance for competitions) and a rectangular ice field of 1000m2, meant for young children, beginners and ice dancers.
Thnx for your offer to do this adaptations,
Jop
AM2315 will be a new separate library as the low level protocol is really different from the DHT22 and alike. (it might be compatible with other AM23xx devices)
Give those folks at TT my regards, they know me. Tell them I'm working on a library for the AM2315 sensor, they might send me one :)
Please let me know your test result. Just a local test is good, does it give realistic values.
If you have other test sketches that might work as example, please send them over and I will add them to the lib.
Calibration: you should give me a tip how to calibrate for humidity.
Humidity is hard to measure exactly. I had a SHT85 sensor from Sensirion which is a pretty reliable sensors. However I was able to fry it (and they are more expensive than this AM one). Currently I have two in a back order.
So you might look at - https://www.weerplaza.nl/actueel/relatieve-vochtigheid/ or similar sites to do a 1st order calibration. You can click on some numbers there and see actual data e.g. https://www.weerplaza.nl/nederland/hupsel/2749993/actueel/
I have to switch to other work now, so it can take time before replies appear.
@JopWerff I move this discussion to the AM2315 library - https://github.com/RobTillaart/AM2315
FYI - the automatic build (LINT) fails as the library is not registered yet at Arduino. (first test, then add release, then register)
FYI, AM2320 I2C interface looks the same as AM2315 ( put on my wish list )
update: That means that my https://github.com/RobTillaart/AM232X library should work too. (and this lib is tested)
This lib does not have offset, but that is easy to add (working on it right now).
update https://github.com/RobTillaart/AM232X (develop branch) is ready for testing..
(fixed things in the AM2315 develop branch too)
Hoi Rob,
You are developing so fast.... I can't keep up.
Important thing to mention in your example(s): which pins (the numbers) I should use to connect the AM2315?
And if it is needed that I use other pin-numbers for I2C CLCK and DATA, how I will make this clear in initializing the library?
For now I want to use these numbers:
#define AM2315_SCL_PIN 19
#define AM2315_SDA_PIN 5
I got also the Idea (reading your link to the AM2320.PDF) that single bus is possible. Is this true? Can you add an example? For the DHT22 and your library DHTNew I used this pin:
` #define DHTPIN 16 // Digital pin connected to the DHT sensor
DHTNEW mySensor(DHTPIN);
`
Late this afternoon I called TT and indeed your name was well known. They were glad to hear about your library development for the AM2315 (and equal types). I suggested the one at the phone (Mark) to provide you with a free AM2315. He was not the decision maker at TT but he proposed that you have to contact them yourself. I think you have to ask for Loek (or maybe Friso). So that's my suggestion; no problem if you mention my name.
I ordered this afternoon an AM2315 at TT. I hope this will arrive tomorrow, so I can test your developments.
Kind regards,
Jop
you must add the pin numbers in the begin() call, something like
AM2315 sensor(&Wire);
...
sensor.begin(5, 19); // DATA, CLOCK
I got also the Idea (reading your link to the AM2320.PDF) that single bus is possible. Is this true?
not standard, you need an I2C multiplexer e.g. https://github.com/RobTillaart/TCA9548
Found an AM2322 to do some tests, ==> to be continued
The AM2315 lib fails with the AM2322 - investigating...
Please try AM232X library first.
solved with setDisableIRQ(false). The interrupts suppression was needed for the DHT11/22 bitbang protocol. They are apparently needed to get I2C working correctly, so it needs to be removed.
I am waiting now on my AM2315 sent from TT.
Did you contact TT to ask for an AM2315? I guess that's the best and easiest way to develop and test.
Regards,
Jop
Hoi Rob,
This
sensor.begin(5, 19); // DATA, CLOCK
I guess this sensor.begin returns a boolean, indicating if an AM2315-sensor is connected and working?
Did you contact TT to ask for an AM2315? I guess that's the best and easiest way to develop and test.
I send a mail this morning I have published the library.
Having a sensor is the easiest (fastest) way to develop. I have worked in the past with remote testing on a Cozir sensor, a professional CO2 sensor, and yes there was substantial time between the iterations. Also with people living in other substantial other time zones give some delay.
I guess this sensor.begin returns a boolean, indicating if an AM2315-sensor is connected and working?
yes, should be stated in the readme ==> check ==> I see not explicit for the ESP version of begin ... (created a documentation issue for this)
I send a mail this morning I have published the library.
Yes, I've heard about when I called TT end afternoon. I spoke Mark again. I heard they were glad with your library and added already a link to it. Again I asked for a test AM2315 for you and Mark suggested again that you send your self a mail to TT to ask for an AM2315. It is of mutual interest that you can test the exact hardware and not a substitute.
Today I was too busy with other work; this weekend I will go on with AM2315 and your latest version library.
Thnx for all the work so far.
Jop
Thanks, Given that the datasheets were pretty exact the same I am confident it will work. The sensor is on my wish list for my next order, however family, work and other libraries need attention too, so low prio.
this weekend I will go on with AM2315 and your latest version library.
Let me know if you have any troubles!
Hoi Rob,
Accidentally I came on this link, another library for the AM2315: https://forum.hobbycomponents.com/viewtopic.php?t=2418
Maybe it brings you useful info. I didn't try this. Lack of time.
Good weekend,
Jop
Thanks, I'll have a look:
mmm. Apparently a bit proprietary. Won't spend time on it.
Hi Rob,
Did connect and test the new AM2315.
But if (sensor.begin(AM2315_SDA_PIN, AM2315_SCL_PIN)) { // DATA, CLOCK` returned false.
Here pin definitions:
#define AM2315_SCL_PIN 19
#define AM2315_SDA_PIN 5
AM2315 sensor(&Wire);
I tried also with standard pins for SCL (22) and SDA (21) and same result.
When I ignore this returning of 'false' and let go program flow to the loop() I get his output:
I hope you will receive your hardware from TT soon.
Good weekend,
Jop
interesting alternating values.
Are the lines labeled OK reasonable temperatures and humidities?
you might try to increase the readdelay => setReadDelay(3000);
TT order will be done coming week.
Yes, I think so. For the temperature values I'm more sure of it.
The daly between samples in loop() is now 2000 millis.
I added your suggestion and increased my loop()-delay to 10.000 millis. Here the result:
Got worse by this.
But anyway the .begin() reports no sensor present. I have to ignore the result.
Got worse by this.
Not a solution but you could get back to the old timing and setSuppressError(bool b) to skip bad readings
Other thought is to increase the frequency to 1 Hz.
I will check the datasheet if there is some sleep mode or so.
From data sheet - par 7.2.1
Need to add a wake-up call and fix this in the begin() too.
Can you try adding a call to isConnected() after begin? Does it return true? (optionally add a short delay between begin() and isConnected().
That paragraph explains the first log a bit, one call to wake the sensor, the other to read data.
(the good news is that the data can be extracted from the sensor)
OK, the other library AM232X - has a different isConnected() function.
That is used by begin() and by another function called wakeUp().
Can you try that library / test sketch?
If that isConnected() works, it will be an "easy fix".
I created a develop branch with the possible fix included - https://github.com/RobTillaart/AM2315/tree/develop
If time permits you may test it.
Ordered the sensor @ TT, expect delivery on Tuesday => testing on Wednesday
Hoi Rob,
actually cannot spend now more time in this. The idea behind a library is that someone who is more skilled in such, should create a piece of software that we (other programmers) can see as a black box.... ;) You are doing very useful work for us, for that reason I suggested TinyTronics to provide you with free hardware (and they are willing to do).
Just for curiosity I tested the Adafruit version and their test example, as I prepared this already in last week (before I received my AM2315).
After improving first this weird code:
and after that I got this output:
09:43:58.142 -> Perform AM2315 Test!
09:44:01.230 -> Failed to read data from AM2315
09:44:04.252 -> Temp *C: 14.40
09:44:04.252 -> Hum %: 57.20
09:44:07.358 -> Failed to read data from AM2315
09:44:10.428 -> Failed to read data from AM2315
09:44:13.439 -> Temp *C: 14.40
09:44:13.439 -> Hum %: 57.20
09:44:16.554 -> Failed to read data from AM2315
09:44:19.652 -> Failed to read data from AM2315
09:44:22.666 -> Temp *C: 14.40
09:44:22.666 -> Hum %: 57.20
09:44:25.757 -> Failed to read data from AM2315
09:44:28.867 -> Failed to read data from AM2315
09:44:31.850 -> Temp *C: 14.40
09:44:31.850 -> Hum %: 57.10
09:44:34.938 -> Failed to read data from AM2315
09:44:38.038 -> Failed to read data from AM2315
09:44:41.047 -> Temp *C: 14.40
09:44:41.047 -> Hum %: 57.10
as you see your work for a new better library is very needed.
Have a good day,
Jop
actually cannot spend now more time in this.
OK, fair enough.
Apparently the Adafruit shows the same problem as my library.
Thank you for testing as that is very informative.
So I wait until I have my sensor and time for testing the new branch with the wakeUp() code. Will be Wednesday or later, if there is progress I will report here.
Thnx. Great!
I appreciate all your efforts.
(I have another issue I'm thinking "to bring on the table". A new type of sensor. You will read later about this - maybe we should start a new Issue for that - is such possible if there is not yet any software or a library connected to?
Please open a new issue for it as it is not related. (mention type of sensor, and other relevant info).
You can do this under this library as I can move issues to the new library (or just create a placeholder repo).
is such possible if there is not yet any software or a library connected to?
Sure,
Just got the message that the AM2315 sensor is expected tomorrow morning
Good to read. I hope you will solve the last problems we encountered.
Hoi Rob,
tomorrow we can ice skate again in Winterswijk. They are busy now - this night - with preparing this natural ice.
And for this process I will use in the near future this AM2315 aside many other sensors.
Have a good night,
Jop
Good morning, looks like you can have a perfect temperature for an extra layer of ice. Have fun.
Indeed, it's going quite well in the east of the Netherlands:
My new issue, Rob, is a meter to measure the thickness of the ice layer. And this should be a digital meter of course. So the samples can be a continuous stream of data to an ESP32/Arduino.
Now we are measuring the temperatures on different levels above, on and beneath the surface of the rink. These data can be used (not yet implemented) to control the flow of water to the spraying nozzles (when I have time I'll put a video of that process here with a link). The more severe the frost, the higher the flow of water can be. Also the humidity of the air plays an important role (for that reason the AM2315).
But the best and ultimate way to measure the effect of our spraying process would be: getting an idea of "is the ice layer growing or not"? If it grows, how fast it is growing?
As for the climate change we don't have the luxury anymore of many nights with -5℃ frost. A more regular case is a frost that sometimes has a "dip". (temperature > 0℃). At such moment the spraying should stop immediately; otherwise we are spooling or swilling with the sprayed water our just created ice layer away. We like to know also: is the ice layer is growing fast or slow? If it looks like growing fast (and the frost we measure is more severe as the systeem can measure) we can increase the flow of water.
With good measuring of the growth of the ice layer we can develop a self-optimizing system. You see.
This is my first thought for our new issue. Think about it.
Thnx, have a nice day. (o and go for ice skating today in Winterswijk - see Winterswijkse IJs Vereniging WIJV .NL)
Jop
First success with an Arduino UNO in the living room.
Values similar to a AM2320 and room thermostat (.8°C above but sensor is near laptop).
Time to read is approx 3.3 millisecond.
I will upload this version to GIthub asap so you can verify it is working.
Ok, thnx Rob,
This looks much better! Today too busy, but I will try as soon as possible.
Success,
Jop
Hoi Rob,
Your DHTNew is a very nice library and has advantages over the other DHT-libraries. I tested it with the DHT22. I'm working with an ESP32,
For my real life project in the open air in conditions of rain and frost I would like to use a more robust version. This one: https://www.tinytronics.nl/shop/nl/sensoren/lucht/vochtigheid/am2315-i2c-temperatuur-en-vochtigheidsmeter
This complete product is using the AM2315, as you see.
But I read in the specs for your DHTNew: "Supports DHT11, DHT22, DHT33, DHT44, AM2301, AM2302, AM2303 as these all have the same protocol."
You will understand my question now: is your fine library DHTNew also suitable for the AM2315?
Kind regards,