Show Posts
Pages: [1] 2 3 ... 6
1  Using Arduino / Networking, Protocols, and Devices / Xively wifi download on: November 21, 2013, 04:32:04 am
Hello. I've been recently trying to read an active feed of myself from xively using wifishield and Arduino.
When I broadcast the data I get returns as 200.  but when I download the data i get return <-1 in serial monitor.
 I used to upload simple photo-resistor reading to xively as test through my Ethernet shield which shows correct reading on xively and my serial monitor.
Also in the same code when I tried to download the feed from xively, it was able to read correctly as the return was correct 200 everytime.
But when I used another Arduino and a separate wifi shield for it to first connect to the same network and 2ndly to a different network, i get return values in serial monitor as <-1 and so no feed is downloaded.

Can you help me here? The examples are from the xively library itself.
2  Topics / Home Automation and Networked Objects / optical dust sensor data to xively on: November 14, 2013, 03:46:30 am
Hello.
Recently I bought myself an optical dust sensor and I hooked it up with my Arduino and then I tested the code. It was satisfactory after consulting it's wiki page:
Here is the link:
http://www.seeedstudio.com/wiki/Grove_-_Dust_sensor
Code is there in the wiki page to read the data in serial monitor.

Now I wanted  to upload the data to xively and so I used xively's Arduino Library. (https://github.com/xively/xively_arduino)

Looking at one of the "data-stream upload example", I modified my code in this way:

Code:
//for OLED********
#include <Wire.h>
#include <SeeedOLED.h>
#include <avr/pgmspace.h>
//*****************
#include <SPI.h>
#include <Ethernet.h>
#include <HttpClient.h>
#include <Xively.h>

//Assigning parameters for the dust sensor//same as the previous code
int pin = 8;
unsigned long duration;
unsigned long starttime;
unsigned long sampletime_ms = 30000;//sampe 30s ;
unsigned long lowpulseoccupancy = 0;
float ratio = 0;
int concentration = 0;

//Xively parameters**************

// MAC address for your Ethernet shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

char xivelyKey[] = "neZYOTXMfiqD9OJD3sYiasJdmX1X5DxzyzH2IuHmhk4SLFAH"; //this is my xively API Key

char sensorId[] = "Particle_Conc:";
XivelyDatastream datastreams[] = {
 XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};

// Finally, wrap the datastreams into a feed
XivelyFeed feed(1803940077, datastreams, 1); // my FEED ID is 1803940077 and single datastream

EthernetClient client;
XivelyClient xivelyclient(client);


void setup()
{
  Serial.begin(9600);
  
  Serial.println("Starting single datastream upload to Xively...");
  Serial.println();
  while (Ethernet.begin(mac) != 1)
  {
    Serial.println("Error getting IP address via DHCP, trying again...");
    delay(15000);
  }
  
// OLED stuff****************************
  //pinMode(CS_pin, OUTPUT);
  Wire.begin();
  SeeedOled.init();  //initialze SEEED OLED display
  DDRB|=0x21;        
  PORTB |= 0x21;
  SeeedOled.clearDisplay();          //clear the screen and set start position to top left corner
  SeeedOled.setNormalDisplay();      //Set display to normal mode (i.e non-inverse mode)
  SeeedOled.setPageMode();
  SeeedOled.drawBitmap(url,1024);   // 1024 = 128 Pixels * 64 Pixels / 8  //Set addressing mode to Page Mode
  SeeedOled.setTextXY(4, 10);          //Set the cursor to Xth Page, Yth Column  
  SeeedOled.putString("Hello"); //Print the String
  SeeedOled.setTextXY(6, 10);          //Set the cursor to Xth Page, Yth Column  
  SeeedOled.putString("Folks"); //Print the String
  delay(5000);
  SeeedOled.clearDisplay();
  SeeedOled.setTextXY(2, 4);
  SeeedOled.putString("Pollution");
  SeeedOled.setTextXY(4, 4);
  SeeedOled.putString("Recorder");
  delay(2000);
  SeeedOled.clearDisplay();
  SeeedOled.setTextXY(3, 0);
  SeeedOled.putString("Measuring...");
 // SeeedOled.setHorizontalScrollProperties(Scroll_Right,3,0,Scroll_5Frames); //Set Scrolling properties to Scroll Right
 // SeeedOled.deactivateScroll();             // Activate Scrolling
 
//OLED stuff finished**********************

// Dust sensor parameters*****************
  pinMode(8,INPUT);
  starttime = millis();//get the current time;
  //////******************
}

void loop()
{
//Dust sensor calculation thing********************

  duration = pulseIn(pin, LOW);
  lowpulseoccupancy = lowpulseoccupancy+duration;
  
  if ((millis()-starttime) > sampletime_ms)//if the sampel time == 30s
  {
    ratio = lowpulseoccupancy/(sampletime_ms*10.0);  // Integer percentage 0=>100
    concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve
  
    Serial.print("Lowpulseoccupancy: ");
    Serial.print(lowpulseoccupancy);
    Serial.println("Ratio: ");
    Serial.print(ratio);
    Serial.println("Conc.: ");
    Serial.print(concentration);
    Serial.println();
    
    lowpulseoccupancy = 0;
    starttime = millis();
    
//Xivly upload stuff happening here
    datastreams[0].setFloat(concentration);
    int ret = xivelyclient.put(feed, xivelyKey);
    Serial.println(ret);
    Serial.println();
 //   problem is here some where

    SeeedOled.clearDisplay();
    //SeeedOled.deactivateScroll();
    SeeedOled.setTextXY(0, 0);
    SeeedOled.putString("Dust Conc.");
    SeeedOled.setTextXY(2, 0);
    SeeedOled.putString("in pcs/283ml:");
    SeeedOled.setTextXY(4, 1);
    SeeedOled.putFloat(concentration);
   }
   delay(500);
  }

Now It's uploading data as expected after it's 30s sampling time, but the data's do not match. It's almost much lesser than the data I get using the previous code(Not implementing  xively alterations).

I'm confused if it has to do with delay or something?
It would be kind if any body out there can scan the code and tell me what's going wrong.
3  Using Arduino / Networking, Protocols, and Devices / Re: X-bee + Arduino prope - need proper buffer-less flow on: September 16, 2013, 03:28:00 pm
Forgot to attach the receiver plotter schematic
. Please look for the attachments


4  Using Arduino / Networking, Protocols, and Devices / X-bee + Arduino prope - need proper buffer-less flow on: September 16, 2013, 03:26:05 pm
Ola everyone!

Was just trying out something crazy and thought of showing carbon monoxide levels as pencil plots (Something like carbon rings on paper) by controlling the translation of a servo attached to a Arduino over  wireless x-bee network (See pic below for "Receiver plotter.png").
A MQ7 equipped with an LCD and X-bee on an Arduino will act as the sensor transmitter(Made it successfully and is working. See Pic below-"Transmitter sensor.png") .

The Anaglog voltages are well printed on the LCD(As indicative CO levels) and show the same data on X-CTU's terminal over wireless X-bee network.
(with a "." in fornt of each received data like . 123, .234 etc etc).

this is the Transmitter sensor code:
Code:
[/font][/size]

#include <LiquidCrystal.h>

int sensorValue;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2); 
}

void loop()
{
sensorPrintFunction();
}

void sensorPrintFunction()
{
  sensorValue = analogRead(0);       // read analog input pin 0
  Serial.println(sensorValue, DEC);  // prints the value read
  delay(100);                        // wait 100ms for next reading
 
  lcd.clear(); // Clear the display
  lcd.print("CO level:"); // Print some text
  lcd.setCursor(0,1);
  lcd.print(sensorValue);
  delay(200);
}

I'm receiving values ranging from 120-400(depending on environment I'm in currently).

The only concern is, the servo's not translating as fast with the data change and it even does not change at all sometimes in cases like when the value changes from say 164 - 175. I could just hear a noise from the servo and that's it. I'm using 9gms micro servos but tried with bigger ones also.
I need a noticeable and rapid  translations in the servo.

Here's the receiver end's code:

Code:
#include <Servo.h>

Servo myservo;
int x = 0;

void setup()
{
  Serial.begin(9600);
  myservo.attach(9);
}

void loop()
{
 
  while(Serial.available())
  {
    x = Serial.read()-'0';
    Serial.flush();
  }
  myservo.write(x);
  delay(5);
 
 }

Please Help me with the code.

What i'm guessing is may be
 1. Buffer problem-But I'm using "Serial.flush();"
 2. May be delay can have some effect. Not effected much I tried. (Have to try few more shots.)
 3. using "volatile byte" as datatype for the incoming serial data did not make much difference too. (Did not tried it sincerely though) .

Help me here anybody.
5  Community / Gigs and Collaborations / Re: Controlling RGB Leds from Live video feedback(Using processing) on: September 05, 2013, 04:59:41 am
This is the final code I came up with. But since I'm not having currently ant RGB LEDs with me(They are in shipment), I'm not able to test it.

Can anybody verify it and suggest where to rectify.

Notes: Processing is ending floats and Arduino is storing them as ints in the array. Hope that won't matter much.

Anyways here's the code.

Code:
//int counter = 0;
int redPin = A0;
int greenPin = A1;
int BluePin = A2;

int incomingdata[6];

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  if (Serial.available() > 0)
  {
  incomingdata = Serial.read();
   
  analogWrite(redPin, incomingdata[0]);
  analogWrite(BluePin, incomingdata[2]);
  analogWrite(greenPin, incomingdata[4]);
}
}
6  Community / Gigs and Collaborations / Re: Controlling RGB Leds from Live video feedback(Using processing) on: September 05, 2013, 04:51:04 am
Hi.
Thanks for replying.
It would be a pleasure if you could tell me which data type to assign as the suffix to an array which contains both character and float .
I mean, my processing sketch is say writing these values in serial port at some instance.

23.00,34.00,54.00.

here 23.00, 34.00 and 54.00 are floats and "," is the character.

the respective chuck of processing code :
Code:
myPort.write(float r + "," + float g + ";" + float b + ".");


Now to assign an array and access from it would need

Code:
//for defining the variable
int incomingdata[16]; //say
 // or
char incomingdata[16];

And for accessing the data from the array and assigning it to something may be like this :

Code:
analogWrite(A2, incomingdata[10]);// writing say Pin A2 with the incoming value stored in 10th chamber of the array "incomingdata"

Now the questions are:

How can I Afford both "," and "floats" in the same array (Do I really need to do that)
and then how to convert floats in to integers ?
7  Community / Gigs and Collaborations / Re: Controlling RGB Leds from Live video feedback(Using processing) on: September 03, 2013, 02:50:35 am
That is where I'm stuck. I know parsing from strings and bytes in Processing but is a bit confuse in terms of Arduino. So I need the help in code.
8  Community / Gigs and Collaborations / Controlling RGB Leds from Live video feedback(Using processing) on: September 02, 2013, 07:55:03 am
Hello.
I'm trying to build a project where in a acrylic pillar will change it's color according to the ambiance.
Now to do that I've written (With taking some help) a program in Processing which would send serially the R G B values from the live camera video.
(The Processing sketch is attached below)
here's the snippet from the processing sketch which sends R G B Values to the serial port.
Code:
myPort.write(r + "," + g + "," + b + ".");
code:
Code:
import processing.video.*;
import processing.serial.*;
Serial myPort;
Capture video;
float m,r,g,b;
int loc;
boolean R = false;

PFont f;

void setup() {
  size(640,480);
  myPort = new Serial(this, "COM11", 9600);
  video = new Capture(this,width,height,15);
  f = createFont("Haettenschweiler",12);
}

void draw() {
  if (video.available()) {
    video.read();
  }
  image(video,0,0);
 
  for (int i = 0; i < video.width; i+=10) {
    for (int j = 0; j < video.height; j+=10) {
      loc = i + j * width;     

      color c = video.pixels[loc]; // Get a pixel   
     
      r = red(c);
      g = green(c);
      b = blue(c); // Get the red value

      m = map(i, 0, width-50,50, 100);
     
      stroke(255,0,0);
      point(m-40,-r/2+height-5);
     
      stroke(0,255,0);
      point(m+20,-g/2+height-5);
     
      stroke(0,0,255);
      point(m+80,-b/2+height-5);
    }
  }
 
  textSize(10);
  fill(255,0,0); 
  text(nf(r,2,0),200,height-60);
  fill(0,255,0); 
  text(nf(g,2,0),200,height-45);
  fill(0,0,255); 
  text(nf(b,2,0),200,height-30);
  myPort.write(r + "," + g + "," + b + ".");
  println(r + "," + g + "," + b);
}


Now I need an Arduino sketch which would utilize this received string to write, with PWM, the RGB LED's Pins Accordingly for according color settings.
I don't know where to start from extracting the string in the Arduino code.
I found a simple RGB control program on web which I'm attaching here(with a bit of my own twitching)

Code:
int redPin = 11;
int greenPin = 10;
int bluePin = 9;

void setup()
{
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT); 
 
  Serial.begin(9600);
}

void loop()
{
  setColor(255, 0, 0);  // red
  delay(1000);
  setColor(0, 255, 0);  // green
  delay(1000);
  setColor(0, 0, 255);  // blue
  delay(1000);
  setColor(255, 255, 0);  // yellow
  delay(1000); 
  setColor(80, 0, 80);  // purple
  delay(1000);
  setColor(0, 255, 255);  // aqua
  delay(1000);
}

void setColor(int red, int green, int blue)
{
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue); 
}

void serialEvent() {
  while (Serial.available())
 {
//from here on I need some help
...
}

I got this reply here :

http://forum.arduino.cc/index.php?topic=185841.new;topicseen#new

Can anybody help me here?
9  Using Arduino / Programming Questions / Re: Controlling RGB Leds from Live video feedback(Using processing) on: September 02, 2013, 07:34:10 am
guys!! sorry to say so but this started sounding all alien to me. You see I'm not so regular with Arduino. So if any of you can please edit the code it would be a lot of help for me.   smiley-sweat
10  Using Arduino / Programming Questions / Controlling RGB Leds from Live video feedback(Using processing) on: September 02, 2013, 05:48:04 am
Hello.
I'm trying to build a project where in a acrylic pillar will change it's color according to the ambiance.
Now to do that I've written (With taking some help) a program in Processing which would send serially the R G B values from the live camera video.
(The Processing sketch is attached below)
here's the snippet from the processing sketch which sends R G B Values to the serial port.

Code:
myPort.write(r + "," + g + "," + b + ".");

code:

Code:
import processing.video.*;
import processing.serial.*;
Serial myPort;
Capture video;
float m,r,g,b;
int loc;
boolean R = false;

PFont f;

void setup() {
  size(640,480);
  myPort = new Serial(this, "COM11", 9600);
  video = new Capture(this,width,height,15);
  f = createFont("Haettenschweiler",12);
}

void draw() {
  if (video.available()) {
    video.read();
  }
  image(video,0,0);
 
  for (int i = 0; i < video.width; i+=10) {
    for (int j = 0; j < video.height; j+=10) {
      loc = i + j * width;     

      color c = video.pixels[loc]; // Get a pixel   
     
      r = red(c);
      g = green(c);
      b = blue(c); // Get the red value

      m = map(i, 0, width-50,50, 100);
     
      stroke(255,0,0);
      point(m-40,-r/2+height-5);
     
      stroke(0,255,0);
      point(m+20,-g/2+height-5);
     
      stroke(0,0,255);
      point(m+80,-b/2+height-5);
    }
  }
 
  textSize(10);
  fill(255,0,0); 
  text(nf(r,2,0),200,height-60);
  fill(0,255,0); 
  text(nf(g,2,0),200,height-45);
  fill(0,0,255); 
  text(nf(b,2,0),200,height-30);
  myPort.write(r + "," + g + "," + b + ".");
  println(r + "," + g + "," + b);
}


Now I need an Arduino sketch which would utilize this received string to write, with PWM, the RGB LED's Pins Accordingly for according color settings.
I don't know where to start from extracting the string in the Arduino code.
I found a simple RGB control program on web which I'm attaching here(with a bit of my own twitching)
Code:

int redPin = 11;
int greenPin = 10;
int bluePin = 9;

void setup()
{
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT); 
 
  Serial.begin(9600);
}

void loop()
{
  setColor(255, 0, 0);  // red
  delay(1000);
  setColor(0, 255, 0);  // green
  delay(1000);
  setColor(0, 0, 255);  // blue
  delay(1000);
  setColor(255, 255, 0);  // yellow
  delay(1000); 
  setColor(80, 0, 80);  // purple
  delay(1000);
  setColor(0, 255, 255);  // aqua
  delay(1000);
}

void setColor(int red, int green, int blue)
{
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue); 
}

void serialEvent() {
  while (Serial.available())
 {
//from here on I need some help
...
}


Please help me get the code fixed.
 
11  Using Arduino / Networking, Protocols, and Devices / Re: Thermal Printer + Arduino + need of RTS/CTS and DTR/DSR pins? on: August 01, 2013, 03:03:50 am
Thanks.
I'll try now.
12  Using Arduino / Sensors / Optical mouse ADNS 2610 + Arduino trouble compiling on: July 30, 2013, 06:39:02 am
Hello;

I recently came along a tutorial of jacking in an optical mouse (chip A2610) with Arduino from this link : http://www.martijnthe.nl/2009/07/interfacing-an-optical-mouse-sensor-to-your-arduino/

Now when I try to compile the  code following the instructions written in the code itself as comments I get the following errors:

First What I did:

1. Downloaded the library and changed it's name to simply "OptiMouse"
2. Tried to run the "coordinate" example.
 It gave me following errors:

Coordinates.cpp:16:21: error: PAN3101.h: No such file or directory
Coordinates.pde:-1: error: 'PAN3101' does not name a type
Coordinates.cpp: In function 'void setup()':
Coordinates.pde:-1: error: 'Optical1' was not declared in this scope
Coordinates.cpp: In function 'void loop()':
Coordinates.pde:-1: error: 'Optical1' was not declared in this scope

Second what I tried:

1. moved the ADNS_2610.cpp and ADNS_2610.h and ADNS_2610.o outside the driver folder where OptiMouse.cpp and OptiMouse.h are located (as mentioned in the code comment).

2. Same errors I got.

I don't know what to do now. help me .


13  Using Arduino / Networking, Protocols, and Devices / Re: Thermal Printer + Arduino + need of RTS/CTS and DTR/DSR pins? on: July 30, 2013, 03:55:42 am
If I don't use them at all will it affect the printing function? And If I just use the serial communication as shown in the bildr tutorial for printing will it work with this printer? I kindly request you to re-frame a conclusive wiring for the Arduino and my Thermal printer from studying briefly the data-sheet (the data sheets attached).

I Think powering it , then connecting the Rx-TX and TX-Rx and GND will do enough as given in bildr tutorial.

Thank you
14  Using Arduino / Networking, Protocols, and Devices / Thermal Printer + Arduino + need of RTS/CTS and DTR/DSR pins? on: July 30, 2013, 03:36:16 am
I recently salvaged a thermal printer saying "EM205_101122" on it's circuit board. I also got success in accessing to all it's datasheets.
It seems that it has a RS232 as well as TTL ports, but both of the ports are given two  extra pins saying "RTS/DTS and DTR/DSR".
While I read about them, they are the flow control pins and are to be kept +12V or -12V.
For communication with the Arduino (as given  in this tutorial: http://bildr.org/2011/08/thermal-printer-arduino/) does these pins are required to be used or we can just use the RX TX pins only?

Help me as I'm stuck in middle of it and I just want to be sure as I don't want to burn anything trying to make it.

Ps find the datasheets as attached below
15  Topics / Device Hacking / thermal printer + Arduino on: July 30, 2013, 03:30:00 am
I recently salvaged a thermal printer saying "EM205_101122" on it's circuit board. I also got success in accessing to all it's datasheets.
It seems that it has a RS232 as well as TTL ports, but both of the ports are given two  extra pins saying "RTS/DTS and DTR/DSR".
While I read about them, they are the flow control pins and are to be kept +12V or -12V.
For communication with the Arduino (as given  in this tutorial: http://bildr.org/2011/08/thermal-printer-arduino/) does these pins are required to be used or we can just use the RX TX pins only?

Help me as I'm stuck in middle of it and I just want to be sure as I don't want to burn anything trying to make it.

Ps find the datasheets as attached below
Pages: [1] 2 3 ... 6