Actually i am trying to do IoT based work.

Until now the sensed data(temperature and humidity) has been made available to only for one user on the Internet using Apache tomcat. So far we have just created a one way communication link between the sensor node and the Internet through the PC.

Now I need to control a device (say a fan) according to the variation with sensed temperature from anywhere through the internet. For the HTML I have used Java Script, which I am new to.

  • 3
    I'm voting to close this question as off-topic because you are asking a Java related question. At leat you should add an example about what you have tried to far.
    – rebatoma
    Commented Nov 17, 2016 at 7:07
  • 1
    Possible duplicate of Arduino Control over the internet
    – duck
    Commented Nov 17, 2016 at 7:11
  • @Mattia JavaScript is not Java... Commented Nov 17, 2016 at 21:26

4 Answers 4


Perhaps a message brokering service like MQTT is what you are looking for. Far too much to it to explain it all here, but basically it lets you publish messages and subscribe for messages, over a network.


If you are planning on keeping the Arduino connected to the PC then you are looking for help with your javascript, which isn't a question for this forum.

If you are looking at making the Arduino independent from the PC then you want to look at possible network options for the Arduino, ESP8266 shield, Mobile phone, C5100 (?).

Of course you might also want to look at using an ESP8266 rather than an Arduino and programming that through ArduinoIDE and using its web server rather than Apache. There are samples that would show you how to do this, you could get them without getting the hardware, but obviously they won't run.


How about this:


But i also would prefer MQTT, but this requires Network connection for Arduino


For the HTML i have used JAVA SCRIPT(but i am new to java)

You have to keep in mind Java is not the same as javascript.

I've once used my Raspberry Pi to communicate with my Arduino Uno. There is a library available to use on your RPi called PySerial, you can use Python on your Raspberry to listen to your Arduino output and store your values to a database for example. You can also use some Python scripts to send things over your serial connection to your Arduino, for example for your fan to start. You can build a web interface to read or view your data and to control your fan with Java or Javascript.

It may not be the most useful way to do it because you can use a Raspberry Pi as your main device but I've done it before and it is nice for learning purposes.

Good Luck!

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