Ethernet module

All about Arduino, Jeenode and other Clones (hardware & Software)

Moderator: Mdamen

phoenixb
Advanced Member
Advanced Member
Posts: 512
Joined: Thu Jul 23, 2009 1:00 pm
Location: Netherlands

Ethernet module

Post by phoenixb »

Hi,

I'm at this moment try to get the Jeenode working with a 1-wire sensor, now i getting some date from this sensor and can read it by using the serial logger in the programm software.
But i want to put this date in a mysql db and want to read it by using a php script (not by using HS) to see the history data of this sensor in a graph.

But i can nor find any demo skech in combination with a server side demo where i can see how it work.
Is here some one that have a demo script for my for this part of jeenode in combination with a ethernet module.
I like to hear it.
Grtz,
__________________
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Ethernet module

Post by Digit »

Hi Dieuwert,

As I understand the JeeNode is connected to Ethernet?
Did you use the JeeLabs Ethercard and did you already succeed in assigning this JeeNode an IP address or not?
That's the first step. There are plenty of examples for that @ Jeelabs. Have a look at some recent weblog posts and you'll find what you need.

Next question... do you want the JeeNode to push the temperature data or are you going to periodically ask (pull) the JeeNode for the temperature?
phoenixb
Advanced Member
Advanced Member
Posts: 512
Joined: Thu Jul 23, 2009 1:00 pm
Location: Netherlands

Re: Ethernet module

Post by phoenixb »

Hi Robert,

At this moment i have sucessfull connect the jeenode/ethernet card to my home network.
And can display the jeenode sensor data to the webpage that is generate on the ethernet module.

And now i want to puss the date to a mysql db and generate from this mysql db a graph.
Now is for this part my issue, i have look on the internet for a way to do this but can not find some good info what i can use as example.
So i hope that some knows a good example that i can use for it.
Gr,
__________________
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Ethernet module

Post by Digit »

Ok, so you have a tiny webserver running on the Jeenode and you can pull the data from it. Cool, isn't it?
Well, it looks like you're almost finished then :)

All you have to do is change the sketch so it will start pushing the data by POSTing it to a webpage; check the latest EtherCard library, it has a function specifically made for HTTP POSTing (at least, I think I saw one scrolling over my screen yesterday). Since you're talking about using PHP I assume you are familiar with it and that you can create and serve a PHP webpage for this.

And regarding PHP and MySQL: well, the web is literally flooded with examples of how to use the combination of both :)

If you don't succeed in changing the sketch I'd say: have some patience (a week?) cause I'm going to create something similar very soon: a JeeNode with EtherCard that uploads data to my Domotica system; the only difference with what you need is that I'll be using XMLRPC, which is what you will not need but that can be changed very easily.
User avatar
Rene
Global Moderator
Global Moderator
Posts: 1689
Joined: Wed Oct 08, 2008 3:54 pm
Location: Netherlands

Re: Ethernet module

Post by Rene »

Robert,

Did you consider using JSONRPC instead of XMLRPC? Have a look at interactive-matter.eu/2010/08/ajson-han ... h-arduino/
Rene.
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Ethernet module

Post by Digit »

I have read about it several times. I am using XMLRPC for quite some time in my system now and it works very reliable in combination with ASP/VB.Net, Delphi and ProntoScript. As long as there's no need to switch, I'm not going to. Besides that, the XMLRPC implementation on the JeeNode will not be more than just a specially crafted HTTP call to keep overhead to a minimum - I don't plan to write a fully featured XMLRPC interface for it :)
But thanks for the tip!
phoenixb
Advanced Member
Advanced Member
Posts: 512
Joined: Thu Jul 23, 2009 1:00 pm
Location: Netherlands

Re: Ethernet module

Post by phoenixb »

a little update/question about the ethernet card.

At this moment i have the next setup:
USB-BUB -> JeenodeSMD (And have try the V3) -> Bridge Board (And try the Carrier Board)-> EtherCard (try 2 card).
I get no error when i uploading the sketch lige TestDHCP or another one and one 1 LED is turn on and 1 LED is blinking (network activity) but i
Can not connect to the ethercard.

Did i mis something?
I like to hear it.
Grtz,
__________________
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Ethernet module

Post by Digit »

Yes you did :)

I assume you watched the Serial Monitor to see if all went well in the setup()?

What you're missing is that the connect you're trying to do is not handled; the testDHCP sketch loop() is empty!
So what does your JeeNode do after getting an IP address? Nothing...

AFAIK the loop() has to contain a minimum of Ethercard related commands to be able to respond to things like a ping.
Check the pings example..
phoenixb
Advanced Member
Advanced Member
Posts: 512
Joined: Thu Jul 23, 2009 1:00 pm
Location: Netherlands

Re: Ethernet module

Post by phoenixb »

Hi,
Yesterday I have found a little connection from the jeenode to the board that was broken (the SPI bus)
Now I see a little change on the working of the Ethercard, when I upload the sketch I see that the Ethernet led is short blinking (like a restart) but when I insert a static IP adres I can not ping it from a normal PC.
When I use the DHCP option the DHCP server give a IP adres but I can not reace it.
Even when I use a simple webserver with a Test page on port80 is not working.
Now I feel I do something wrong with the carrier / bridge board.
When I whant to upload a skech to the ethernet module which card setup must I use?
1) USB-BUB -> JeeNode -> Carrier Board -> Ethercard
2) USB-BUB -> Jeenode -> Bridge Board -> Ethercard
And which Card must i select in de program tool to upload the skech and must i alwase use the SPI bus (the 2x4pins connector)
I like to hear it.
Grtz,
__________________
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Ethernet module

Post by Digit »

Hi dj,

Where does the sketch arrive? Right, in the ATMega chip (that thing in the middle on the JeeNode).
So to upload a sketch you only need USB-BUB -> JeeNode.

What is "the program tool"? You're not being very clear. Do you mean the Arduino IDE? Then say so, I (and others) can't smell what you're using.
Which card to select? I can't even select a card!

Your former post:
JeeNode SMD (V3). Do you mean you have a JeeNodeSMD v3? There is no V3, only V1 IIRC. Maybe you mean a JeeNode USB v3? Something else?

One other thing: if sometime ends a sentence with a question mark, it means that person is waiting for an answer (in order to help you). If you don't answer, it's unlikely that you will be helped any further. In fact, don't post your problem at all if you don't want to answer.

So this is not going anywhere, the way this topic is going. I cannot make any cheese of it!
phoenixb
Advanced Member
Advanced Member
Posts: 512
Joined: Thu Jul 23, 2009 1:00 pm
Location: Netherlands

Re: Ethernet module

Post by phoenixb »

Hi Robert,

First sorry for the confusion around my questions, this was not my intention but I was too excited :?
The main problem is still the English language sometimes I have some trouble to write the Dutch question in good English.

But to return to the questions you asked
- What is "the program tool"? -> I use the Arduino IDE 0022 software.
- Which card to select? I can't even select a card! -> I can select different cards in the menu “tools-board”
- Do you mean you have a JeeNodeSMD v3 -> sorry for the mistake I have try a Jeenode SMD V1 and a Jeenode V3 (At least that v3 is printed on pcd)
grtz,
__________________
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Ethernet module

Post by Digit »

OK, thanks.

Regarding the board to select:
As of June 2011 the JeeNode SMD is equipped with the Optiboot loader.
If you get errors while uploading with terms like "not in sync", "protocol error" in it, select the "Arduino Uno" board and try again.
Otherwise, the board "Arduino Duemilanove or Nano with ATmega328" should work.

For a JeeNode "Arduino Duemilanove or Nano with ATmega328" should always work.

Idea: post the sketch you uploaded, or mail it to me.
I have a JeeNode V6 with EtherCard here on my desk so it's very easy for me to test your sketch.
If it works here, it's probably a hardware failure.
If it doesn't, I can have a look what's wrong with the sketch and maybe even fix it for you.
phoenixb
Advanced Member
Advanced Member
Posts: 512
Joined: Thu Jul 23, 2009 1:00 pm
Location: Netherlands

Re: Ethernet module

Post by phoenixb »

First I have check the type board setting in the software and have right now no errors when I upload the Sketch to the Jeenode V3 or the Jeenode SMD.
For test the Ethercard module I use from the Ethernet library (that I downloaded from the jeelabs wiki) the next ping sketch

Code: Select all

// Ping a remote server, also uses DHCP and DNS.
// 2011-06-12 <jcw@equi4.com> http://opensource.org/licenses/mit-license.php
// $Id: pings.pde 7725 2011-06-13 14:07:56Z jcw $

#include <EtherCard.h>

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

byte Ethernet::buffer[700];
static uint32_t timer;

// called when a ping comes in (replies to it are automatic)
static void gotPinged (byte* ptr) {
  ether.printIp(">>> ping from: ", ptr);
}

void setup () {
  Serial.begin(57600);
  Serial.println("\n[pings]");
  
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

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

#if 1
  // use DNS to locate the IP address we want to ping
  if (!ether.dnsLookup(PSTR("www.google.com")))
    Serial.println("DNS failed");
#else
  ether.parseIp(ether.hisip, "74.125.77.99");
#endif
  ether.printIp("SRV: ", ether.hisip);
    
  // call this to report others pinging us
  ether.registerPingCallback(gotPinged);
  
  timer = -9999999; // start timing out right away
  Serial.println();
}

void loop () {
  word len = ether.packetReceive(); // go receive new packets
  word pos = ether.packetLoop(len); // respond to incoming pings
  
  // report whenever a reply to our outgoing ping comes back
  if (len > 0 && ether.packetLoopIcmpCheckReply(ether.hisip)) {
    Serial.print("  ");
    Serial.print((micros() - timer) * 0.001, 3);
    Serial.println(" ms");
  }
  
  // ping a remote server once every few seconds
  if (micros() - timer >= 5000000) {
    ether.printIp("Pinging: ", ether.hisip);
    timer = micros();
    ether.clientIcmpRequest(ether.hisip);
  }
}
When I connect everything to the right way I see in my DHCP table a new IP adres so looks good, but when I look in the serial monitor in the Arduino IDE I see only the text [Ping} and a few minute later a error that the connection is fails.
When I try to ping het ip adres that I see in the DHCP table I get a error that the IP adres is not responding and that is the strange part.
I have also use this sketch with a fixed ip adres and also this one is not response on a ping command

Code: Select all

/*
  Web  Server
 
 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield. 
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)
 
 created 18 Dec 2009
 by David A. Mellis
 modified 4 Sep 2010
 by Tom Igoe
 
 */

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,10, 120 };

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
Server server(80);

void setup()
{
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  Client client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();

          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("<br />");
          }
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}
__________________
wwolkers
Member
Member
Posts: 273
Joined: Tue Sep 23, 2008 10:10 am
Location: Netherlands
Contact:

Re: Ethernet module

Post by wwolkers »

Hi,

make sure you have the latest version of the software.
JCW recently made some changed because there were bugs in the software. for more details check http://forum.jeelabs.net/node/350
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Ethernet module

Post by Digit »

I'll have a look later this evening.
Post Reply

Return to “Raspberry, Arduino, Cubietruck and other clones Forum”