feed: https://pachube.com/feeds/25061
The image above shows a graph on Pachube.com of the light intensity in my dorm room. A Light sensor was attached to an Arduino which was connected to my computer running Processing. The connection to Pachube was good but the collected data showed a lot of noise. (The sun came up at +- 6am)
I used the following sources to accomplish this:
http://community.pachube.com/arduino/usb/processing
http://community.pachube.com/?q=node/97
http://webzone.k3.mah.se/projects/arduino-workshop/projects/arduino_meets_processing/instructions/ldr.html
processing code:
import processing.serial.*;
import cc.arduino.*;import eeml.*;
Arduino arduino;
float myValue;
float lastUpdate;
DataOut dOut;
void setup()
{
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0], 115200);
dOut = new DataOut(this, "http://api.pachube.com/v2/feeds/25061.xml", "PACHUBE API");
dOut.addData(0,"light sensor, LDR, light level, light dependent resistor");
}
void draw()
{
myValue = arduino.analogRead(0);
println(myValue);
if ((millis() - lastUpdate) > 10000){
println("ready to PUT: ");
dOut.update(0, myValue);
int response = dOut.updatePachube();
println(response);
lastUpdate = millis();
}
}
2 comments
Don’t be discouraged by noisy data. Better sensor circuits are available, and sample conditioning can easily be achieved in software. Concerning the Arduino, it may be preferable to work interrupt-based. I’m new to Arduino, but not to microprocessors. A good design strategy may be to put the Arduino to sleep (thus consuming less and prolonging battery liftetime) until an internal hardware timer overflows, waking up the processor and prompting to acquire and process data. Wake-up time can be miliseconds while sleeping time can be seconds, minutes or even hours. Again, I’m not sure whether the Arduino is equipped with this kind of hardware but I’m fairly certain it is, as this kind of thing is fairly mainstream.
After some experimenting I know why there are price differences between sensors. Some just don’t work like they should or have more noise than anything else 🙂
And it is possible to let the arduino sleep. I didn’t do this yet but I read it somewhere. It is also possible with the XBee’s . But power consumption isn’t an issue at the moment, I think that is something that can be fixed later.