Hello, my name is Aisha this is my first post and I am excited to get into the community.
I live in a studio apartment with my wife. The entire apartment is on a 15amp breaker so we have to be careful about power use.
We find if we run the A/C and cook something in the kitchen the fridge will kick on more often and trip our breaker.
We have a blower to pull hot air out of the kitchen and I would like to use an arduino to turn it off and on based on the temperature.
I have:
an arduino uno
a tmp36 temperature sensor
a 5v arduino relay module
a breadboard and leads
I have used the arduino to switch the relay using the blinking LED code from a kit I got. I have wired up the sensor and read readings off of it.
The tutorials I find online say I should connect it to 3.3v and also AREF to 3.3v when I do this I don't get 3.3v in my serial monitor like the tutorials say but 1.5 (average).
I am left lost as no tutorials show how to do this without an LCD screen and with a relay module. I don't need to monitor the temperature after I have it set properly once so an LCD is unnecessary (though I would not mind being able to add on in the future.)
I plan to put the sensor on a cable, are there limits to how long a cable can be for this sensor? I was planning on using cat5 cable.
So far all of my experiments with arduino involve copy pasting code and maybe modifying a couple lines that are clearly labeled or that a tutorial has told me to edit. I have 0% skills and about as much understanding and confidence in coding anything let alone a micro controller.
I have seen people adding things like data logging to increase accuracy of readings and delays to keep the switch from tripping like crazy but again I'm still struggling with the hardware and code is not at my level yet.
Hopefully there are people who can help me out. I know this is super easy for anyone who knows how to use and code arduino, I just need some help getting my first project finished.
When the AREF is connected to the 3.3V pin, you have to use a sketch that supports that. Because it can damage the Arduino when a normal sketch is used.
I suggest not to connect the AREF pin. The increase of accuracy is only little. You don't need it.
A long cable is no problem. There is a note in the datasheet to use a resistor for improved response time, but you can use it as it is.
Most of us start with a TMP36, but since it is an analog sensor and depends on the voltage, it is not very accurate. After that many of use use the DS18B20, a digital sensor without the voltage trouble.
We would like to see your sketch between code tags, and your wiring (a drawing on paper how you connected it, or a photo).
A TMP36 has three pins.
A supply pin, that needs to be connected to 3.3volt or 5volt. Not critical. 5volt is good.
An output pin, to connect to an analogue input.
And a ground pin (obvious).
An analogue read of the pin gives you numbers. They will hover around 154 if your room is ~25C.
Use the if statement in your code to switch the fridge relay.
e.g. if the value is more than 160, turn the frige off, and if the value is less than 150, turn the fridge on.
20C is a reading of ~143
25C is a reading of ~154
30C is a reading of ~164
So about two numbers difference per degree C.
No need to fiddle with the Aref, or turn that value into Fahrenheid or Celcius if you just want the fridge to turn on or off.
But you have to convert these numbers to F or C if you want to display it on an LCD.
Using 1.1volt Aref will just increase resolution by about 5 times.
Not needed in your case.
Leo..
Thanks for the info, this all helps a lot. As far as code goes I'm using a sketch from the adafruit website that just outputs data to a serial monitor.
I use a smart phone for programming so I will have to try to copy the sketch off that. But essentially I have no code. I am not capable of coding myself so I really need to find the code already done for me somewhere.
I have only made an led blink and changed it's speed and that was only editing one variable in someone els's code.
So I know how best to connect the sensor but now I'm still stumped on code. With no coding ability I'm not sure how to go about getting the sketch I need put together.
I was really hoping to find a project online that had everything coded for me but all of the tutorials I find leave out details or assume you know too much (for example changing the code to support a relay instead of a radio transmitter).
In the Adafruit sketch, "temperatureC" can be used to check the temperature.
if ( temperatureC > 25.0 )
digitalWrite( pinRelay, HIGH);
if ( temperatureC < 22.0 )
digitalWrite( pinRelay, LOW);
You have to know something about programming, or learn along the way.
It is almost impossible that a sketch on the internet would happen to be just what you want.
Is it possible to use a computer ? Using a smart phone to develop a sketch is very hard.
A reminder about safety. The relay module will probably have the connector soldered in. This will mean that the mains voltage will be available to touch. Please make sure the module is in a container that prevents any contact.
Hi,
IF you decide to use a DS18B20, see lots of how to info HERE:
You can connect multiple DS18B20's on the same Arduino pin. For example I have indoor and outdoor temperatures, swimming pool, pool solar heater Input and Output temperatures all on one Arduino pin. Some of those sensors are waterproof types as shown on the page above.
You can have actions based on temperatures on an Arduino running by itself, or also display temperatures on the Serial Monitor or LCD display. There is an example HERE:
All I did was change the digital pin 7 to the sens on my relay and bingo it works! The only issue I have is when I change the trigger temp it won't upload unless I try over and over until it works as a fluke (recompiling doesn't seem to help) or re paste the code, recompile and then upload and often that still gives errors.
The error I am getting is "Error: process returned not zero code: 1"
I have yet to get on my pc to try uploading using the official IDE, I use a smart phone as a programmer because I don't have room for my pc at my desk.
Here is my proof of concept on a breadboard (Right now I am lighting an LED using the relay, after working out my upload error I will move on to a small AC indicator light.
More progress, I have a full working proof of concept now. I also figured out it was my phone causing my upload issues.
Now all I need to do is put it in a case. I would prefer to not have to solder anything to the arduinop so I can use it in the future for another project, but I don't trust the leads I have to stay put. Any suggestions?
I figure a proto shield or something similar would be a good idea but I would prefer to use what I have on hand.
Regarding safety, I do not like the box or layout. Cardboard is not the preferred box for mains wiring.
It looks as though you are using a switchmode supply to power the Arduino. An open pcb supply is not safe as you have used it. All mains projects should be in proper electrically safe boxes and not using glue to hold in place.
To finish the project, get an enclosed power supply and use a proper box with parts bolted in place.
If anything goes sideways, it could easily catch the cardboard on fire, then the apartment, and then the building. As you have no location listed, I can only provide generic ideas and US sources. The local hardware store should have 4x4, 6x6, 8x8, 10x10, and 12x12 plastic junction boxes in the electrical section. These do cost some money, but are (a) readily available, (b) very very strudy, (c) rather large (12x12 for only $34 is actually cheap), and (d) nearly guaranteed to be rated for the voltages and power you are working with. Also check out All Electronics, Jameco, Electronic Goldmine and the like for other enclosures. These locations also have a variety of enclosed or sealed power supplies available.