aREST Ethernet Example trouble

I am trying to use the aREST library and included Ethernet example with my EtherMega or Mega/Ethernet shield, but am clearly doing something wrong. The library is at “GitHub - marcoschwartz/aREST: A RESTful environment for Arduino” and there seems to be a lot of positive activity with this library among other users, so this tells me it is regularly debugged. For the life of me though, I don’t really know how to invoke the commands I guess.

I cloned the library to my documents/arduino/library folder, and launch the example sketch therefrom and upload as is after setting my IP and MAC if need be. I forwarded port 80 in my home network GUI to 10.0.0.177 (Arduino’s static IP). I then open Firefox and type any of the following combinations into the browser only to have Firefox tell me the server cannot be found.

arduino.local/digital/34/0
localhost/digital/34/0
10.0.0.177/digital/34/0

I tried 2 variations of the example in that I already have my EtherMega in a project box connected to 8 channel relays, so to use the relays as LEDs, I coded for digitalWrite commands to be directed at digital pins 30-37. I tried this variation of the Ethernet example, but I also tried the example with no modifications except for MAC, IP. This barebones example, I also tried all 3 combinations of the above REST calls in the Firefox browser, all returned “server not found”.

Do I need to try a different browser, or are there files that need to be put on the micro SD card first like used in other server examples? I have my own site that was made in wordpress and it has it’s own API which I intend to one day plug my project into, but I understand that getting this REST library working in my LAN network will be a step in the right direction.

If anyone can advise what I’m doing wrong in this situation, and/or
any other insights that will help me finally bridge this gap between my project and my hosted website is appreciated in advance.

Are you certain 10.0.0.177 is within the localnet IP subnet range?

Can you ping the Arduino?

Is the PC on the same localnet as the Arduino?

Michael, I had a quick look over the library, which looks like it has many features and works with a range of hardware.

You don’t need port forwarding to test this from the LAN side of your network.
The MAC address, just leave it, as long as it is a unique MAC on your network.

Then check if your Mega is contactable, try to ping it from a network tool or command line.
If you get a return at that IP address, then try to enter a complete HTTP address in FireFox.

Do you get the console message from the Mega such as ‘server is at 10.0.0.177’ ?
If not, then the server code was not able to initialise or some other problem.

Then try the example and use the exact same pin, not your pin 34, just as first test.

While this library might suit your needs, have you looked at the Webduino library?
If you wish to operate your Mega as a HTTP server, then this library will do everything you need and in a clear and organised manner.

Edit: Tim already mentioned ping, I was slow in posting this I guess :slight_smile:


Paul

If memory serves, I used 177 in a past example sketch, as per some random tutorial instructable or what have you, but as my ISP is comcast and uses the 10.0.0.x scheme instead of 192.168......, I adjusted accordingly. But prior to this reply, I adjusted the sketch to 10.0.0.31 and uploaded, then made the new REST calls accordingly. I did notice that the failure is different now that I use the IPaddress in the call instead of arduino.local or localhost. The new failure says that ,.......... bear with me....

While attempting to recreate the failure message, the project worked all of a sudden. I found a link to substantiate my (memory) of using 177 as Comcast's subnet ranges are 255 for the first 3 blocks (octets?) and 3 different ranges for the remaining, but all were above 177. The previous fail message on my browser was that the server was taking too long. This at least told me there was a connection made, though very weak for an unknown reason.

While investigating the subnet class range of Comcast, I was in my LAN's GUI and in perusing the pages, I saw a button to ADD DEVICE WITH RESERVED IP. While in there, I added the particulars from my sketch (Mac, IP, name), and clicked 'save". The screen went white with a statement "the server is restarting" or language to that effect.

Now when I enter the various REST calls that can be used with relays, they work as expected. I'm not exactly sure why, but I did share all known variables and actions I've taken to hopefully add light to the situation for the next reader. I also wish to point out that the following 2 calls produce the same result;

10.0.0.177/mode/34/o // letter O 10.0.0.177/digital/34/0 // zero (I mistakenly wired my AC to NC)

Are changes to the site being made? I don't have any of the text editor features in the original message box, nor the reply box. The only options I have are Message Icon above and Attachments below. Site issues?

So, success then :)

No problems here with the Arduino forum site, for a change, if that is what you are wondering.

Is that right, that you have your ISP control your LAN side IP allocation, I've never heard of that if true ?

In the grand scheme, do you think using a Mega as a HTTP server will fit your project functionality ? I mean, I can imagine you will be wanting some fancy web pages with all sorts of dials and gauges and controls and then you will be wanting historical charts, right ? Check if using this library can provide the capacity to give you what you need eventually. If it does, great, but I sniff a fresh RPi coming :)


Paul

Thanks for the insights Paul, I actually just downloaded the Webduino from github and will begin testing immediately. The project that I am slowly in the process of learning how to construct will greatly expand over time. Of course I want a pretty web page, and have even secured my own domain name for the project. Because I am so new to coding and computer languages as a whole, it was refreshing to find that a service like WordPress makes web page design more like Microsoft Word, which I am very comfortable with. As this world is so new to me, and I know where my project needs to get to, I am researching everything involved, the networking aspect being of major importance as this wil potentially turn my cell phone into my project's LCD. With all that said, I am being lead to believe that it would be best if my website can serve the project best if being the server and the arduino as the client. The Arduino would have it's loop programmed for timed events or climatic event triggers, but supremacy commands can come in from the network to over ride the sketch. This of course assumes that I am ALWAYS the originator of those commands.

Any rate, thanks for helping me troubleshoot and thanks for the lead on Webduino!

rockwallaby: but I sniff a fresh RPi coming :)


Paul

a couple of weeks ago, I bought an Udoo which is an RPi/Due (3v3 Mega), but an ordering mistake led me to get the Udoo that doesn't have any kind of networking, so I gotta get an Alfa, or some other usb wifi dongle to to get it online. Because it is only 3.3v, I have it on the back burner till I know more about Arduino, but I was hoping to use it as the network hub. Will I be able to control 5v Arduinos with a 3.3v Udoo (RPi)?

Will I be able to control 5v Arduinos with a 3.3v Udoo (RPi)?

Yes, absolutely, and quite easily via the USB interface that both have.

Or, if you wish to use TTL levels, then for example, you might have an Arduino Mega and use Serial1 through Serial3 as 5 volt TTL. At the other end you might have a small GNU/Linux board also with a few UART ports, but at 3v3 level.

To connect these up, you need a bi-directional level converter, to allow the 5 volt data at one end to be exchanged with the 3v3 data levels at the other end.


Paul