Show Posts
Pages: [1]
1  Using Arduino / Sensors / Temperature Sensor (TMP36) and RFI on: November 18, 2012, 03:54:03 am
I've been using two TMP36's ( / recently with my Arduino Uno, works great. The Arduino is connected / powered over USB from my computer (some old Dell Optiplex running Fedora 17).

The sensors were directly connected to 5V from the arduino, ground, and the arduino's analog sensor. Nothing else in the circuit.

The TMP36's have worked without a problem for a few weeks, but after shifting some things around and cleaning up my wiring a bit, I've had some odd results. The TMP36's would suddenly output around .001 to .002 volts from the output pin. I keep my house pretty chilly, but definitely not in the -50 range!

What perplexed me the most was that the circuit checked out just fine time and time when disconnected from the arduino. On my breadboard I could attach a 5 volt supply and the output behaved as I expected. Simply replacing the breadboard 5V and ground with lines from the Arduino resulted in the unusual results.

I dug through the datasheet a bit and noticed a short section about RFI and these sensors. I attached a .1uF capacitor across the supply line and ground and the problem immediately ceased.

I'm curious if anyone has experienced similar problems and what was likely to have changed and caused my sensors to experience so much RFI or if there may be some other factor that the added capacitor would have helped with.
2  Topics / Home Automation and Networked Objects / Re: Rotating door automation on: November 12, 2012, 09:14:17 pm
No trouble at all, I love cool and practical projects like this!

Although your particular use may be niche, I could certainly envision someone doing something similar with blinds in a house that could be raised and lowered at the appropriate times to help block the sun. Who knows, it's always amazing the ways people adapt each other's ideas for their own projects.
3  Topics / Home Automation and Networked Objects / Re: Rotating door automation on: November 07, 2012, 03:43:29 pm
Sorry, I've been off the forums for a few days.

Let's see, two buttons, a potentiometer, and saving the settings...

You can make two local Long variables to store when a button is first pressed. The button would wait a certain period of time before entering the subroutine (which wouldn't actually need to be a function). Some boolean values could be used to control when settings are saved and when settings should be read from the stored values...

I've attached some code that verifies OK, but I haven't actually tested whatsoever. I think it would run pretty well though, although it would be great if others would give it a glance. The code doesn't have to block whatsoever waiting on the buttons to be held down long enough.

The pin value constants are all set to 0, so that would need to be changed. The EEPROM locations would also need to be set according to your needs (not sure if you're storing anything else). Also there is no software debounce for the buttons, hardware debounce would be preferable or adding a "readPin(int pin)" type of method that could handle a software debounce.

The code should allow for a button to be held for five seconds, the value of the potentiometer adjusting the value for the position, and then having that value saved to EEPROM when the button is pressed again. An LED will glow indicating that a position is being adjusted, and then turn off when the position is stored.

I've tried to comment a bunch to explain things, but feel free to correct or ask about it!

EDIT: It was really annoying downloading the attachment so I included the code in the post

#include <EEPROM.h>

//These variables store the positions for open and closed
int positionOpen;
int positionClosed;
//These variables store the locations in EEPROM where the saved positions are stored
const int positionOpenLocation = 0;
const int positionClosedLocation = 0;
//These constants just store the pin values
const int setOpenValuePin = 0;
const int setClosedValuePin = 0;
const int potPin = 0;
const int LEDPin = 0;
//These values are used to store a button press and to check and see if it's still pressed for the required time
long buttonOpenTime = 0;
long buttonClosedTime = 0;
//These booleans keep track of when a button has been pressed, time stored, and we haven't registerred a low yet
boolean buttonOpenPressed = false;
boolean buttonClosedPressed = false;
//These booleans control what parts of the loop execute, ensuring we're not setting both at the same time, etc
boolean settingOpen = false;
boolean settingClosed = false;
//How long you want to have to hold the buttons down, in ms
const long buttonHoldTime = 5000;

void setup(){

pinMode(LEDPin, OUTPUT);  
//Read the stored values from memory, allows values to persist after power failure or reset
//You only want these next two lines after the values have been saved at least once
//or else your sevo might go to some random location
positionOpen =;
positionClosed =;

void loop(){

//If you're not currently setting the closed value, and the setOpen value is at HIGH
if(!settingClosed && digitalRead(setOpenValuePin) == HIGH){
  //if this is the first read of a high set the buttonOpenPressed to true and record the time
    buttonOpenPressed = true;
    buttonOpenTime = millis();
    //if the button's been pressed and you've been held down longer than the buttonHoldTime, set settingOpen to true
  }else if(buttonOpenPressed && millis() - buttonOpenTime > buttonHoldTime){
    settingOpen = true;
    buttonOpenPressed = false;
    digitalWrite(LEDPin, HIGH);

//if you've previously registered a press, but you now read low
if(buttonOpenPressed && digitalRead(setOpenValuePin) == LOW) buttonOpenPressed = false;

//if you're setting the open value and you've pressed the button to save it
if(settingOpen && digitalRead(setOpenValuePin == HIGH)){
  digitalWrite(LEDPin, LOW);
  EEPROM.write(positionOpenLocation, positionOpen);
  settingOpen = false;

//if you're setting the open position
  //Read the potentiometer position and store it, dividing by 4 because of the EEPROM's storage size
  positionOpen = analogRead(potPin) / 4;

if(!settingOpen && digitalRead(setClosedValuePin) == HIGH){
  //if this is the first read of a high set the buttonClosedPressed to true and record the time
    buttonClosedPressed = true;
    buttonClosedTime = millis();
    //if the button's been pressed and you've been held down longer than the buttonHoldTime, set settingClosed to true
  }else if(buttonClosedPressed && millis() - buttonClosedTime > buttonHoldTime){
    settingClosed = true;
    buttonClosedPressed = false;
    digitalWrite(LEDPin, HIGH);

//if you've previously registered a press, but you now read low
if(buttonClosedPressed && digitalRead(setClosedValuePin) == LOW) buttonClosedPressed = false;

//if you're setting the closed value and you've pressed the button to save it
if(settingClosed && digitalRead(setClosedValuePin == HIGH)){
  digitalWrite(LEDPin, LOW);
  EEPROM.write(positionClosedLocation, positionClosed);
  settingClosed = false;

//if you're setting the closed position
  //Read the potentiometer position and store it, dividing by 4 because of the EEPROM's storage size
  positionClosed = analogRead(potPin) / 4;

4  Topics / Home Automation and Networked Objects / Re: Using android phone to control remote dimmer on: October 27, 2012, 06:58:07 pm
Two things,

Firstly, there are three different functions to write out serial data:

serial.print(), serial.println(), and serial.write() .

Looking at the reference for serial.print(), what actually happens is that the data is sent to the serial port in a human-readable format, but in the format specified by the second parameter.

So the number 65 sent with serial.print(65, HEX) would write 0x41 (65 in HEX) to the serial port, but using human readable characters. So in actuality, the binary values 0x34 and 0x31 would be sent (producing ASCII characters '4' and '1' on the serial monitor). This function is primarily intended to make monitoring and debugging easier, while not being what you need in your case.

So in your case, Serial.print(dimmerON,HEX) is actually writing the following bytes to the serial port:

You need to use the serial.write() that will actually write the binary value for 0x02ff400d to the serial port. You will probably want to use the method using an array of bytes.

Secondly, it will likely not be quite that simple. RS-232 has more to its protocol than simply writing serial data on the lines. I am not certain, but it does not appear that you are using any type of RS-232 driver chip. I've never implemented anything using RS-232, so I'm definitely not experienced in working with it.

There is an Arduino Software RS-232 tutorial:

There are also Arduino RS-232 shields available.

Either the software version with a driver chip, or the shield version are probably your best options. If you're working on an UNO, the shield will probably use the available serial port, so if you'll be reprogramming a lot it might be in your interest to look at the version using software serial.
5  Topics / Home Automation and Networked Objects / Re: Rotating door automation on: October 27, 2012, 05:26:16 pm

Is it possible to use a potentiometer to adjust a value BUT have the adjusted value saved even when the pot is removed?

That is certainly doable. You could have something as simple as a button (could even use one already on the project) that, when held down for a while, begins a subroutine that lets you use the pot to set the starting position, press button again to save value to EEPROM, set finish position with pot, press button again to save to EEPROM.

You can also have the subroutine change the appropriate pins to an input instead of an output, that way you wouldn't have a pin set as an input all the time and not really doing anything, although I doubt it would have any unintended results anyway.

Your code would simply load the start and finish values from the EEPROM on power up. Note the first time the device powers up the contents of the EEPROM could be random values, so be mindful of that.
6  Topics / Home Automation and Networked Objects / Re: Using android phone to control remote dimmer on: October 27, 2012, 03:16:03 am
i tried to directly wire up from arduino to RS-232 ( yea seriously). and I try to write a program.

i tested this program and i watched  the status from the serial monitor, it kept print the value 2FF000D repeatedly
while i send 1 to the monitor, it changed the value to 2FF400D but still repeatedly
and i tried to send another num to monitor, it stopped.

how come the value keep looping, how can i send  hex once only?

however i tried the above step after i connected between TX,RX and GND of arduino board and 232port 2,3,5 pin.
i sent 1 out , i could see the monitor that showed the hex of 2FF400D, but the remote dimmer didnt turn on.
what's the problem here?

Reference the serial.available() function: .

Serial.available() returns the number of data bytes available. In your code the statement

if (Serial.available () == 0)

means that every time there are 0 bytes available to read,

Serial.print ( dimmerOFF,HEX);

will be executed.

What you want to do is test for when Serial.available() > 0 and then read the byte from serial. You can then have an if statement, or switch statement to determine what should happen when a given byte is received.
7  Topics / Home Automation and Networked Objects / Re: Rotating door automation on: October 27, 2012, 03:02:53 am
This is a great project. Please post a video when finished!

Out of curiosity, are there any concerns as far as the chickens being in the way of the door when it is being closed? If so, do you have any plans for handling that?
8  Topics / Home Automation and Networked Objects / Re: Video Doorbell on Your iPhone/Android! on: October 27, 2012, 02:54:09 am
Thank you. But how do you make it work for video? Furthermore, is a video alert on the iPhone possible with a web based app? The project above is convulted in that you get a separate text message and email. I'm just looking for a simple live video feed of the door when someone presses your doorbell.
The e-mail is only a convenience, you wouldn't have to use is. The linked tutorial does not use text messages, it is actually pushing a notification to the phone. If a web service (like pushingBox) doesn't quite fill your video needs, you can certainly still make this work.

There's a number of ways in which you could implement this, from building an app ground up for iPhone and pushing your own notifications, to simply having a push service send you a link to a webpage with your web cam embedded.

The Arduino isn't going to be handling any kind of video stream, this would be done with another computer (or perhaps with a webcam that hooks right into your network? Do those exist?). The computer would need to run some type of video streaming service that would enable you to embed the video stream into a webpage. The linked tutorial seems to suggest that some webcams include software to make your webcam feed publicly accessible.

Everything else about the previously linked tutorial would work fine as far as using a push service and an Ethernet shield. A simple link in the notification to your web page with the video stream embedded would probably be sufficient for what you're wanting.

As far as whether you can have a "video alert" on an iPhone... my bet is no, as I haven't ever seen one. That's a result of Apple's implementation of their push notification standards. Implementing this idea as an Android widget might be a cool idea though...
9  Topics / Home Automation and Networked Objects / Re: Pushing a html page to a client device when a push button is pressed on: September 17, 2012, 04:50:59 am
Some more specifics would be helpful on this. It sounds as though this will not be a typical http server situation. As noted by Ricardo, html is not "pushed" to a client, html is requested from a server and delivered to the client.

Without knowing the specifics of the project, I would recommend reconsidering how you're thinking about this. The "pushbutton" is really the client, sending a request to the server to display something. The client can certainly send relevant information to the server to affect how the html file is created and thus displayed.

That being said, it wouldn't be bad to implement an auto-refresh solution to this as Ricardo describes. Depending on what you're doing, however, the lack of a real-time system could be irritating.
10  Using Arduino / Audio / Re: can't get basic midi sketch to work on: February 29, 2012, 08:10:11 pm
Thought I would update the thread since I'd replied earlier.

Currently I'm successfully both receiving and transmitting midi messages (Software Serial and hardware Serial).

I got some new parts in this week, and that seems to be doing to the trick. I built the circuit to the specs on the midi electrical specification schematic. For the output I used an inverter and an NPN transistor as the buffer, 1K resistor into the base. One thing that continued to throw me was that the midi spec shows pin values as they appear on a midi cable (male), not as they are on a 5-Pin DIN  jack (female). This makes a rather large difference.

For the midi input I used a 6N138 optocoupler. The input side of the 6N138 was exactly as specified on the midi spec. On the output side, I used a 220 ohm resistor into the V0 pin and a 1K resistor into the Vcc pin (both resistors getting 5V from the Arduino's power supply). The data receive line from the Arduino was connected at the same point as the 220 ohm resistor and the V0 pin's connection.

Everything seems to be working great now. Hope any of this might help.
11  Using Arduino / Audio / Re: can't get basic midi sketch to work on: February 22, 2012, 02:04:48 pm
^Yes, 31250, not 13250. I don't think the onboard Serial connection will work very well at 13250, haha.

Strange and frustrating indeed.
12  Using Arduino / Audio / Re: can't get basic midi sketch to work on: February 21, 2012, 03:57:58 pm
Wanted to add further to this discussion. I'm on a brand new Arduino Uno R3. Mac OS 10.5 for development. I'm new to working with the Arduino and new to Midi as well (at least from a hardware standpoint).

I also am unable to get the basic midi sketch to function. I've constructed the midi output exactly to spec with the electrical specifications (even going as far as including the buffer). At one point my midi device, a Motu 828mk3 Interface was receiving midi messages in sync with when I sent them, however the message information was nonsensical. I have been unable to repeat this result with the same setup and code.

Neither Software Serial nor onboard Serial output seems to work. I've tested with the Arduino Uno still connected via USB to the computer and disconnected with an external power source.

I'm getting a 6N138 in within a day or so to try and receive midi input to spec. Hopefully that may shed some more light if this is purely a serial output problem of if it's having trouble receiving at this rate as well.

Other things I've tested:

I've tested sending a byte from Software Serial at 13250 into the Arduino's built in serial port and this works fine (10 consecutive bytes received correctly, then output over hardware serial port to a computer). This worked correctly at 9600, 13250, and 14400.

I hooked things up to an oscilloscope today and the timing looks well within tolerance (every bit taking approx 32 microseconds) so this doesn't seem to be a timing issue. Everything is completely as expected, start bit etc.

I'm certain the midi input I'm using works and the software (Logic Pro) can monitor valid midi input.

Will post further updates as I try some more things.
Pages: [1]