|
KenB
|
 |
« on: December 20, 2008, 03:12:13 PM » |
|
Guys, Just 2 hours after receiving my Arduino and ethernet shield, it has served its first webpage to a local port on my router. I had a spot of bother with the compilation, until I realised that I had to include all the files in the directory. It then compiled OK, but on programming totally locked up my laptop. The only solution was the off button and a hard reboot. This happened twice so I loaded the code onto my notebook and all worked perfectly. I'm reading the "temperature" from a thermistor connected to one of the analogue input ports. The example code given is to read a Dallas 1wire sensor - but I hacked it to get a crude reading from the thermistor I am now embarking on my uphill conquest of the C programming language / Everest.  Ken
|
|
|
|
Logged
|
|
|
|
|
Paulh_Boats
|
 |
« Reply #1 on: December 20, 2008, 04:33:16 PM » |
|
Ken,
Good stuff... any chance you could post the code for us all to see?
-Paul
|
|
|
|
|
Logged
|
|
|
|
|
KenB
|
 |
« Reply #2 on: December 20, 2008, 04:56:02 PM » |
|
Paul, I'm having some basic compilation problems. Whilst I've managed to get the nuelectronic example web server/client sketches to work OK, I'm struggling to get any of the ones from Pachube to compile. The Pachube examples use stdio.h which you can find buried in the basement of the Arduino 0012 folder ( in a locked filing cabinet with the "Beware of the Leopard" sign) but having found this, added it to the project and compiled it gives me a whole load of meaningless compile errors when it tries to build it. It's somewhat frustrating that these people share their code but in such a way that its not obvious what all the necessary files are to make it compile without errors - I guess real programmers are telepathic or something. I cannot find a way of getting the Arduino build environment to automatically link in all the necessary files - so for the moment I'm stuck  I suppose I'll resort to blinking a LED or printing "sodding C".  Time to get hold of the Pachube guys and get a step by step guide to how to build the damm thing. Ken
|
|
|
|
|
Logged
|
|
|
|
|
Paulh_Boats
|
 |
« Reply #3 on: December 20, 2008, 05:31:57 PM » |
|
Ken
stdio.h contains all the print() commands and similar input/output functions.
I have downloaded the 0012 compiler from Arduino.cc and added stdio.h to the blink example:
#include <stdio.h>
int ledPin = 13; // LED connected to digital pin 13
void setup() // run once, when the sketch starts { pinMode(ledPin, OUTPUT); // sets the digital pin as output } .......
It compiled ok so I think your installation maybe wrong.
Where are the Pachube examples?
-Paul
|
|
|
|
|
Logged
|
|
|
|
|
|
|
KenB
|
 |
« Reply #5 on: December 20, 2008, 08:51:17 PM » |
|
Paul,
I commented out the #include stdio.h in the ethernet.h file and it now compiles OK.
Clearly stdio.h was not used in this example.
I now need to work out exactly how the Pachube site polls my server.
Ken
|
|
|
|
|
Logged
|
|
|
|
|
Paulh_Boats
|
 |
« Reply #6 on: December 20, 2008, 09:30:27 PM » |
|
I commented out the #include stdio.h in the ethernet.h file and it now compiles OK.
Clearly stdio.h was not used in this example.
I now need to work out exactly how the Pachube site polls my server.
I was going to suggest removing the #include stdio.h line. Your server waits in a loop for a client connection.... when the connection is made it sends a packet of data to the client and the connection ends. Then the server loops until it sees another client connection...and sends the packet again. So it serves data on demand in the same way we ask www.navitron.org.uk/forum for the latest webpage. A key fact is that in Arduino C loop() repeats forever, until the power is removed: void loop() { // Try to get a client Client client = server.available(); // Is there a client? if (client) { // Yes - client has made a http request ..... // send data to client client.println("Hello client"); // end the connection client.stop(); } // Loop back and look for another client } The above code is using the official Arduino Ethernet library, the Nuelectronic code is more complex but works in a similar way. -Paul
|
|
|
|
« Last Edit: December 20, 2008, 09:41:22 PM by Paulh_Boats »
|
Logged
|
|
|
|
|
KenB
|
 |
« Reply #7 on: December 20, 2008, 11:54:41 PM » |
|
Paul, Thanks for the explanation. I now need to try and reconfigure my router so that the Arduino can be seen by the outside world. I managed that for the PIC webserver - just have to remember how I did it.  Ken
|
|
|
|
|
Logged
|
|
|
|
|
KenB
|
 |
« Reply #8 on: December 21, 2008, 12:52:07 AM » |
|
Paul, Ben, List, By special request - for 1 night only The Freeduino webserver serves its "temperature" to this external IP address. Click the button to get an update. http://91.111.107.146/In this case the "temperature" is the output of the thermistor ADC channel (0 - 1023) divided by 10 Ken
|
|
|
|
« Last Edit: December 21, 2008, 12:53:45 AM by KenB »
|
Logged
|
|
|
|
|
Paulh_Boats
|
 |
« Reply #9 on: December 21, 2008, 01:38:10 AM » |
|
Ken, Clicking the link you provided works and F5 reloads the page in half a second, but the Get Temperature button loads this page with the cmd parameter: http://192.168.1.101/?cmd=1.....which is your internal IP address that times out after a minute. A quick edit of the code will fix that. Anyways its a good step forward. cheers Paul
|
|
|
|
« Last Edit: December 21, 2008, 01:58:17 AM by Paulh_Boats »
|
Logged
|
|
|
|
|
RichardKB
|
 |
« Reply #10 on: December 21, 2008, 01:52:14 AM » |
|
The link 91.111.107.146 is kens WAN ip which works OK but when you hit get temperature from a web side client you are trying to connect to an internal ip address 192.168.xxx.xxx which I assume is the ip address of the machine on Kens local network I can see the ip address but do not want to list it on a public forum.
Rich
|
|
|
|
« Last Edit: December 21, 2008, 02:22:09 AM by RichardKB »
|
Logged
|
|
|
|
|
wyleu
Guest
|
 |
« Reply #11 on: December 21, 2008, 07:33:41 AM » |
|
Anyone got a IP to 22mm compression fitting ? D
|
|
|
|
|
Logged
|
|
|
|
|
KenB
|
 |
« Reply #12 on: December 21, 2008, 10:54:45 AM » |
|
Paul, Richard,
Thanks for pointing that out - it was after midnight when I was modifying the code.
I have now contacted the Pachube Community for assistance in getting it to work with Pachube.
In theory the Pachube client sends a request to the Arduino server every 5 seconds and it serves its sensor data as a series of comma separated variables or as an XML script.
Pachube then strips out the data (or the XML tags and data) and makes these available to its graphing an logging software.
I've checked that the external internet can now see the Arduino (at least until the router is allocated a new IP address).
One step at a time!
Ken
|
|
|
|
|
Logged
|
|
|
|
|
cornishben
|
 |
« Reply #13 on: December 21, 2008, 11:37:29 AM » |
|
at this rate ken you'll have finished my msc project before i've even got my arduino ;-)
|
|
|
|
|
Logged
|
|
|
|
|
KenB
|
 |
« Reply #14 on: December 21, 2008, 11:48:15 AM » |
|
Ben, I wouldn't be so sure  I'm just trying to gain an understanding of the basics and get something simple to work. I'm still struggling with the Pachube connection, I can't think of anyway to test it, because when you make a request to the Arduino server, there's no simple way to see what it's sending - I suppose I could print something to the serial port to say that there had been an incoming request for data? Ken
|
|
|
|
|
Logged
|
|
|
|
|