Hello,
I'm using UNO with a sketch stored in memory. I want the sketch automatically run when UNO is provided with power (not necessary by connecting it to computer). Possible?
Thanks!
Eric
Hello,
I'm using UNO with a sketch stored in memory. I want the sketch automatically run when UNO is provided with power (not necessary by connecting it to computer). Possible?
Thanks!
Eric
It does that anyway, normally.
After being power ON, the TX light wont flash until I turn on the Serial Monitor....Or do you mean UNO records data even when TX does not flash?
Since I want to use UNO to record data on field (no computer available), this issue is sort of important...
Thanks,
Yang
TX is just serial transmission. We can't see your code so maybe it's not writing to serial until a device is connected. Thats not to say the UNO isn't running which was your question. Write in a function to flip a LED state as it runs, maybe that built in LED on pin 13. Then you can see for yourself the code is running if the LED is flashing.
pigdogcat:
After being power ON, the TX light wont flash until I turn on the Serial Monitor....Or do you mean UNO records data even when TX does not flash?
Since I want to use UNO to record data on field (no computer available), this issue is sort of important...Thanks,
Yang
where do you want to record data ? eeprom ? sdcard ? ..... ?
do you already record data on this device ?
As Danny told you, your sketch runs as soon as the arduino is powered on and, until you tell us more about your project and you post your code, we won't be able to help you .
pigdogcat:
After being power ON, the TX light wont flash until I turn on the Serial Monitor....Or do you mean UNO records data even when TX does not flash?
The Tx light will not flash (and no data will be put into the serial buffer on the Arduino) until it is connected to a Serial Monitor or a terminal program that connects listens to that COM port.
The serial data is still coming off the Tx pin, but the USB adapter chip is not storing it. You can prove this to yourself by attaching an LED and a resistor to the Tx pin (Pin 1).
+5V ---------|>|-----500 ohm resistor--------Tx pin
pigdogcat:
After being power ON, the TX light wont flash until I turn on the Serial Monitor....Or do you mean UNO records data even when TX does not flash?
Since I want to use UNO to record data on field (no computer available), this issue is sort of important...Thanks,
Yang
Ignore the Tx LED - it does not tell you whether your sketch is running, it only tells you whether there is data being sent over the USB.
If you want to prove to yourself that the Arduino runs the loaded sketch as soon as it is powered up, upload the blink sketch and observe that the LED on pin13 starts blinking as soon as it is powered up.
Load the blink example, provide power via a battery (with out connecting to the USB) and watch the LED flash.
Mark
You may be misunderstanding how serial works. The Uno will gladly transmit data to a host that isn't connected. If you write a sketch that prints data to the serial port, then plug the Uno in to power (but not a computer), it will still transmit that data over serial. There's just nothing to "catch" that data. It's like talking in an empty room, or a tree falling in a forest...
If you're thinking you should be able to power the Arduino from an external power supply, connect the USB cable later, and see all the data that was previously transmitted, well, no that won't happen. Any data sent before is lost.
Also, when you open the serial monitor in the IDE, it resets the Uno, so it may look like it only just started running, but in reality, it was running the whole time. Then when you opened the monitor, it reset and started running again.
The proper way to work around this depends on what you want to do. You can use a serial terminal program that doesn't send the reset if you just want to be able to peek at the serial stream from time to time. If you want to store all the output, even when it's not connected to a computer, you'll need to get an SD card shield and log to that instead.
But whether you're looking or not, the sketch is always running. Always. Waiting... watching you. (Creepy.)
You can use a serial terminal program that doesn't send the reset
It isn't the Serial Monitor that "sends a reset". It's a function of the USB establishing a connection through the USB to serial chip.
So if you fire up a perfectly normal teminal program that does not send anything until you enter it, the Arduino will still reset.
Looks like you want your Arduino UNO to log data and have no computer present. You can use SD cards to save data even when the Arduino is not connected to a computer. Alternatively, you can use TWO Arduinos, one of them present on site and the other one connected top your computer, use some RF or WiFi Module/Shield to send data from the Arduino on site to the Arduino connected to your Computer and then log the data on your.
dannix:
TX is just serial transmission. We can't see your code so maybe it's not writing to serial until a device is connected. Thats not to say the UNO isn't running which was your question. Write in a function to flip a LED state as it runs, maybe that built in LED on pin 13. Then you can see for yourself the code is running if the LED is flashing.
Thanks for this idea! I add a code line to flash PIN13 to test if the sketch is running. The PIN13 is flashing, but not the TX, which means the sketch is automatically running when UNO is powered ON no matter TX flashes or not.
Thanks for all,
Yang
lar3ry:
So if you fire up a perfectly normal teminal program that does not send anything until you enter it, the Arduino will still reset.
This is a function of the initial DTR state sent to the Arduino when the COM port is opened, which is controlled by the client. The Arduino IDE causes the reset when it opens the COM port but that's not fundamental behaviour of the COM port - it's possible to open the port in such a way that the Arduino doesn't get reset.
This is what I was implying -- not touching DTR (and thus generating the reset pulse). Although, I haven't tested myself to see if plugging in USB causes a reset in any way, so that could be true as well.