Nanode (RF) webserver

68 views
Skip to first unread message

Bram Werbrouck

unread,
Dec 3, 2014, 3:39:16 AM12/3/14
to nanode...@googlegroups.com
Hi,

I want to make a small webserver with my Nanode RF.  This is the ID:

When you enter the (static) IP-address, you have a little website to control the outputs of the Nanode... 

I tried several examples I found on the internet, but always without any succes... Is there anyone who can help me??

Nicholas Humfrey

unread,
Dec 3, 2014, 3:55:12 AM12/3/14
to nanode...@googlegroups.com
Have you tried any of the examples here?

What is the problem you are experiencing?

Sent from my phone
--
You received this message because you are subscribed to the Google Groups "nanode-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nanode-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bram Werbrouck

unread,
Dec 3, 2014, 4:15:14 AM12/3/14
to nanode...@googlegroups.com
When I test the testDHCP sketch: I got the following in the serial monitor:


[testDHCP]
MAC: 74:69:69:2D:30:31
Setting up DHCP
My IP: 192.168.0.157
Netmask: 255.255.255.0
GW IP: 192.168.0.1
DNS IP: 195.130.130.133



When I test webClient:


[webClient]
IP:  192.168.0.157
GW:  192.168.0.1
DNS: 195.130.130.133
SRV: 74.125.230.248

<<< REQ >>>
HTTP/1.0 404 Not Found
Content-Type: text/html; charset=UTF-8
X-Content-Type-Options: nosniff
Date: Wed, 03 Dec 2014 09:08:53 GMT
Server: sffe
Content-Length: 1432
X-XSS-Protection: 1; mode=block
Alternate-Protocol: 80:quic,p=0.02

<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <me...


With dbbb_server:
**nothing

And when I go to 192.168.1.203 in my webbrowser:

Cannot open the page, the sever is unavailable ...


What am I doing wrong?



Op woensdag 3 december 2014 09:55:12 UTC+1 schreef Nicholas Humfrey:

Dick Middleton

unread,
Dec 3, 2014, 4:27:58 AM12/3/14
to nanode...@googlegroups.com
I've done this with a Nanode using the JeeLabs EtherCard library. I found
that memory was a severe limitation particularly if you want to use DHCP and
other protocols using udp. The 700 byte buffer is really a minimum and
leaves very little room for anything else. If you make it too small the first
symptom is the server doesn't respond consistently or even at all. The second
symptom the program crashes!

Although I did successfully create a working webserver I decided to use an
arduino with more resources. I'm currently using a Mega2560 with a 1200 byte
buffer. YMMV.

Dick

Dick Middleton

unread,
Dec 3, 2014, 4:36:09 AM12/3/14
to nanode...@googlegroups.com
On 12/03/14 09:15, Bram Werbrouck wrote:
> When I test the testDHCP sketch: I got the following in the serial monitor:

> <!DOCTYPE html>
> <html lang=en>
> <meta charset=utf-8>
> <me...
>

Content-Length: 1432

Classic memory limitation failure.

Try serving a very simple page e.g. 200 bytes.

Dick

Jon Bartlett

unread,
Dec 3, 2014, 4:14:54 PM12/3/14
to nanode...@googlegroups.com
or go the whole hog with a Raspberry pi - not much different in cost - but huge expansion potential !
--
You received this message because you are subscribed to the Google Groups "nanode-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nanode-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

Bram Werbrouck

unread,
Dec 4, 2014, 2:44:13 AM12/4/14
to nanode...@googlegroups.com
YES,

found the problem:

my computer was on the wireless network of my neighbor and the nanode on my own network..

This is the code I use:

 
#include <EtherCard.h>

#define STATIC 0  // set to 1 to disable DHCP (adjust myip/gwip values below)

#if STATIC
// ethernet interface ip address
static byte myip[] = { 192,168,1,200 };
// gateway ip address
static byte gwip[] = { 192,168,1,1 };
#endif

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

const char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
  "<head><title>"
    "TEST"
  "</title></head>"
  "<body>"
    "<h3>This is my first webpage on the Arduino RF!! </h3>"
  "</body>"
"</html>"
;

void setup(){
  Serial.begin(57600);
  Serial.println("\n[backSoon]");
  
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) 
    Serial.println( "Failed to access Ethernet controller");
#if STATIC
  ether.staticSetup(myip, gwip);
#else
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");
#endif

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);  
  ether.printIp("DNS: ", ether.dnsip);  
}

void loop(){
  // wait for an incoming TCP packet, but ignore its contents
  if (ether.packetLoop(ether.packetReceive())) {
    memcpy_P(ether.tcpOffset(), page, sizeof page);
    ether.httpServerReply(sizeof page - 1);
  }
}




With this getting started, I have 3 more questions:

1) When I change the 0 into a 1 in the following line :
#define STATIC 0  // set to 1 to disable DHCP (adjust myip/gwip values below) oterwise use 0
My browser doesn't find the webpage anymore???

2) How can I acces this little webpage through the internet and not only when I am home in my own network. I want to check/control my nanode when I am at work..

3) How can I use a build-in button to turn a LED on??

Thanks for helping me..
When I'm done, I post the whole sketch here

Dick Middleton

unread,
Dec 4, 2014, 3:49:55 AM12/4/14
to nanode...@googlegroups.com
On 12/04/14 07:44, Bram Werbrouck wrote:

> 2) How can I acces this little webpage through the internet and not only when
> I am home in my own network. I want to check/control my nanode when I am at work..

Either use a proxy forward from your existing home webserver. Nginx can do
this easily. Apache can do it as well.

Or, add port forward to your NAT table in your router.

You can also just use it as a resource accessed from a normal (home) web page
using ajax or such like i.e. not accessed directly.

> 3) How can I use a build-in button to turn a LED on??

Need to use POST requests.

Dick

Bram Werbrouck

unread,
Dec 5, 2014, 3:55:49 AM12/5/14
to nanode...@googlegroups.com, di...@lingbrae.com
So far So good :-)

I have seen that a 'website' for the Arduino takes a lot of memory.. Would it be possible to expand my NANODE RF with an SD Card Shield? Maybe I can store the pages on the SD card and de variables in the memory of the Nanode rf and combine them when the page is asked??


Any advice ??

Ken Boak

unread,
Dec 5, 2014, 4:09:44 AM12/5/14
to nanode...@googlegroups.com
Bram,

The Nanode RF already has a footprint on board to take a microSD card.  It also accepts a MCP79410 RTC chip and a 23K256 32K x 8 SRAM.

Ken

mikethebee

unread,
Dec 5, 2014, 4:15:42 AM12/5/14
to nanode...@googlegroups.com, di...@lingbrae.com
Well done on getting it working, I had a chuckle about the 'wrong network'. I did a wired webserver when I first built my nanode. More recently I have be using it to drive an LCD, monitor temp, and drive other hardware. 

You are right that a webserver demand more than the nanode was intended to provide, and running from an SD card is not ideal. I think the suggestion of using a rPi is a good one, but not to replace the nanode, rather to complement it. I use a rPi for tasks such as video, webserving, etc and the nanode or arduino when I need hardware connections. Linking them together via a network makes a great distributed computing solution, just what the IoT needs.

-Mike

BTW: over at TVRRUG a post highlighted an issue with FTDI that might affect Nanode users. Find the thread at https://groups.google.com/forum/?hl=en#!topic/tvreprapug/LQplQRyBSMQ


Bram Werbrouck

unread,
Dec 5, 2014, 4:19:56 AM12/5/14
to nanode...@googlegroups.com
this footprint, is this on the back of the NANODE?? (USD CARD) ?? 


Where can I find the right Micro SD card holder?? I already searched the net but I see always some kind of shield..

A little shield seems easier :-)
what do you think of this? http://parallax.com/product/32312



Ken Boak

unread,
Dec 5, 2014, 4:22:01 AM12/5/14
to nanode...@googlegroups.com
Mike, Bram

You might be interested in an updated product from Openenergymonitor.org

It provides a 433MHz "JeeNode" wireless link for the Pi - so that the Pi can be used as a gateway.

We have brought out most of the I/O pins from the ATmega328 - so that it can provide Arduino like I/O ports for the Pi  - which is otherwise somewhat restricted in the I/O department.

See my blog post for more information


Bram Werbrouck

unread,
Dec 5, 2014, 4:23:34 AM12/5/14
to nanode...@googlegroups.com
hhhmmm, what do you mean with "Pi" ???




Op vrijdag 5 december 2014 10:22:01 UTC+1 schreef monsonite:

Ken Boak

unread,
Dec 5, 2014, 4:28:22 AM12/5/14
to nanode...@googlegroups.com
Bram

Sorry, Pi is "Raspberry Pi"

SD connector is a Molex Part Part No 500873-0806




Dick Middleton

unread,
Dec 5, 2014, 4:30:27 AM12/5/14
to nanode...@googlegroups.com
Storing static data in ram on arduino is best avoided. You can store it in
various other places. PROGMEM is first possiblity - it's stored with the
program code which is 32K on the 328 cpu. Secondly you can use eeprom - there
is a little on the cpu but the nanode has an option of a 256K chip which you
may have. Thirdly you can add eeprom on a shield or other device. Some RTC
chips have eeprom you get to it using I2C which is very easy. Finally you can
use SD card. In my view it's overkill - you're not like to need GB of data
and if you do the arduino is probably the wrong platform.

The gotcha is that whatever non-ram storage you use the data has, at some
point, to be copied to ram and so you will need a buffer.

As I intimated in my last post, you are probably better not serving web pages
at all but just serve json data objects. Then run a more capable webserver on
another system somewhere. Usually this would be your home server but I've
used external servers for this, most interestingly Amazon S3. The dynamic
part of such websites can be implemented client side using javascript.
There's some super stuff out there for doing this. Wet your appetite by
looking at knockout.js (http://knockoutjs.com) for example (one amongst many
examples). There is a difficulty with the external server approach called
cross-site scripting - browsers are built to defend against this but there are
ways to avoid this with some browsers.

One other thing. You can use the RF capability of the Nanode to tx your data
to another system. It seems reliable, it's easy and it's nowhere near as
resource hungry as a webserver.

As always YMMV.

Dick

Bram Werbrouck

unread,
Dec 5, 2014, 5:29:49 AM12/5/14
to nanode...@googlegroups.com, di...@lingbrae.com
I've seen an awesome design..



That's what I'm looking for, they use a SD-card to store rhe CSS file and the graphics...





Op vrijdag 5 december 2014 10:30:27 UTC+1 schreef nottledim:

Bram Werbrouck

unread,
Dec 7, 2014, 11:29:58 AM12/7/14
to nanode...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages