Uno R3, Ethernet Shield, SD card and AM2302

Hi All,

New to the forum, been using Arduinos for small projects for years now, though may have finally got in over my head.

I just started my first Ethernet project and I'm having some problems I am hoping somebody wants to help me with.

Currently my project consists of: Uno R3, 2 analog T-stats (analog inputs), Ethernet shield using SD for html page server and an AD2302.

I want eventually to control 9 relays and an LCD as well in this project, so I am going to upgrade to a mega when it arrives tomorrow.

I have been modifying code from others and implementing parts that test okay for what I'm trying to do with success until yesterday.

The core code for my web page is mostly from this tutorial:

I have successfully ran their code and expanded it to include +3 more analog readouts on the web page and works great.

I tried adding temp/humidity from the AD2302 and can't figure out where I am going wrong.

Without the added code for the AD2302 it runs great, with it I get "SD card initialization failed!" And I can't even ping the ip.

It can be compared to the tutorial linked above, both the html page and sketch.

I was able to run multiple other examples for the AD2302, like this one.

https://create.arduino.cc/projecthub/ThothLoki/portable-arduino-temp-humidity-sensor-with-lcd-a750f4?ref=platform&ref_id=424_trending___&offset=87

Code attached, if anyone has the time to check it out I'll be very grateful!

I know I'm very low on memory and that may some or all of my troubles, any thoughts are appreciated.

xmlajax2DHT.ino (9.18 KB)

Also, I know I am using libraries in the posted code, that are unnecessary, it was experimental and should probably be removed.

SD library uses 500 bytes for memory cache.

put every constant string into F() macro

Thank you, I'll try that today and post if it solves my problems.

Thank you for the tip Juraj, using F() macro is a good function for conserving memory I didn't know about.

Researching it I found this, that explains it's functions pretty well:

Sadly, this did not solve all my problems.

Using F() and deleting the libraries from my code I was not using yet, now I don't get low memory warnings and I can establish the connection to web page from a browser.

My main issue now seems to be I have errors in how I am printing the temp and humidity variables.

I can load the page into a browser and see the 2 digital states and 4 analog values, though get no data loaded at all without commenting out the code sections for printing t/h variables, see revised sketch attached.

Lines 223-235 are what I need to debug.

Thanks for reading!

xmlajax2.2DHT.ino (9.22 KB)

don't use space in xml element names. you have . use or <float_h> and close the element with same name

Right on Juraj, I had a few issues besides that, including forgetting to update index.htm on the SD card a few times as I made changes to the variable names. :o

Now it is working, Thank you very much for your pointers!

I am attaching the working code and html (as .txt) for anyone who might benefit.

When I get the complete project finished, after I port it to the mega and add the other controls I'll post the project here.

index.txt (2.91 KB)

xmlajax2.2DHT.ino (9.23 KB)

you should set Content-length and use buffering for http responses. here is the WebServer and browser side script in my project. I use json responses.

Thanks Juraj!

I'll look into implementing your code into my project, it is advanced for me so I may have some questions when I get there.

I am hoping to finish the hardware part of my project by the end of next week, then getting back into parsing all the code into a final product.

I'll post more information on the project sometime next week.