Air Quality Egg Shield -> Cosm sample sketch

493 views
Skip to first unread message

sam mulube

unread,
Nov 9, 2012, 11:30:08 AM11/9/12
to airqua...@googlegroups.com
I just received my AQE shield today, and happened to have an idle Nanode lying around, so hacked together a quick sample sketch to push data to Cosm from the Nanode.

The sketch just combines the EggBus example with the EtherCard Cosm(Pachube) example, so it wouldn't be hard to replicate, but I just thought it might save someone some time.

The sketch will only currently work with a Nanode, not a standard Arduino due to the different Ethernet chipsets (I think), but maybe I should try to get that working as well.

The code is available here: https://github.com/smulube/aqe-shield

Any comments, suggestions, corrections gratefully received

Huisinr

unread,
Nov 11, 2012, 3:09:49 PM11/11/12
to airqua...@googlegroups.com
Thank you for the post , I'm still struggling but at least this helped me learn some thing more about coding on the arduino
Best
Ron

Cesar Garcia Saez

unread,
Nov 11, 2012, 3:26:47 PM11/11/12
to airqua...@googlegroups.com
Good work Sam!

Some questions about it:

1) Did you reset the APIKEY? I would suggest you to do it so people don't overwrite your data by mistake
2) DHT22 is a digital sensor (the output is digital) but it's labelled as analog.

Best,
César 


--



sam mulube

unread,
Nov 12, 2012, 5:42:31 AM11/12/12
to airqua...@googlegroups.com
Hey César,

thanks for the comments. I should have added a disclaimer that I'm actually one of the devs at Cosm so I do know the risks of publishing a valid API key for public consumption, so that is definitely an old one. However I should probably change the published code to avoid setting a bad example.

cheers

Sam

sam mulube

unread,
Nov 12, 2012, 5:44:12 AM11/12/12
to airqua...@googlegroups.com

Hey Ron,

thanks for the feedback. I'm no Arduino expert so this really was a copy/paste job from the work of others, but I'm glad it was of some interest. Will try and get a stock Arduino version working as well if I get a minute.

cheers

Sam

Cesar Garcia Saez

unread,
Nov 12, 2012, 6:33:28 AM11/12/12
to airqua...@googlegroups.com

I just reminded I pushed some repositories yesterday with my very own keys!
Luckily these are just test feeds.
Time to reset them :-)

Best,
César

--


eversion

unread,
Nov 13, 2012, 5:35:43 PM11/13/12
to airqua...@googlegroups.com

Hi. When I set up the Cosm feed should I manually set up datastreams with names that match the output descriptions in the serial monitor? Everything appears to be working fine but no data is arriving at the feed. Any ideas?

https://cosm.com/feeds/86131

Rob

sam mulube

unread,
Nov 13, 2012, 7:29:40 PM11/13/12
to airqua...@googlegroups.com

Hey Rob,

hmm that's a bit puzzling, but maybe we can figure it out. I did manually create the datastreams before I started the Nanode running, but actually you shouldn't need to do this - they should get created automatically by the incoming update if they're not present.

So I've had a look at your debug page here: https://cosm.com/users/axisdesign/debug , and there doesn't seem to be anything reaching the Cosm servers. This could mean either that your Nanode hasn't managed to connect to the network properly, or possibly that the API key you are using has a typo in it somewhere, as the only thing that links incoming requests to the debug page is if we have a valid API key to identify which user incoming requests belong to.

The possible API key issue is easy to verify, so maybe just double check that you copied the key correctly into your sketch, but to establish the device is correctly on the network we might need to back up a bit. When you look at the serial output from the board the first bit of output should show a little bit of network connection info. Does that all look alright, i.e. does it look like it's managed to obtain an IP address correctly?

To double check this it might be worth trying to run some of the other EtherCard examples just to make sure they seem to connect as they should. I normally start with the basic testDHCP example, but you should probably also try some of the examples that actually connect out to sites on the Internet.

If that all seems to work, could it be a firewall issue? I'm not sure what type of network you are trying to run the device on, but to test you could try making a manual request to Cosm from another machine. Typically for this we recommend using curl (http://curl.haxx.se/). If you have an OSX or Linux machine you probably already have this available, for windows you will probably need to install it manually.

Once you have it installed, make sure you have the debug page mentioned above open, and then from the same network your Nanode is connected to (actually maybe even using the same Ethernet cable if you can), you should be able to do:

curl --method GET --header "X-ApiKey: YOUR_API_KEY" http://api.cosm.com/v2/feeds/86131.json

which should show some data coming back from Cosm, and you should see the request appearing on your debug page. If that works then you should also try:

curl --method PUT --header "X-ApiKey: YOUR_API_KEY" --data-binary "0,0,0,0" http://api.cosm.com/v1/feeds/86131.csv

just to make sure that you are able to actually send a PUT request.

If all of that works, but still nothing is coming from the shield + nanode, then I'm a bit stuck, but if you drop us a line at sup...@cosm.com, we can dig a bit deeper to see if we can figure anything out.

Hope some of that is useful.

Best regards

Sam

Cesar Garcia Saez

unread,
Nov 13, 2012, 10:08:40 PM11/13/12
to airqua...@googlegroups.com, Ed Borden

Superb troubleshooting guide about putting data to Cosm in general. I think it should be included in the wiki/faq for new incoming users.
Best,
César

--


eversion

unread,
Nov 15, 2012, 5:06:55 AM11/15/12
to airqua...@googlegroups.com
Thanks Sam, that's great feedback. I've tested it by plugging it into my office router as well and tried it from there but still no luck. Everything seems to be right - see attachment - but still nothing arriving. I've also tried a different feed into a different Cosm account.

I'll try the method using Curl next and see if that explains it. I'm running Windows 64 bit but I have a Raspberry Pi I can use so that will probably be the easiest way to run curl.

What are the two figures below the CO measurement reading as zero? The characters don't appear to be showing correctly.

Rob

air-egg-86222.png

netnut

unread,
Nov 16, 2012, 7:18:18 PM11/16/12
to airqua...@googlegroups.com

Sam,

I tried the sketch both on a MAC and a Windows machine and on both it compiles but I get an upload error to the nanode. I know that the FTDI cable is working correctly as I am able to open the serial port and read the data on the existing sketch. The error I get is:

avrdude: Version 5.11, compiled on Sep 2 2011 at 18:52:52
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/Users/sanjayuppal/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/tty.usbserial-A4016Z0O
Using Programmer : arduino
Overriding Baud Rate : 57600
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

Seems like a generic nanode to computer error, but wanted to know if you came across this as well.

thx,

Sanjay

Rob Annable

unread,
Nov 19, 2012, 5:33:10 AM11/19/12
to airqua...@googlegroups.com
Hi Sam,

I've managed to get the GET command to work - although I had to take off the --method bit and just have one hyphen in front of GET (I'm no expert with code and this is the first time I've used curl!) but the PUT command doesn't seem to work.

I get the following: 'Only get, put and delete requests are allowed'

Any ideas?

Rob



Sam

--



sam mulube

unread,
Nov 20, 2012, 9:25:33 AM11/20/12
to airqua...@googlegroups.com
Hey, sorry for the slow response; been a bit busy at work so didn't spot these messages.

Hmm, that's interesting - it looks like the EggBus library is reporting more sensors from your shield than I see on mine. I've attached the output that I get in the Serial monitor.

I wonder if there's a difference in the EggBus version that we are using or if it's a genuine difference in the board (not sure if you have added any other sensors).

Oops, I see you've sent a follow up message. Will respond further there.

Screen Shot 2012-11-20 at 14.17.13.png

sam mulube

unread,
Nov 20, 2012, 9:33:32 AM11/20/12
to airqua...@googlegroups.com
Hey Sanjay,

I think you're going to run up against the limits of my Arduino knowledge very rapidly. I really don't know what this is. I do remember that I had an issue when I first tried to upload this sketch to the Nanode I had lying around. Previously I'd been using an Arduino Ethernet, which meant that no code would upload until I changed the option in the Tools > Board menu to be "Arduino Nano w/ ATmega328" (actually I suspect any of the ATmega328 boards might well have worked).

So what's the current Board setting, I'm also wondering what version of the Arduino IDE you are currently running? Are you able to load any other sketches the Nanode because when I had that problem I couldn't load any?

You'll probably have more joy posting this message on either the Nanode or Arduino forums as I've very much not an expert in this field.

Sorry that's not more helpful.

Best regards

Sam

sam mulube

unread,
Nov 20, 2012, 9:42:24 AM11/20/12
to airqua...@googlegroups.com
Hey again Rob,

sorry that was me being an idiot and not checking my curl options before I wrote that.

So if you do: man curl

and look through that whole big page of options this shows, you should see that it shouldn't have been --method, but actually --request, so the command actually should have looked like this:

curl --request PUT --header "X-ApiKey: YOURAPIKEY" --data-binary "0,0,0,0" http://api.cosm.com/v1/feeds/86131.csv

Hopefully that *will* work, so you can then get back to trying to figure out why the Nanode isn't working. Did you try running the "testDHCP" example bundled in the EtherCard library?

Best

Sam

netnut

unread,
Nov 20, 2012, 4:18:06 PM11/20/12
to airqua...@googlegroups.com

Thanks Sam,

I did get it to work when I selected UNO from the drop-down menu (hint from Vic at Wicked Device). Was not obvious to me, now the Nanode Gateway works fine with both OSX and Windows.

Cheers,

Sanjay

Message has been deleted

Rob Annable

unread,
Nov 24, 2012, 3:44:29 AM11/24/12
to airqua...@googlegroups.com
Thanks Sam.

Got the curl actions working fine, so it must be an eggbus library problem. Especially as having gone back to GitHub to download the latest version, I now appear to be getting a different output again with only CO readings and NO and no temperature.

Do I need to pick a particular previous build of the library do you think?

Rob
--

Victor Aprea

unread,
Nov 24, 2012, 10:41:24 AM11/24/12
to airqua...@googlegroups.com
Rob,

What makes you think there's a problem with the EggBus library? It seems to be very stable to me. If you run the PollEggBus example, do you get periodic output to the console?

Vic


--
 
 



--
Victor Aprea // Wicked Device

Rob Annable

unread,
Nov 27, 2012, 11:50:28 AM11/27/12
to airqua...@googlegroups.com
Actually I think there's a problem with the airqualityegg shield. I'm not getting any readings at all now. The PollEggBus example is just turning out the following:

 Table Row 219: [2, 112] => [0.00000000, 0.00000000]
     Table Row 220: [2, 112] => [0.00000000, 0.00000000]
     Table Row 221: [2, 112] => [0.00000000, 0.00000000]
     Table Row 222: [2, 112] => [0.00000000, 0.00000000]
     Table Row 223: [2, 112] => [0.00000000, 0.00000000]
     Table Row 224: [2, 112] => [0.00000000, 0.00000000]
     Table Row 225: [2, 112] => [0.00000000, 0.00000000]
     Table Row 226: [2, 112] => [0.00000000, 0.00000000]
     Table Row 227: [2, 112] => [0.00000000, 0.00000000]
     Table Row 228: [2, 112] => [0.00000000, 0.00000000]
     Table Row 229: [2, 112] => [0.00000000, 0.00000000]
     Table Row 230: [2, 112] => [0.00000000, 0.00000000]
 
ad infinitum 

And the Cosm sample sketch we've been discussing here isn't turning any data out now either :(

I attempted to plug into the top of an Arduino Wifi shield a few days ago - I wonder if that's damaged it?

Thoughts welcomed!

Rob


--
 
 

vicatcu

unread,
Nov 28, 2012, 10:31:54 AM11/28/12
to airqua...@googlegroups.com
Rob, yikes... there are not 219 table entries stored in the ATtiny88, so something is going seriously wrong here. Can you post the very first output from the PollEggBus sketch after a reset. I want to see if any of the "header" information is coming across the I2C bus...

I haven't tried using the Air Quality Egg Shield in conjunction with an Arduino WiFi shield, but looking at high level online docs, it doesn't look like there should be any kind of obvious hardware compatibility problem with that configuration.

Regards,
Vic

Rob Annable

unread,
Nov 28, 2012, 7:18:47 PM11/28/12
to airqua...@googlegroups.com
Interesting. Now that I've remembered to turn off the autoscroll button I can see more! 

NO2 and CO seem fine, but when we get to sensor type pb (is that temp or humidity?) it goes nuts and keeps going to table row 255 before starting again - here's a copy:

Egg Bus Address: 0x3
Firmware Version: 3
  Sensor Address: 00:04:A3:27:B5:CE
---------------------------
  Sensor Index: 0
    Sensor Type: NO2
   Indep. Scaler: 0.00010000
  Table X Scaler: 0.40000000
  Table Y Scaler: 1.70000004
 Measured Value: 314318 => 31.43179893
              R0: 2200
Implied Resistance: 69149.96093750
     Table Row 1: [62, 117] => [24.80000114, 198.90000915]
     Table Row 2: [75, 131] => [30.00000000, 222.70001220]
     Table Row 3: [101, 152] => [40.40000152, 258.39999389]
     Table Row 4: [149, 188] => [59.60000228, 319.60000610]
     Table Row 5: [174, 204] => [69.59999847, 346.80001831]
     Table Row 6: [199, 219] => [79.59999847, 372.30001831]
     Table Row 7: [223, 233] => [89.20000457, 396.10000610]
     Table Row 8: [247, 246] => [98.80000305, 418.20001220]
    Sensor Value: 227.6149291992
    Sensor Units: ppb
---------------------------
  Sensor Index: 1
    Sensor Type: CO
   Indep. Scaler: 0.00040000
  Table X Scaler: 0.00300000
  Table Y Scaler: 165.00000000
 Measured Value: 373 => 0.14919998
              R0: 750000
Implied Resistance: 111899.99218750
     Table Row 1: [134, 250] => [0.40199999, 41250.00000000]
     Table Row 2: [168, 125] => [0.50399999, 20625.00000000]
     Table Row 3: [202, 49] => [0.60599999, 8085.00000000]
     Table Row 4: [232, 12] => [0.69600000, 1980.00000000]
     Table Row 5: [241, 6] => [0.72300000, 990.00000000]
    Sensor Value: 100860.2968750000
    Sensor Units: ppb
===========================
Egg Bus Address: 0x57
Firmware Version: 0
  Sensor Address: 02:70:62:00:00:00
---------------------------
  Sensor Index: 0
    Sensor Type: pb
   Indep. Scaler: 0.00000000
  Table X Scaler: 0.00000000
  Table Y Scaler: 0.00000000
 Measured Value: 40919552 => 0.00000000
              R0: 40919552
Implied Resistance: 0.00000000
     Table Row 1: [2, 112] => [0.00000000, 0.00000000]
     Table Row 2: [2, 112] => [0.00000000, 0.00000000]
     Table Row 3: [2, 112] => [0.00000000, 0.00000000]
     Table Row 4: [2, 112] => [0.00000000, 0.00000000]
     Table Row 5: [2, 112] => [0.00000000, 0.00000000]
     Table Row 6: [2, 112] => [0.00000000, 0.00000000]
     Table Row 7: [2, 112] => [0.00000000, 0.00000000]
     Table Row 8: [2, 112] => [0.00000000, 0.00000000]
     Table Row 9: [2, 112] => [0.00000000, 0.00000000]
     Table Row 10: [2, 112] => [0.00000000, 0.00000000]
     Table Row 11: [2, 112] => [0.00000000, 0.00000000]
     Table Row 12: [2, 112] => [0.00000000, 0.00000000]
     Table Row 13: [2, 112] => [0.00000000, 0.00000000]
     Table Row 14: [2, 112] => [0.00000000, 0.00000000]
     Table Row 15: [2, 112] => [0.00000000, 0.00000000]
     Table Row 16: [2, 112] => [0.00000000, 0.00000000]
     Table Row 17: [2, 112] => [0.00000000, 0.00000000]
     Table Row 18: [2, 112] => [0.00000000, 0.00000000]




--



Victor Aprea

unread,
Nov 28, 2012, 11:44:18 PM11/28/12
to airqua...@googlegroups.com
Rob,
 
You must have some other I2C devices in your system. You'll need to consciously avoid accessing those I2C addresses that are not EggBus sensors in your sketch. Notably, address 0x57 seems to be the culprit in this case. The PollEggBus sketch indiscriminately assumes anything that responds on the I2C bus is a "EggBus compliant" but you can just guard against address 0x57 in your case with something like:
 
...
while((egg_bus_address = eggBus.next())){
    if(egg_bus_address == 0x57) continue;
    ...

That should help! As for what you have in your system that's responding to address 0x57... you know better than I!
 
Kind Regards,
Vic

--
 
 

Rob Annable

unread,
Dec 1, 2012, 6:41:56 PM12/1/12
to airqua...@googlegroups.com
Thanks Vic. The additional code doesn't seem to have helped unfortunately. At a bit of a loss now as all I've done as far as I'm aware is simply plug the shield into my otherwise unmodified nanode, so I don't know what else might be causing the problem with 0x57. At the limits of my understanding here I'm afraid - I'm an architect by day and unskilled hacker by night, so don't really have the skills to interrogate it properly. I think I'll try it in a different arduino and see if that helps.

Rob


--
 
 

Cesar Garcia Saez

unread,
Dec 3, 2012, 2:10:47 AM12/3/12
to airqua...@googlegroups.com

Some tips regarding Nanode Gateway:

-Old red Nanode were compatible with Arduino Duemillanove, and current green RF ones are compatible with Arduino UNO.

-I would advise against plugging other shields as most of the pins in RF are reserved by components on board. Only the analogs and digital pins 3,4,7,9 are free to use. We even got some side effects using digital ones.

-Six of the pins are moved in the Nanode RF. I think they are the ones for ISCP programming. Check if there is a connector under wifi shield trying to use those pins as some of the shields use them.

Best,
César

--
 
 
Reply all
Reply to author
Forward
0 new messages