Pretty simple right? We can grab this example code and replace line 41 with whatever data we would like to sent back to the connecting party. If a connection is detected and a connection actually exists ( line 23 and line 30), data will be sent to the connecting party ( line 41) and the connection will be closed ( line 61). If you look at the code of the “Hello World!” example that we used for “ UIPEthernet” (see this “ How to web-enable your Arduino“), then you’ll see in the loop that it’s basically waiting for a connection to be made ( line 23). In the end it’s all text and if you decide to use your home brew application to retrieve the data, then it’s totally up to you what and how you do this. There is however nothing wrong with using CSV (Comma Separated Values), HTML, or your own home brew data structure. Please note that you can format the output anyway you prefer, but for convenience I decided to use XML as a format. Instead I used a web-browser for testing purposes. In essence we are going to grab the data from the Arduino in the shape of a “webpage”. This is the one I started with, since I didn’t need an application that would ask the Arduino for data. In this article we will focus on PULLING DATA to our computer. – Push: The Arduino will connect to a server application to push the data to. – Pull: An application on our computer (or server) that is going to ask the Arduino for the data. We have two options to get our Arduino data, and the best option depends on your purpose: For simplicity we will take a computer connected to the network and our Arduino connected to that same network. ![]() In this example, I’ll take the temperature sensor of my DS18B20 article and I’d like to be able to read the temperature data from my computer, phone or tablet, over a network connection.
0 Comments
Leave a Reply. |