Writing to arduino using python from windows machine

Hi, I want to write data in arduino from pc by using serial port and later I want to watch the output in serial monitor of arduino. I am using windows machine.

The code for pc python..

import serial import time

s = serial.Serial('COM10',9600) // opening the serial port time.sleep(2) // http://playground.arduino.cc/interfacing/python this link tell me to work in windows I have to add time.sleep s.write("hello")

The code for Arduino

void setup() { Serial.begin(9600); } char msg = ' '; void loop() { while(Serial.available()>0) // Reading data when available { msg=Serial.read(); //store in a variable Serial.println(msg); // print the data delay(1000); // add delay



My python code writing data to arduino.However I didn't watch any output in the serial monitor of arduino. The windows reset the arduino. http://playground.arduino.cc/interfacing/python this I came to know that Its working on linux machine. Besides this they advice to use sleep to work in windows. I have uses sleep. But its not working. If anybody know the solutions or any help please suggest.

You seem to be using the same serial port to read from your python program as you use to write to your monitor. You can't do that. Use software serial for one of the channels with the appropriate voltage converter.

Yes I am using the same port. I can't access the same port at the same time. I have to write first. Then I am checking in the arduino serial monitor for output.

Can you give a sample example that will suit my code to implement software serial.

Every time you open up a serial connection to the arduino the arduino resets so you can not switch.

Can you give a sample example that will suit my code to implement software serial.

What the code I asked you to post correctly and you ignored me?

So is there any way to implement that or I have to ignore and implement in Linux machine.


I expect this is probably doable on Windows using serial port emulator software, like this: http://sourceforge.net/projects/com0com/

You'd have to write a Python program that sits "in the middle" between the Arduino serial monitor, and the actual Arduino. Anything the Arduino sends to the Python program, it echos out to the serial monitor. Anything the python program wants to send, it sends directly to the Arduino.

Haven't done this on Windows myself.

I have done it on Linux, also using Python, using the Linux Pseudoterminal functionality (exposed in python using the pty module).