Go Down

Topic: Conflict of DHT_sensor_library & I2C bus (Read 595 times) previous topic - next topic

LukasCZE

Apr 27, 2017, 05:51 pm Last Edit: May 03, 2017, 07:48 pm by LukasCZE
original title of topic: Conflict of Ethernet shield & DS1307 RTC I2C module
new title, after identification of problem: Conflict of DHT_sensor_library & I2C bus
----
Hello,

I am having temperature logger to SD card and phant.io (data.sparkfun.com) upload and both works correctly when not trying to include libraries

Code: [Select]
#include <Wire.h>
#include <RTCx.h>


when I include any of them, SD logging works (...not actually checked, but SD.open returns TRUE) but
Code: [Select]
client.connect(server, 80)
 fails always 

Denote that SS of SD/W5100 on SPI bus is correctly handled through pins 4 and 10 as it works without RTC.

DS1307 is connected @ I2C pins 20 and 21 on Arduino Mega.
Denote DS1307 works with arduino example sketch withouth problem.

There must be some conflict in libraries right?

Any ideas?

Regards
Lukas

LukasCZE


pylon

Quote
There must be some conflict in libraries right?
I doubt that, my guess is a memory problem.

You didn't provide a link to the used library for the DS1307 but I guess you used this one. If this is correct, I cannot find anything that would interfere with the Ethernet library (given you really just used the include lines and not a single line of code that actually uses the library).

Post your complete code.

LukasCZE

#3
Apr 27, 2017, 07:09 pm Last Edit: Apr 27, 2017, 08:59 pm by LukasCZE
code is uploaded the in the post latter,

I migrated to MEGA from uno. There is around 6000 B free in SRAM, the program takes about 10% of program memory btw (I consider as not important).

I migrated to MEGA from UNO thinking it is memory problem actually.

Yes, i use those <Wire.h>, <RTCx.h>. Including any of them cause malfunction of ethernet.

Remark: I tried to include all libraries i use (or would like to use) into WebClient ethernet example sketch and it worked! I am confused now hard.

So there might be some relation to my program I dont see. Not only library problem!

Lukas.

some additional info from compilation:
----------------------------------------
edit 1:
Multiple libraries were found for "SD.h"
 Used: C:\Users\Lks\Documents\Arduino\libraries\SD
 Not used: C:\Program Files (x86)\Arduino\libraries\SD
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI
Using library Ethernet at version 1.1.2 in folder: C:\Program Files (x86)\Arduino\libraries\Ethernet
Using library DHT_sensor_library at version 1.2.3 in folder: C:\Users\Lks\Documents\Arduino\libraries\DHT_sensor_library
Using library SD at version 1.1.1 in folder: C:\Users\Lks\Documents\Arduino\libraries\SD

Sketch uses 26,892 bytes (10%) of program storage space. Maximum is 253,952 bytes.
Global variables use 1,322 bytes (16%) of dynamic memory, leaving 6,870 bytes for local variables. Maximum is 8,192 bytes.

-----------------------
edit 2: I am having a problem similar to this: http://forum.arduino.cc/index.php?topic=175000.5 but I have Mega now, so I believe there is plenty of memory (?).

pylon

Quote
I migrated to MEGA from uno. There is around 6000 B free in SRAM, the program takes about 10% of program memory btw (I consider as not important).
I usually call RAM memory while flash is storage but I agree that is very subjective. Your program does use 1.3kB for global variables which is 16% of the available RAM on the Mega but about 70% of the UNO. In the case of the Mega the used RAM shouldn't be a problem.

Quote
So there might be some relation to my program I dont see. Not only library problem!
I'm quite sure that it's related to your program but it could be the some libraries are incompatible but I doubt that it's the Ethernet and the RTC library, given my assumption about the source of that library is correct (which you didn't answer BTW).

Provide links to the libraries you use! Post a wiring diagram of how everything is connected.

You wrote that including any of the two libraries results in no connection to the server. So if you just include the Wire library you don't get that connection although you make absolutely no call to it?

LukasCZE

Hi,
thanks for your answer.

Q: So if you just include the Wire library you don't get that connection although you make absolutely no call to it?
A: yes. as I said.


Q: library
A: https://github.com/stevemarple/RTCx , the other libries I consider as default libs (same as used in Examples). I am not sure how to manage all the library issues... for example: i will debug this project and lets say share the sketch on some website but then time goes and someone will change some library that it stops working. how to avoid this? should i carry all the libraries with the sketch with the tested versions of them?

Q: Post a wiring diagram of how everything is connected.
A: N/A,  I am not at home, I will post later. but the rtc module is connected to 5V,GND and I2C pins such that it works with the simple example sketch. the ethernet shield: pins 10/4 for Ethernet/SD and they share SPI bus. some analog pins are used. denote that i dont change the hardware but only sketches and the individual things are tested.

Lukas

LukasCZE

#6
May 01, 2017, 09:15 pm Last Edit: May 01, 2017, 09:27 pm by LukasCZE
I am attaching

SPI
Ethernet
SD
DHT_sensor_library

libs that I use.

pylon

Comment out these two lines in your code and if my guess is correct your problems are gone even if you include the Wire library:

Code: [Select]
    int temp1 = (int)(dht.readTemperature());


and
Code: [Select]
    int humid1 = (int)(dht.readHumidity());


You may have to comment out some more lines (like Serial.print()s) or define the variables to a fixed values to make the code compile after the commenting out.

If that works you have to search for a better DHT library. This one blocks interrupts for an average of 4ms for each of these calls and in 4 milliseconds a lot of traffic is going over a network. If the interrupt is blocked that processor cannot react on these events which might end in a freeze.

Try this library that uses interrupts to communicate which the DHT: https://github.com/niesteszeck/idDHT11

LukasCZE

Hi,

thans for your help! commenting out those lines allows me to use working RTC. Currently I suspended DHT11 sensor and will try another library later.

I will post some more complete solution later.

Lukas

Go Up