# Data from DHT11 temp sensor and timestamp from DS1302 on SD card

**URL:** <https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416>\
**Category:** XOD Programming Questions\
**Created:** [September 11, 2020, 11:50am UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416 "2020-09-11T11:50:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![unosoperator](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/unosoperator/32/2678_2.png) [@unosoperator](https://forum.xod.io/u/unosoperator)\
**Post date:** [September 11, 2020, 11:50am UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/1 "2020-09-11T11:50:46Z")

</div>

I want to collect data from DHT11 sensor every 5 seconds, add timestamp from DS1302 RTC module, and save it to sd card. But I get empty \*.txt file with no data.

 ![Bez tytułu](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/f/f149a6908f5c3afe6890cf231a25badb05f7e19c.jpeg)

[ht11-log.xodball](https://forum.xod.io/uploads/short-url/kh49BRB9GQDkmsgF7SbDGGt6az2.xodball) (9.0 KB)

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [September 11, 2020, 3:52pm UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/2 "2020-09-11T15:52:10Z")

</div>

A defer node between cht11 & sd-log might help. You are just starting RTC read the same time you start sd-log in current config. I would think you would get old data logged if that was the only problem, though…

---

<div class="post-metadata">

**Author:** ![unosoperator](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/unosoperator/32/2678_2.png) [@unosoperator](https://forum.xod.io/u/unosoperator)\
**Post date:** [September 11, 2020, 5:00pm UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/3 "2020-09-11T17:00:51Z")

</div>

You mean something like this. I still get empty file.

 ![Bez tytułu](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/a/a68027bc9bd52fb954bab5f047b5713a6ba17e36.jpeg)

---

<div class="post-metadata">

**Author:** ![unosoperator](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/unosoperator/32/2678_2.png) [@unosoperator](https://forum.xod.io/u/unosoperator)\
**Post date:** [September 17, 2020, 5:18pm UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/4 "2020-09-17T17:18:11Z")

</div>

Hi. I still can’t solve my problem.

---

<div class="post-metadata">

**Author:** ![gabbapeople](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/gabbapeople/32/1517_2.png) [@gabbapeople](https://forum.xod.io/u/gabbapeople)\
**Post date:** [September 17, 2020, 5:30pm UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/5 "2020-09-17T17:30:19Z")

</div>

@unosoperator  
Debug the program. Separate it into pieces, rtc, thermometer, sd-log. Using watch and tweak nodes test each of this part and find out what isn’t working. Start with the sd-log. Try to change the filepath and shorten the filename.

---

<div class="post-metadata">

**Author:** ![unosoperator](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/unosoperator/32/2678_2.png) [@unosoperator](https://forum.xod.io/u/unosoperator)\
**Post date:** [September 17, 2020, 8:04pm UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/6 "2020-09-17T20:04:17Z")

</div>

Every module work fine separately. Looks like problem is to connect data from both modules.

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [September 18, 2020, 2:10am UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/7 "2020-09-18T02:10:32Z")

</div>

Connect the “OK” output of DHT-11 to “GET” of ds1302.

Library updated is @0.0.7

---

<div class="post-metadata">

**Author:** ![unosoperator](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/unosoperator/32/2678_2.png) [@unosoperator](https://forum.xod.io/u/unosoperator)\
**Post date:** [September 18, 2020, 6:28am UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/8 "2020-09-18T06:28:23Z")

</div>

In debug mode. Value in red circle change rapidly between “+XOD;100:83:0” and “+XOD;101:83:0”. Still, file on sd card is empty.

 ![1](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/b/b34025d3e50f07cef26129e989f385616d357f6e.jpeg)

---

<div class="post-metadata">

**Author:** ![brusher](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/brusher/32/475_2.png) [@brusher](https://forum.xod.io/u/brusher)\
**Post date:** [September 18, 2020, 10:31am UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/9 "2020-09-18T10:31:06Z")

</div>

Looks like your board reboots and probably there is a problem either with memory allocation or a short lifetime of some variable.

Please, attach the xodball, so we can inspect the problem.

---

<div class="post-metadata">

**Author:** ![unosoperator](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/unosoperator/32/2678_2.png) [@unosoperator](https://forum.xod.io/u/unosoperator)\
**Post date:** [September 18, 2020, 10:37am UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/10 "2020-09-18T10:37:07Z")

</div>

[ht11-log.xodball](https://forum.xod.io/uploads/short-url/8ULbn14mJLQV7FK6SJs6TJdYhzE.xodball) (9.5 KB)

---

<div class="post-metadata">

**Author:** ![m-b](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@m-b](https://forum.xod.io/u/m-b)\
**Post date:** [September 18, 2020, 11:52am UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/11 "2020-09-18T11:52:29Z")

</div>

Maybe there is a problem with join and concat  
Sprobujcie ten program moze jest problem z join i concat! Pozdrawiam

[ht11-log.xodball](https://forum.xod.io/uploads/short-url/lBzgveei2NSRyDzH3NXQU4BqX7I.xodball) (13.5 KB)

 ![grafik](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/3/38961847251d3bdf3634e2d99a32c666ff93218d.png)

---

<div class="post-metadata">

**Author:** ![unosoperator](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/unosoperator/32/2678_2.png) [@unosoperator](https://forum.xod.io/u/unosoperator)\
**Post date:** [September 18, 2020, 2:23pm UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/12 "2020-09-18T14:23:56Z")

</div>

Thanks. I tried your file but I still get empty txt . I can save on sd card only date and time, or only temperature and humidity but not all of them. Also tried this, but with no result:

 ![2](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/1/17586af61d87d667f256b54af9f6bf846eb03f1b.jpeg)

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [September 18, 2020, 3:18pm UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/13 "2020-09-18T15:18:55Z")

</div>

Remove the `defer`, and on the output of `join` use " `pulse-on-change` to W

---

<div class="post-metadata">

**Author:** ![unosoperator](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/unosoperator/32/2678_2.png) [@unosoperator](https://forum.xod.io/u/unosoperator)\
**Post date:** [September 18, 2020, 3:38pm UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/14 "2020-09-18T15:38:03Z")

</div>

`cesars`, that way there isn’t even empty file, sd stays empty.

 ![2](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/7/75687f230aa13a9bd6fb8baed97f8bdb9c941679.jpeg)

---

<div class="post-metadata">

**Author:** ![brusher](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/brusher/32/475_2.png) [@brusher](https://forum.xod.io/u/brusher)\
**Post date:** [September 18, 2020, 3:58pm UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/15 "2020-09-18T15:58:13Z")

</div>

I’ve inspected your xodball and this sketch works fine, but only on the microcontroller with enough memory (Arduino Mega). When I uploaded it to the Arduino Uno I got the same behavior.

The reason is `sd-log` (actually, SD library inside) uses a HEAP memory, and if your sketch (this one, not any sketch) uses more than 50% of dynamic memory on your board, I bet this not enough left for the HEAP.

The simplest solution: use a more powerful board with a lot of dynamic memory.  
The complex one: write a node/library without using a default SD library and without consumption of HEAP memory 🤓

Please, mention to me if the suggested solutions won’t work or you found the better one.

P.S.  
Which board model do you use?

---

<div class="post-metadata">

**Author:** ![unosoperator](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/unosoperator/32/2678_2.png) [@unosoperator](https://forum.xod.io/u/unosoperator)\
**Post date:** [September 18, 2020, 4:33pm UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/16 "2020-09-18T16:33:50Z")

</div>

@brusher I have Arduino Uno and Nano.

This is use of memory on Uno. Right now I noticed that low memory warning:

 ![2](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/2/21f20b2ad66f2db12059953b9f936fda97f22c8f.jpeg)

> [@brusher](#):
>
> The complex one: write a node/library without using a default SD library and without consumption of HEAP memory

I think I wont be able to do this , because my skills are very low in programming. Everything more complicated than “blink” led write in Arduino IDE gives me a headache. Thats why I moved to XOD. Looks like I need to use Mega board for this project.

Anyway, thanks you guys for help.

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [September 18, 2020, 5:55pm UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/17 "2020-09-18T17:55:35Z")

</div>

In your example above, the watch node on the join is only showing “watch”. This implies it does not have any data to output, which would explain why you are not getting any data logged and using pulse-on-change never creates the file (there is never a change). This is still only a symptom of the root problem (which @brusher has tracked down to an out-of-memory issue), but it is a hint that there is a serious underlying issue if a join with input data doesn’t have any output…

---

<div class="post-metadata">

**Author:** ![unosoperator](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/unosoperator/32/2678_2.png) [@unosoperator](https://forum.xod.io/u/unosoperator)\
**Post date:** [September 18, 2020, 6:31pm UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/18 "2020-09-18T18:31:25Z")

</div>

I remove sd card node and everything work perfect:

 ![2](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/a/a8aa3e93504445eb55d4fe076f103788b1eceba7.jpeg)

… and after adding sd card node, even not connected to anything:

 ![3](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/2/22163bbf8c772776facbda8263507c9b16ca4e45.jpeg)

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [September 18, 2020, 7:25pm UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/19 "2020-09-18T19:25:36Z")

</div>

Did you try to use another pin for CS, for example D4?

---

<div class="post-metadata">

**Author:** ![unosoperator](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/unosoperator/32/2678_2.png) [@unosoperator](https://forum.xod.io/u/unosoperator)\
**Post date:** [September 18, 2020, 7:37pm UTC](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416/20 "2020-09-18T19:37:47Z")

</div>

Yes, but with no luck.

[Next page](https://forum.xod.io/t/data-from-dht11-temp-sensor-and-timestamp-from-ds1302-on-sd-card/4416.md?page=2)
