I want to make simple client-server program where arduino behave as a client. For example I have a LED connected in arduino board that is controlled by a switch. With the switch I can turn off and on the LED. Now I want to send the status of that LED to another computer wirelessly (let's say within the Local network). That computer will act as a server and update the change as soon as the LED changes its status. I am not expecting any complete code, I just want to know how could it be done in general? May be some links can help me? Because this is my first time working with client-server in arduino sketch, I need some kind of guidelines. Thank you.

  • There are example client-server sketches included in the IDE. Did you look at those?
    – Nick Gammon
    Commented Oct 29, 2015 at 6:53
  • When you say "Local Network" - do you mean over Wifi ?
    – Kingsley
    Commented Jan 29, 2016 at 0:12

2 Answers 2


A simple HC-05 module will give you a wireless bluetooth connection. They're fairly simple to setup, and you can write data to them the same as one would the Arduino serial console. Obviously they can read data too.

SoftwareSerial bt_serial(2, 3); // RX | TX


if (led_state != last_led_state)
    if (led_state == HIGH)
    last_led_state = led_state;

On the "server" side, a simple program reading the mapped bluetooth serial port would do the job. For example, some python code:

import serial
import sys

serial_port = serial.Serial(port='COM8:', baudrate=9600, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE)

    print("Failed to open port")

while (True):
        led_state = serial_port.read()
        if (led_state != 0):
            print("LED is on")
            print("LED is off")

serial_port.close()   # yes, it never gets here    

Even though I like Kingsley's answer I thought I'd add to this using Wi-Fi becuase you had mentioned LAN.

These two links should be enough to help you: WifiChatServer and C# Telnet Library

Those links can sort of be dissected to fit your needs, but if you need some actual code just tell me.

Now I am aware that the Arduino is acting as a server and the computer acts as a client, but I believe this setup is better because it's easier to manipulate connecting to servers on the computer rather than on the arduino side.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.