As you’ll soon see I’ve had a very good stab at coding this myself, where I need your help is in making it use less memory, any general suggestions on how I can make it “better” and crucially how to improve my own coding as well at the same time!
Currently it’s compiling at:
Sketch uses 24,224 bytes (75%) of program storage space. Maximum is 32,256 bytes.
And as you can imagine I’m getting rather concerned as I still have some further processing needed of the received GET data via the Ethernet connection and I’d really like to add an IR remote to this build as well (why not!)
What the device is to do:
It’s an UNO with an Ethernet shield at the front door of the house with a PIR, Lightsensor, DHT & RGB LED Strip (via a couple of transistors).
The device is POST’ing data every N seconds to a PHP script and also able to receive GET requests back to turn things on/off etc…
Specifically I’d really value your views on the follow:
#1 Is there anything glaring obvious that I could code better? If so, what and a hint on how to do that would be “Ace”
#2 In the ethernet connections there is a lot of hard-coded string data, could this be improved by setting these values via PROGMEM ?
#3 For the line “ethClient.println( F(“Host: 192.168.0.2”) );”, how would you approach making the server address “192.168.0.2” a variable? Noting it’s used twice, once here and further up at line 277
#4 When the project is finished, is there a simple way to remove/disable all the Serial.print messages? And does this even matter?
The project so far
I’ve posted the code on GitHub as it’s easier to read there, the link is here current code and posted it as an attachment below as well.
Any feedback, good, bad or outright ugly is very welcomed!
Front_Door.ino (11.8 KB)