How to query a website from Arduino - arduino

I'm building a website, and I want my Arduino Uno (that is hooked up by USB to my local machine) to execute every time a certain page is reached on the site. (For example, blink the light when somebody signs up for our service.) I don't have an Ethernet shield. Is there an alternative?
The only thing that I've come up with is to repeatedly download a log file from the website to my local machine, and run a loop querying the contents of that log file on my Arduino, but the constant requests will put too much stress on the server. Is there any easier way to do this?

When the page is requested on the server, you can run a program that signals your local machine that is controlling the Arduino. Implemenaation depends on what Web Server you are running and if the content is static or not. But even if it just a simple static html page, that page can include a request to this service much like a html page includes requests for included images.
Your local machine will need a static IP address. If the local machine is on a different network behind a generic router, you may need to do port forwarding to the static address.

Eventually figured it out, with help from here:
http://labs.arduino.cc/NET/GettingStarted
You need to use Processing to ping the website, and send the acquired data through the serial port to the Arduino. Since both are using the same port, make sure to load the code over to the Arduino first before you start running the processing code.

Related

Connect ESP32/ESP8266 to domain website to control LED's

I was wondering if there is any way to connect the ESP32/ESP8266 to my domain in Hostgator, I have a website which has buttons to control LED's or other stuff connected to the ESP, but I was searching to see if it is possible to connect the ESP to my website, I can only see videos and documentation of the ESP creating it's on WebServer, Is there any way to connect it to my domain Website?
If your web site uses HTTPS you can find a useful example in the ESP8266 Arduino code. See the HTTPSRequest example .ino file.
First you have to set your ESP has an access Point, you can see how to it here https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/soft-access-point-class.html
Then in your website you need to make a POST request to your ESP IP. Considering you're not using any type of Back-End you do not need to connect your ESP to the Website but the other way around. Hope this gave you a little help
Making HTTP request from ESP8266 board is very simple and straight-forward process.
You can look at the WebClient example that is installed with the ESP8266 library.
Then - after you craft the URL you're querying and you know the format of the answer you get - you just test for it to decide what to do with your LEDs.
Please let know if there is a need for more clarifications or code sample.

Application Level Network Sniffer

Is there a better tool than WireShark to sniff out where given application is trying to connect and at which port. (So that I could easily overwrite it with my HOSTS file). Being able to log packet data is helpful too.
Ultimately I would prefer an application that I could just throw a running process at and start logging the network activities of the given app
Of course the application and sniffer will be running on the same PC. Preferably I would love a Windows sniffer. Since running that app on Linux will be .... difficult.
Answering myself: http://www.sysprobs.com/monitor-network-traffic-windows-7-microsoft-network-monitor-34
This article helped me big time. The tool in there is really great.
Have you tried socket sniff?
It should let you monitor specific applications:
socket sniff

Networking. Making a program available through the internet

I want to create a program in which a user enters data and saves it on a text file. For example they enter a name and their age and it saves it and loads it. The thing is that i want this program to be available to the user at all times on any computer which means having the program online.
Do i need to make the program have networking capabilities? Or can i just have a server or host computer to hold the program and have the client access that directly?(like using the spreadsheets from google).
I don't know what you mean by "do I need to make the program have networking capabilities". If you choose to avoid the web site route then you need to have a server and client side app. If you want the program to be able to save data to a server then you need to do some socket programming.
To create a server, you need to:
create a socket
bind the socket to an address and port
listen for incoming connections
wait for clients
accept a client
send and receive data
To create a client, you need to:
create a socket
connect to a server
send and receive data
Hope this helps!
There are may ways to accomplish your goal, but the route that is probably easiest and most useful is to create a web page that implements this functionality.
Some of the many benefits include
No special software to install. Just requires a web browser.
Runs on any platform (including mobile) that has a web browser.
No software updates to push out to users. Update your website, and everyone gets the latest code.

access serial port through internet which is connected to a remote machine

I have a sensor gateway which is connected to the serial port. My java program basically a desktop application which is collecting sensor data and storing in a public mysql database. Now I am wanting to access the serial port through internet with a web application which is using the same public mysql database. I have think a bit but I think it is not a proper way. If I would keep a table in the database, if any command is generated through internet via the web application this table store the command for a period of time and my desktop application continuous monitoring the table if data available get the data and pass it through serial port. I am seeking for a proper way to access serial port through internet/cloud which is connected to remote machine or something like an expert opinion.
That's certainly the simplest method. Much simpler than say a web service that stores it in memory, or again in the database and you get safety which you wouldn't get if you just relied on the file system to lock a file. You might need some method of clearing out the output from the DB.

Querying Current Wifi Network SSID for Network Profiles script

I've got a script that programmatically applies different proxy settings for different wifi networks, but I'd like to make it automatic; when a certain wifi network is logged into, my script is called with the network name.
Any ideas?
Assuming you are on a linux if-up/if-down hooks is what you need.
Look at /etc/network/if-up.d and /etc/network/if-down.d .
The interfaces(5) manual page whould help in general.

Resources