Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PC to PC communication

Status
Not open for further replies.

Parth86

Member
Hello

If there are two computers, In which one computer sending the command to the another computer via internet to control any device

computer A---------->internet -----computer B-- microcontroller --relay-device

Q1 If I want to send the command from computer A to computer B, what I have to do ? how to send data from A to B?
Q2. How does computer B decode the command and send to micro controller ?
 
Q1 addition: Also learn how LAN and Internet works to see who can communicate with whom.
 
Networks are not easy to understand as you have 7 layers of abstraction. The bottom one is the hardware, the top one is the software you use. In between is a whole world of protocols, most of which you don't need to know about unless you're a network specialist. https://en.wikipedia.org/wiki/OSI_model
It's not clear from your 2 posts whether the microcontroller is connected to a computer, which is connected to the internet, or whether the microcontroller itself has an internet connection.
In the first case, you don't really need to know more than how the micro is communicating with computer B. In the second case, all you really need is a network card (or "shield") that your microcontroller can plug into and the relevant software libraries.

(edit)
So, you are talking about sending arbitrary commands to a piece of hardware? You can use Secure Shell, or you can use Telnet (which is simple but an invitation to hackers (by which I really mean the black-hats) ). These programs send the characters you type, over the internet (or intranet, or a serial cable) to the device you specify.
So you need to know the ip address of the receiving device, and that's where you tell the program to connect to.
 
Last edited:
It's not clear from your 2 posts whether the microcontroller is connected to a computer, which is connected to the internet, or whether the microcontroller itself has an internet connection.
.
.
computer A connected to internet -- --computer B connected to internet -- microcontroller --relay-device
 
The communication is a simple serial connection... The protocol isn't as simple.. However! Virtually any software you use will allow control... If you create a web page that accepts data input, you can then use that data to control a pic.

A simple button on a web page....
Some user presses that button in another country!
Your computer receives an acknowledgement of said button press!
Your web application can then serially ( via USB ) turn on an LED connected to the pic!

If you look through MBED youtube video's...

If you watch any "Internet of things" you'll find it very easy todo..
 
I've yet to digest what's here: https://aws.amazon.com (Amazon Web Services).

There's a lot of difficulty because "people" don't have clear access to the Internet. It's very difficult for a device at home to send an email or SMS somewhere.
Now it would be possible to say connect to a serial device at your friend's house from home, but the friend would have to have set up Dynamic DNS for his network, so you can reach it. The ISP keeps changing your public IP adddress. Dynamic DNS keeps changing the host name to match what your ISP assigned you.
Your friend also has to open PORT to the outside world as well.

Similarly there is an HVAC company that allows you to control your house thermostat via the Web. This works because the home device talks to the company's server and relays info there. You connect via your web browser to the company's server as well. Your authentication allows you and your HVAC equipment dealer to access your home system.

Edit: changed service provider to HVAC equipment dealer
 
Last edited:
let's take your diagram:

computer A---------->internet -----computer B-- microcontroller --relay-device

and modify it a bit:

Computer A (IP:MAC) (port)----Router- (Public IP)--ISP----->Internet - ISP(public IP)- Router (NAT)--(Private IP)-Microcontroller(IP:MAC) B (PORT)- --relay-device

Internet DNS maps host names to IP addresses. eg. school.edu to x.y.x.c or your DYNDNS address of say yourHome.dyndns.org to your ISP's public IP address.

Now, I added a bunch of "stuff". Each device on the Internet has a MAC address and an IP address. Certain addresses are reserved as public and private (10.?.?.?) and 192.168.?.?) and 172.16.?.?) The private addresses are not routeable to the Internet. they are local only.

NAT is known as Network address translation. It basically takes a device on your network and modifies the packet as coming from the MAC address of your router, Incoming ports generally have to be "opened". The router modifies the packets back through NAT or something like that.

TCP/IP is generally a lossless protocol. Not all of the packets have to travel the same route. UDP is a point to pint protocol. UDP is good for audio/video.
the port #; 1 to some maximum. Ports under 1000 are known as privileged ports. Http:// is port 80. Http: is known as a service and it has a "default port number".

My modified version is a little messy. it's not well thought out. But it's close.
 
first thank you for helping me , I think hardware interfacing is more important. I think I have to buy ethernet module. Ethernet module will communicate with the microcontroller
I did some google search, but still confused
how does microcontroller communicate with computer via internet ?
Is it possible to connect microcontroller directly to internet (without ethernet module?
 
At the microcontroller location, you will need a device connected to the Internet. That device then communicates to the micro. Whether that interface is serial, bus or Ethernet determines whether or not you need an Ethernet shield. That device could be an Ethernet shield and then, with proper programming, a separate computer is not necessary. This would look like, in the following hybrid sketch. Computer A --- Internet --- Microcontroller with Ethernet module.

Somewhere in the remote site must be Ethernet capability. If it's another computer, the following hybrid sketch would look like Computer A --- Internet --- Computer B --- USB --- Microcontroller with USB interface.

I called them hybrid sketches because they include different layers in the OSI Model.
 
vead,
There was a series of articles in the November and December 2009 and January 2010 issues of the Australian magazine "Silicon Chip" that describes one method to do what you are asking about. The title of the article was "Web server in a box" This is worth reading if you can find a way to get the articles.

Les,
 
Computer A --- Internet --- Computer B --- USB --- Microcontroller with USB interface.
If you will look first post , I was searching like following sketch, because it save the cost of ethernet module but question is that, will it work ?
Computer A --- Internet --- Computer B --- USB --- Microcontroller with USB interface.
computer A should be send data to computer B via internet then computer B receive data and send data to microcontroller via usb port to control device using relay
 
Sorry I missed that point. It will work, but you will need to write a program for computer B to perform the relay function. As well as a program for computer A and the microcontroller
 
Sorry I missed that point. It will work, but you will need to write a program for computer B to perform the relay function. As well as a program for computer A and the microcontroller


I think I have to create web page, there should be button on page, that should be control target via net
one PC send the data via internet , and another PC will receive data and send to microcontroller via usb

anyone can tell me what I have to learn to complete task ? I mean how to complete task step by step , how to create Program ?
 
Last edited by a moderator:
I think I have to create web page, there should be button on page, that should be control target via net
one PC send the data via internet , and another PC will receive data and send to microcontroller via usb

anyone can tell me what I have to learn to complete task ? I mean how to complete task step by step , how to create Program ?

That sounds pretty simple. Set up a web server (like Apache) on the machine near the thing you want to control, and write a CGI (common gateway interface) script to echo a string to a serial port (I'd recommend RS232 serial as being the easiest way to talk to a microcontroller). Depends a little bit on what systems your computer is running - in Linux it should be straight-forward, on Windows I don't know... Of course if also depends on what microcontroller you're using, but most should have a UART that's easy to set up.

There are lots of ways of doing this though. Maybe you could suggest the computers/operating systems/software/micros that you would like to use and we can narrow down the options?
 
If you don't already know how to code, you're a ways away from getting this to work. If you want a web page you'll have to learn how to configure it, code in HTML, php, pearl or some other web language. And make the page available publicly, with either a static address or more likely dynamic DNS. Then on the PC, you will need to select a language to code the relay program, such as VB, C or C++. Same for the microprocessor; select ASM, C or whatever language is supported. Depending on your system architecture, computer A may only need a browser. And depending on what you use to program your web page, your relay function may be embedded in the web page.
 
Take a look here: **broken link removed** too. Again, a webpage to bits. This may not be what your after.

When you say "How", it might be instructive to go back to the early days of computing. There were multiple different operating systems with the only thing compatable was the serial port. So, the Kermit protocol was developed to transfer files between these different OS's.

It was packet based and error correcting.

Modbus https://en.wikipedia.org/wiki/Modbus is another protocol of a master/slave nature. See **broken link removed** This basically allows you to set bits "coils" or "relay coils" across a RS485 serial network. Modbus has migrated to TCP/IP.
 
Status
Not open for further replies.

Latest threads

Back
Top