Show Posts
Pages: 1 2 [3] 4
31  Community / Bar Sport / Another Plataforms as Arduino on: May 24, 2012, 11:10:53 am
Hi everyone,

I've recently done a project with arduino boards. And I was wondering if you can help me. I need to know about another plataforms as powerJaguar and pingüino. These two are clones of Arduino. But, do you know about anything else? What did it happen when arduino didn't exist?

thank you for your time,

greetings!
32  Using Arduino / Networking, Protocols, and Devices / Re: PN532 Breakout Board on: March 30, 2012, 02:34:36 am
Hi PaulS,

I read it on the datasheet. Besides my teacher told me.  He told me to try some commands and watch the results. So my first step is trying to send a command and just read the answer. On the adafruit library I saw that you must send some byte before sending a commad as a sensor. But like I said it seems that it´s necessary an intermediate... Maybe one of you know a web page where I can find a tutorial ... o some clue to solve my problem.

anyway, thank you for your time!!

greetings!
33  Using Arduino / Networking, Protocols, and Devices / PN532 Breakout Board on: March 29, 2012, 04:16:33 pm
Hi everyone,

I hope you could help me. I have a PN532 and an Arduino FIO board. My question is How can I connect it? I saw in adafruit web page a tutorial, and a library. But I do not understand.  I saw this: http://www.adafruit.com/products/364A a few minutes ago. It seems   that there is an intermediaty between the fio and the PN532, and they develop a library to arduino. But it seems to complicated to me. What I mean is, if there is a easiest way to connect both of them. My PN532 has sel0 and sel1 off, the uart mode is selected. Can I use this mode to connect to the fio directly? Is there any sketch example to do it? Because it must work with a baudrate of 115200 8N1 .... but I do not know how to choose this parameters.

I tried the next:

Code:
#include "NewSoftSerial.h"
#define SS   5
#define MOSI 4
#define VCC  2
#define GND  3
NewSoftSerial cardSerial(5,4);

void setup() {
  cardSerial.begin(115200);
  Serial.begin(115200);
  Serial.print("probando lector de tarjeta\n");
  digitalWrite(VCC, HIGH);
  digitalWrite(GND, LOW);
}
void loop() {
  cardSerial.print(0x55, BYTE);
  cardSerial.print(0x55, BYTE);
  cardSerial.print(0x00, BYTE);
  cardSerial.print(0xFF, BYTE);
  cardSerial.print(0x03, BYTE);
  cardSerial.print(0xFD, BYTE);
  cardSerial.print(0xD4, BYTE);
  cardSerial.print(0x14, BYTE);
  cardSerial.print(0x01, BYTE);
  cardSerial.print(0x17, BYTE);
  cardSerial.print(0x55, BYTE);

  if (cardSerial.available()>0){
    Serial.print(cardSerial.read(), HEX);
    Serial.print("\nleo\n");
  }
  delay(1000);
 
}

Evidentely it doesn´t work. I´ve tried to read the datasheet but ... Also I´ve read the library from adafruit to understand how it could work but sadly I am pretty lost.

So I hope you could help me, give me some tips or clues to figure out how make this work.

Thank you for your time

greetings!
34  Using Arduino / Project Guidance / Re: JSON WEB SERVER html on: January 29, 2012, 04:55:21 pm
The client.println(" ") is not correct. That is not a blank line. It has a space. Try this.
Code:
client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/plain");
  client.println("Connection: close");
  client.println();
  // rest of stuff


thank you!! it works !!it works!!

really thank you!!
35  Using Arduino / Project Guidance / Re: JSON WEB SERVER html on: January 29, 2012, 03:34:28 pm
This test code is intended to go in a HTML document on your PC, not involving the Arduino at all.

You should see a message dialog showing you the value of json and json.name. Do you see both of them? Does json.name show the correct value "fio1"?

Hi PeterH,

... Yes,sorry, my english it is no so good, well I pasted the code example I used it on my PC and it worked.  But, my question was about the arduino... As you see I deleted the open(get... etc, status, ...  and I simply write the json strutcture. It worked, an alert window appeared saying "object Object" and filling the gaps, name: fio1, temperature: 32 etc. That means that the example worked, the example I pasted on the post. So, with that,  I added the status, get, etc... but the alert window shows nothing and the gaps are filled with "undefined" but if I use the json structure { name: fio1, temperature: 34...} If I use {name: fio1, variables: { temperature: "32", humidity: "86"... etc}} it says something as unable to get temperature ...

sorry for my english

thanks
36  Using Arduino / Project Guidance / Re: JSON WEB SERVER html on: January 29, 2012, 03:14:40 pm
The JSON looks right to me.

To eliminate some of the complexity while you get the basic JSON-string-to-script-variable part working, try this:

Code:
<script>
  var json = {  name: "fio1"  };
  alert("json=[" + json + "]");
  alert("json.name=[" + json.name + "]");
</script>

That should pop up a message dialog saying json=[Object object], and json.name=[fio1], or something similar.

If not, then check for script errors when it runs.

Hi PeterH,

I already did it on the example, and it shows " object Object" and it works:

name: fio1
temperature: 24
humidity: 85
address: 0x01
sleepCycle: 20
asynchronus: 0

but when I tried on the board, it said undefined ... maybe I explained myself badly. Sorry. Or I ´m not understand you xD

Anyway thank for reading my posts, I appreciate it.

Greetings!!
37  Using Arduino / Project Guidance / Re: JSON WEB SERVER html on: January 29, 2012, 02:46:54 pm
Quote
I want to show in a web page the values of my sensors.

The below is a more conventional and possibly easier method to display values in a web page.
...

Hi Zoomkat,

thank you for your time. I already know it, but I was asked to use JSON. I already did something similar...  http://g33k.blogspot.com/2010/09/arduino-data-webserver-sample-web.html

byes!!
38  Using Arduino / Project Guidance / Re: JSON WEB SERVER html on: January 29, 2012, 02:39:24 pm
As I understand it, you have a local web page that provides all the decorative stuff and just executes an HTTP request to the Arduino to retrieve some data. The page then processes the results and uses that to populate the page.

The basic approach seems OK. I haven't look at the detail of your JSON handling, but your JSON fragment is incorrect: the field names should not be quoted.

I suggest you get that sorted out by hard-coding your JSON string in the page and then use your existing logic to exec it into a variable; then you can print out whatever fields of that variable interest you.

Hi Peter,

thank you for your answer. You understood it quite well. I correted the json file, thanks. And I did as you said, separately, I write html web server. And It worked, but...
<!DOCTYPE html>
<html>
<head>
<script>
  function loadJson(fioNumber)  {
        var json = {
  name: "fio1",
  variables: {
     address: "0x01",
     temperature: "24",
     humidity: "85",
          asynchronus: "0",
          sleepCycle: "20"
      }}
;
alert(json);
        document.getElementById("temperature").innerHTML = json.variables.temperature;
        document.getElementById("humidity").innerHTML    = json.variables.humidity;
        document.getElementById("address").innerHTML     = json.variables.address;
        document.getElementById("sleepCycle").innerHTML  = json.variables.sleepCycle;
        document.getElementById("asynchronus").innerHTML = json.variables.asynchronus;
        document.getElementById("name").innerHTML        = json.name;
      };
</script>
</head>
<title>Servidor Web Arduino</title>
<body>

<FORM>
<p><INPUT TYPE=BUTTON OnClick="loadJson(1);" VALUE=FIO1></p>
<ul>
<li>name:         <a id="name"></a> </li>
<li> temperature: <a id="temperature"></a></li>
<li>humidity:     <a id="humidity"></a></li>
<li>address:      <a id="address"></a></li>
<li>sleepCycle:   <a id="sleepCycle"></a></li>
<li>asynchronus:  <a id="asynchronus"></a></li>
</FORM>

</body>
</html>

but...when I post on the card ... well... on browser, I open the console that show the code ... (in chrome F12) and it said that it couldn´t find temperature (which is part of variables...) well I simplified the structure... { name = "fio1, temperature="34"... etc} ... but Is it json? xD Anyway,  if I enter the IP address of my arduino it shows

fio1 (as a button)

name: undefined
temperature: undefined
humidity: undefined
address: undefined
sleepCycle: undefined
asynchronus: undefined

undefined¿? I searched through the web but... I am lost.
Could it be that the it is not response?
Did I send a bad response?

void sendGetResponse(int fioNumber, Client client) {
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/plain");
  client.println("Connection: close");
  client.println(" ");
  char filename[8];
  sprintf (filename, "F%d.jsn", fioNumber);
  filePrint(filename, client);
  client.flush(); 
}

I directly write the jsonfile  (client.print ...)

Thank you for your time, I really appreciate it.

greetings!
39  Using Arduino / Project Guidance / Re: JSON WEB SERVER html on: January 28, 2012, 03:24:55 pm
Hi,

thanks for your answer. The next step it will be to use a server, as you said. But I was asked to do this more or less... Just show the information. There is other examples, like ajaxwebserver I found it here ->http://djgj.sub.jp/TETRASTYLE/arduino/Ajax_WebServer.txt

As you can see, the html it is not complicated. And json is supposed to do easier. But anyway thank you for your answer.

byes!

40  Using Arduino / Project Guidance / JSON WEB SERVER html on: January 28, 2012, 02:58:48 pm
Hi everyone,

First of all, I want to apologize if this is not the correct place to post, and secondly as you notice my english it is not so good.

I hope you could help me. I want to show in a web page the values of my sensors. By now I am playing with a little example.

The system is composed by an arduino UNO and an Ethernet shield. Both work as a server. I made a "web page" in html:

("SERVER.txt"):
<!DOCTYPE html>
<html>
<head>
<script>
  function loadJson(fioNumber)  {
    var oJSON = new XMLHttpRequest();
    oJSON.open("GET","&fio" + fioNumber,true);
    oJSON.onreadystatechange = function()  {
      if (oJSON.readyState == 4)  {
        var json = eval("(" + oJSON.responseText + ")");
        document.getElementById("temperature").innerHTML = json.variables.temperature;
        document.getElementById("humidity").innerHTML    = json.variables.humidity;
        document.getElementById("address").innerHTML     = json.variables.address;
        document.getElementById("sleepCycle").innerHTML  = json.variables.sleepCycle;
        document.getElementById("asynchronus").innerHTML = json.variables.asynchronus;
        document.getElementById("name").innerHTML        = json.name;
      }
    };
    oJSON.send();
  }
</script>
</head>
<title>Servidor Web Arduino</title>
<body>

(F1.txt):

<FORM>
<p><INPUT TYPE=BUTTON OnClick="loadJson(1);" VALUE=FIO1></p>
<p>   name:        <div id="name"></div></p>
<p>   temperature: <div id="temperature"></div></p>
<p>   humidity:    <div id="humidity"></div></p>
<p>   address:     <div id="address"></div></p>
<p>   sleepCycle:  <div id="sleepCycle"></div></p>
<p>   asynchronus: <div id="asynchronus"></div></p>
</FORM>

</body>
</html>

I want to explain this, I create as files as sensors. If I have 4 sensors there are 4 files F1.txt,F2.txt,F3.txt,F4.txt. Itl would be sense with the sketch.

It is supposed that if a push the button, a http get request is sent to my board. And then it replies with a json object:
(this structure is saved as a file )
 {
  "name": "fio1"
  "variables":{
     "address": "0x01",
          "temperature": "24",
          "humidity": "85",
          "asynchronus": "0",
          "sleepCycle": "20"
      }
}

And I think when it is send to the browser it will work... I show you my super-sketch:

// LIBRERIAS

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

#include <SD.h>  // ocupa 5KB 

char fio[3];
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x49, 0xFD };
byte ip[]  = { 192, 168, 1, 2 }; //aula de informática {172,31,55,44} // laboratorio { 192, 168, 112, 31 }
byte gateway[] = { 192, 168, 1, 1};
Server server(80); // Puerto 80, HTTP

// VARIABLES GLOBALES

//Ethernet Shield uses pins 10,11,12,13.
#define bufferMax 128
int bufferSize;
char buffer[bufferMax];

// SD
File myFile;

#define ssPin       10
#define chipSelect   4

void setup() {

  Ethernet.begin(mac, ip, gateway);
  server.begin();
  Serial.begin(9600);    // inicia comunicación serie
  pinMode(ssPin,OUTPUT);

  if (!SD.begin(chipSelect)) {  // inicia la tarjeta SD
    Serial.println("initialization failed!");
    return;
  }
}

void loop() {

  listenForClient();
}

void listenForClient() {

  Client client = server.available(); // espera a que haya datos disponilbles
  if ( client ) {
    waitForRequest(client); 
    int fioNumber = parseReceivedRequest(client);
    if (fioNumber != 0)
      sendGetResponse(fioNumber, client); 
  }
  client.stop();
}

void waitForRequest(Client client) {
  bufferSize = 0;
  while (client.connected()) {
    if (client.available()) {
      char c = client.read();
      if (c == '\n')
        break;
      else
        if (bufferSize < bufferMax)
          buffer[bufferSize++] = c;
        else
          break;
    }
  }
  Serial.print(buffer);
}

int parseReceivedRequest(Client client) { // Petición recibida del tipo: "GET &fio1 HTTP/1.1"
  char* qm, * space;
  fio[0]=0;
   // strncpy does not automatically add terminating zero, but strncat does! So start with blank string and concatenate.
  if ( qm = strstr(buffer, "&fio") ) {  //apuntará a &
    qm     += 4; // sumando 5 apunta al valor deseado ( 4 letras --> "&", "f", "i", "o")
    space  = strstr(qm, " ") + 1;
    strncat(fio, qm, space-qm-5);
    return atoi(fio);
  } else if ( qm = strstr(buffer, " ") ) {
           webPrint(client);
           return 0;
         }  else
              return 0;
}


void sendGetResponse(int fioNumber, Client client) {
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/plain");
  char filename[8];
  sprintf (filename, "F%d.jsn", fioNumber);
  filePrint(filename, client);
  client.println(" ");
}
 
void webPrint (Client client) { 
  filePrint("SERVER.TXT", client);
  char filename[6];
  int fiolength =  1, i = 1;
  for ( i = 1; i <= fiolength; i++ ) {
    sprintf (filename, "F%d.txt", i);
    filePrint (filename, client);
  }
  client.println("</body>");
  client.println("</html>");
}
// fuente: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1295739118
void filePrint (char filename[10], Client client){
  char a;
  if (myFile = SD.open(filename, FILE_READ)) { 
    while ( myFile.available() ) {
      a = (char)myFile.read();
      client.print(a);
      Serial.print(a);
    }
    myFile.close();                 // CERRAR FICHERO
  }
}

basically I wait for http request, I write http:\\192.168.1.2 in the browser... so I received "GET /HTTP1.1" as there is not information I print the web page. Then I wait  for clicking the button, so it will appear an GET fio1 /HTTP1.1. I parse this last one, and response to it. I search on the micro SD card for a file called fio1 and then print this information that is the json structure  and nothing happens. The goal was  when the structure arrives to the client the script execute itself and fill the gap I wrote as <div ahref ... .... but... Maybe I make a  mistake writing the html or the script or the http json response is not the correct one...

I am sorry it is sort of big... xD. Well, my questions are:

I do not have idea of html or http, just the few things I´ve read. And it is a mess. So I am not know if the html is well proposed. Or if I can response the http get request as I did just printing on the client, ...

 I hope you could help me! Just read this is remarkable.

thank you !
41  Using Arduino / Programming Questions / wake up xbee through RF on: December 20, 2011, 03:56:18 am
Hi everyone,

I hope there is no similar topic, but I try search out in the forum but I got nothing. So here I am, I would like to know if it is possible to wake up a xbee module series 1 through RF. I read the datasheet and it says (http://ftp1.digi.com/support/documentation/90000982_E.pdf):

"Cyclic Sleep Remote with Pin Wake-up (SM = 5)

Use this mode to wake a sleeping remote module through either the RF interface or by the deassertion of Sleep_RQ for event-driven communications. "

After reading and searching forums I achieve to understand that while the xbee module is asleep, it cannot hear anything so if it has a incoming RF data it will just lost it, because it is asleep.

As you could guess I do not speak english correctly so I could misunderstand what I read. But maybe it is not, so I was wondering if anyone could help me to figure out how to wake a xbee through RF. By the way I am using API communications, just in case.

Again, I beg you pardon for my english.

Thank you,

bye!
42  Using Arduino / Project Guidance / Re: Arduino varibale sleep timer on: December 13, 2011, 11:45:20 am
Hi everyone,

I'm using a Fio board with a xbee-module. I've just read that you've achieved to sleep the board, could you tell me how to do it?

 I found some programs as http://www.arduino.cc/playground/Learning/ArduinoSleepCode, and libraries as Narcoleptic ( (http://code.google.com/p/narcoleptic/)) and enerlib (http://arduino.cc/playground/Main/LibraryList). Sadly I understand that if you want to wake up the board you need an external action, like to press a button or to type something on the monitor ... What I want is programme the board to sleep and wake up itself.

I hope you could help me.

sorry for my english

greetings!
43  Using Arduino / Programming Questions / Re: XBee Hibernate puts the Arduino asleep as well! on: December 13, 2011, 11:17:40 am
Hi,

I don't understand you quite well. But I'm trying to explain what I'm doing.

I'm using an arduino FIO with a xbee module. The fio will feed from a battery. Like you, I achieve to sleep the xbee module, but I'm not sure if doing that I'm sleeping the fio too.

I have some questions or comments to ask.... You enter on command mode, why? I used the  x-ctu program to enable SM to 1, I'm not concerning to putting to 0 later. I copy I part of my program

void setup() {
  pinMode(sleepPin, OUTPUT);    // OUTPUT controls xbee module
  digitalWrite(sleepPin, LOW);       // set to LOW (wake)
 
  xbee.begin(9600);  // start XBee communication
}

void loop() { 

    Serial.print("\n  zZzZzZzZ \n");
    digitalWrite(sleepPin, HIGH);  // sleep state

    delay(SLEEP_CYCLE*1000);  // tiempo en ms, declarado como UNSIGNED LONG !!!!

    digitalWrite(sleepPin, LOW); // ESTADO DESPIERTO
    Serial.print("\n  DESPIERTO\n");
    delay(1000);
    // 1. medir temperatura y humedad
    temperature = readSensor('T');
    humidity = readSensor('H');
    uint8_t data[] = { 3,4,1,temperature,2,humidity };
    uint8_t length = sizeof(data);
    uint8_t option = 0;

As you can see I do not enter to command mode...

well, maybe you don't need my experience xD but I was wondering if you are interesting on sleeping the board. I found these libraries:
 narcoleptic --> (http://code.google.com/p/narcoleptic/)
 enerlib --> (http://arduino.cc/playground/Main/LibraryList).

But, in all of them, it seems to be necessary an external action like press a button or write something on the monitor ... Well, rigth now, I am not quite sure of that, but what I need is a sort of a counter that when it is expired the board wakes up do something and again sleep, all itself without a external action.

I hope I could help you and overall,  you or somebody could give me a clue.

Greetings

(sorry for my english)
44  Using Arduino / Project Guidance / Re: [Big problem] Communication between multiple Arduino (with Xbee) without errors on: October 28, 2011, 05:04:50 pm
Hi,

I find out a function which gives you the address who belongs a packet:

Rx16Response rx16 = Rx16Response();

address_fio = rx16.getRemoteAddress16();
data = rx16.getData(5);

Now, knowing the address I can differenciate packets that the coordinator receives from

I hope it could be useful

greetings

(sorry for my english)
45  Using Arduino / Project Guidance / Re: [Big problem] Communication between multiple Arduino (with Xbee) without errors on: October 28, 2011, 03:27:58 am
Thanks Graynomad,

mmm I could do that. The coordinator asking for data consecutively.

So, there is no way to know the end device´s address... Although if I use polling it´s no longer necessary.

I was wondering if you know a tutorial of xbee library or API on arduino ... cause I found this one but it´s a little bit tricky: http://code.google.com/p/xbee-arduino/

anyway

thank you for your time

 
Pages: 1 2 [3] 4