So I’ve blogged about using the Precon Temperature/Humidity sensor before, but it is time, apparently,to re-visit the topic. We’re working on a project with Vodafone, and I needed to write a brief “How To” for them, so I thought I’d just make it here so everyone (both of you) could benefit.
First, this sensor is possibly the easiest to hook up and interact with of any I have worked with. It has a simple analog temperature sensor and an analog humidity sensor that are just read as a percentage of the reference voltage supplied to the unit. So if the voltage supplied is 3.3v, and the humidity value read is 3.3, then you’re at 100% humidity. And it’s a simple linear scale, so there is no complex conversion, etc. The same is true of the temperature value, though the scale is -30° C to +100° C, so you have to do a little bit of adjusting of the raw value.
The wiring is extremely simple:
That’s Pin 1 — Temperature — of the Precon to Pin A1 on the Sun SPOT for Temperature readings. Pin 2 of the Precon to +3v on the Sun SPOT — to power the sensor. Pin 3 — Relative Humidity — of the Precon to pin A2 of the Sun SPOT for RH readings. And Pin 4 — Ground — of the Precon to Ground on the Sun SPOT. The only other connection you need is +3.3v on the Sun SPOT to Pin A0 on the Sun SPOT for reference Voltage (vref). Since the sensor readings are a percentage of supplied voltage, you have to keep track of the supplied voltage, and this is how.
That’s it for wiring. Really.
Now, the code is just as simple. Once gain, really.
I used NetBeans, of course, to create the project using the Sun SPOT Application Template Module (for information of installing these templates, see here). Here’s the code for the main class:
/*
* RHGPS.java
*
* Created on Aug 21, 2008 4:54:22 PM;
*/
/**
* The startApp method of this class is called by the VM to start the
* application.
*
* The manifest specifies this class as MIDlet-1, which means it will
* be selected for execution.
*/ publicclass RHGPS extends MIDlet {
protectedvoid startApp()throws MIDletStateChangeException {
System.out.println("Hello, world"); new BootloaderListener().start(); // monitor the USB (if connected) and recognize commands from host
IScalarInput vref = EDemoBoard.getInstance().getScalarInputs()[EDemoBoard.A0];
RHSensor rh = new RHSensor(EDemoBoard.A1, vref);
TempSensor ts = new TempSensor(EDemoBoard.A2, vref); long ourAddr = Spot.getInstance().getRadioPolicyManager().getIEEEAddress();
System.out.println("Our radio address = " + IEEEAddress.toDottedHex(ourAddr));
ISwitch sw1 = EDemoBoard.getInstance().getSwitches()[EDemoBoard.SW1];
flash.setRGB(100,0,0); // set color to moderate red while(sw1.isOpen()){ // done when switch is pressed try{
// done when switch is pressed
flash.setOn(!flash.isOn());// Blink LED
System.out.println("Temp: " + ts.getTemp() + " Degrees C.");
System.out.println("Humidity: " + rh.getRH() + "%");
Utils.sleep(SLEEP_INT); // wait 1 second }catch(IOException ex){
ex.printStackTrace(); } }
notifyDestroyed(); // cause the MIDlet to exit }
protectedvoid pauseApp(){
// This is not currently called by the Squawk VM }
/**
* Called if the MIDlet is terminated by the system.
* I.e. if startApp throws any exception other than MIDletStateChangeException,
* if the isolate running the MIDlet is killed with Isolate.exit(), or
* if VM.stopVM() is called.
*
* It is not called if MIDlet.notifyDestroyed() was called.
*
* @param unconditional If true when this method is called, the MIDlet must
* cleanup and release all resources. If false the MIDlet may throw
* MIDletStateChangeException to indicate it does not want to be destroyed
* at this time.
*/ protectedvoid destroyApp(boolean unconditional)throws MIDletStateChangeException { for(int i = 0; i < 8; i++){
flash.setOff(); } } }
So that's the Main portion. You will notice that there is reference to 2 other classes, RHSensor and TempSensor. Those are amazingly simple classes, listed here:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/ package org.sunspotworld;
/**
*
* @param pin Pin number for analog reading of Temperature
* @param vref IScalarInput pin for voltage reference
*/ public TempSensor(int pin, IScalarInput vref){ this.temp = EDemoBoard.getInstance().getScalarInputs()[pin]; this.vref = vref; }
/**
*
* @return Double value of degrees C
* @throws java.io.IOException
*/ publicdouble getTemp()throws IOException { return(((double) temp.getValue() - 115) / (double) vref.getValue()) * 100;
} }
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
And that's all there is to it. A simple ant deploy run will put the application in your Sun SPOT, and start it spitting out Humidity and temperature readings every 1/4 second.
I hate to use public humiliation as a means to get action, but sometimes, it's the only way. I've been trying for a week to get some response -- any response -- out of Facebook support. I know, you may think that is an oxymoron right there, and given my current experience, I'm inclined to agree with you.
How hard is it for a support organization to actually respond to issues submitted in a finite amount of time? How hard can it really be? Seriously.
Here's the issue. I own a group on Facebook for the Wake County Special Education PTA (Wake SEPTA). I'm their de facto webmaster. So I decided to promote them on Facebook. Why not, right? Well, I managed to somehow click the wrong button and change my location. Duh. Silly mistake. But it, apparently has dire consequences. I lost Administrative rights to my Raleigh/Durham based group, WakeSEPTA. This wouldn't be a problem if there were other Admins that could re-authorize me. But there aren't, so the group is 'orphaned' such that no one can join, and I can't get back in to administer it.
So last week I began asking Facebook Support for help. So far, nothing. Not a peep. Not a response. No help. Nothing. Is the help alias hooked straight to /dev/null? Sure seems like it.
One would think that Facebook would be interested in actually supporting users. But apparently once you're hooked, they don't much care. I'd love to get this issue resolved. I would have loved to have gotten this issue resolved a week ago. Seems like an easy thing to fix. But it does take some response from Support before it can get fixed.
So back in 1998, while I was the Technology Manager for Sun Ray, I set a goal for myself of winning the Chairman's Award (as it was called at the time). This is a very prestigious award at Sun, and is remarkably hard to win. I worked myself near to death for years trying to win this award, to no avail.
3 years ago I left the Honeycomb Team in the Labs a few months before they won the award (now called the Sun Innovation Award). Once again, close, but no cigar.
So I'm very happy, and feel honored, that the Sun SPOTs Team has won an Innovation Award for FY08. This is a very high honor indeed, and I am pleased to be a part of such a fantastic team that has produced an innovation worthy of such high honor. This was certainly a Team effort, and everyone associated with the project deserves the recognition. So, my hat is off to my team members for getting me somewhere I have aspired to for many years.
Again, this was a Team effort of enormous proportions. The Hardware folks delivered unmatched quality with a stunningly low level of returns and errors. The Software team (Squawk and the Sun SPOT Team) delivered some remarkably stable software, and we have seen the adoption of Sun SPOTs increase through both sales and our Sun SPOT Open Grant Program.
But without our users, customers, champions and supporters, we'd be toiling in obscurity, so it is really thanks to all who use Sun SPOTs, are enthusiastic about Sun SPOT, and the entire community. Thank you.
As of 2 minutes ago, the search for Nancy Cooper, our neighbor, is officially over. Her body was found last night. I don't even know what to say. I am at a loss for words, and am deeply saddened. The neighborhood of Lochmere is an open, friendly, and close-knit community and this hits hard.
Family and friends of Nancy Cooper thank all of those who helped on Sunday with the search for Nancy. They had 150+ people looking on trails and covering the city with close to 2000 fliers. Truly the fliers are everywhere, which is a good thing.
The plan for today (Monday) is to go out and search more. There will be headquarters at both Lifetime Fitness and Java Jive starting at 9 am. From there people will be sent to a designated area to search in larger groups focusing on the area 20 feet to the sides of the trails and also out-lying neighborhoods. Volunteers are needed throughout the day.
Needless to say, we'll be out searching today. Hope you can join in.
Copied verbatim from Rich Sharple's blog, but this is big ... and scary for us.
One of our neighbors - Nancy Cooper has been missing since the morning of Saturday, July 12. She went for a run around 7am on Saturday morning in theLochmere / Regency Lake area of Cary, NC and never returned. Nancy is white, has shoulder length brown hair and hazel eyes, she’s 5 feet 9 inches tall and weighs about 120 pounds. She was last seen wearing a T-shirt, running shorts and light blue running shoes.
There’s more information and photos on WRAL.com and the News & Observer. If you’re a local blogger - please help spread the word and If you have any information contact Cary Police at 919-469-4016 / 4012.
As some (many? both?) of you know, we have been running a special program for Education with Sun SPOTs. We have been accepting proposals, and granting Sun SPOT kits, for course development in Wireless Sensor Networks, Robotics, and a wide range of other topics. The courses developed through this program are required to be open source, and we're starting to get results!
RTI has submitted an interesting website with some of their course development activities and results. Check it out!
I'll post more as they roll in. If you're working on one of these projects, and you want to see your project listed here, just send me the link (again, if you already did and I ignored it) and I'll get it posted here!
I think we (Sun) 'get it' and get it right, most of the time. Not on everything, for certain, but when it comes to communication, openness and transparency, we have that down. As a counter example ...
I use a nifty piece of software from BareBones Software called Yojimbo (I know, the name sort of blows, but it's a great 'digital junk drawer' for my Mac and helps me save, organize and keep track of lots of stuff in one place. But I digress). Don't get me wrong here, I love the product, and use it almost every day. But their communication strategy seems to be modeled on Apple's. Tight-lipped and reticent. The users on the Yjimbo users' alias are clamoring for answers, for insight into what may, or may not, be going to happen with the product, and where things are headed. the response from BareBones?
Yep, pretty much. Well, other than to point to their FAQ, which says:
We'd like to offer an iPhone version of Yojimbo, but can't currently say if/when this may happen nor what its feature set might be. As soon as we're able to provide more info about our plans, we will do so.
The equivalent of "we can neither confirm nor deny ..." and a non-answer. Don't get me wrong, I understand that at times it can be advantageous to carefully control the release of information so as to not over-promise, under-deliver, or to make a big splash with your announcements. But there is a lot to be said for involving your users, for making them feel involved, a part of the process, and invested in your products. A user that has a mere affinity for a product is not nearly as good as a user that has an investment in, and a commitment to, a product or company. Involving your users gives them the investment and commitment to make them useful assets, not just the other end of the payment stream.
And what has all this to do with Sun? Well, I really think that this little experiment we call blogs.sun.com is a shining example of what can come of a company that values open communication with its customers -- and potential customers. Very few of our customers, I would venture, are unclear about what we are working on, where we are investing, and what they can expect from us. Yes, we all want to see more from the stock price, etc. but it's pretty clear that we have a real commitment to open communication with our customers.
Two years of hair comes almost full circle. When I moved to North Carolina in 2006, I did this:
Yep, cue-balled it. It was easier than having to wash it.
But as soon as I moved here, my then-9 year-old son began a project to grow his hair and donate it to Locks of Love. It was his own idea, and something I'm proud of him for coming up with. And he asked me to do it with him, so I did. Well, last week was cutting time, and I went from this:
to this:
in 10 minutes.
I feel much better now.
[ The only thing to do with good advice is pass it on. It is never any use to oneself.
So the ratings for the JavaOne Hands On Labs came out, and we (Sun SPOTs) did pretty well. Above average, to be exact.
The following scores are generated using the Overall Quality values.
Overall Conference Average (all sessions) 4.12
BOF Average 4.01
Panel Average 3.92
Hands-On Lab Average 4.30
Technical Session Average 4.13
The Sun SPOT Hands On Lab rated a 4.57, the Birds of a Feather (BOF) rated a 4.2, and the Technical Session rated 4.38. All respectable, and well above average.
Thanks to all of you that attended, and gave us such nice feedback!!
[ Mother told me to be good, but she's been wrong before. ]
So this has nothing to do with Sun SPOTs (that I know of anyway), and probably isn't at all revolutionary, but still, it troubles me.
We're spending lots of time and energy on alternatives to fossil fuels for automobiles and power generation, since we (rightly) believe that there is a limited, and ever dwindling, supply of such fuels. I think this is great, and hope we get somewhere fast with this technology or technologies. It will help us with the radical climate change we have caused -- and don't argue with me about that one, I'm not interested in hearing the "I don't believe in climate change" stuff. It's real. Deal with it.
But one thing I have never heard discussed is ... what are we going to use to power jets for air travel? The idea of an electric jet, or a solar-powered jet, just doesn't seem like it's feasible. Is anyone thinking about such a thing? Or are we going to re-expand the world and go back to electric trains and steam ships for long-distance travel?
Just my random thought.
[ If God is perfect, why did He create discontinuous functions? ]
The Sun SPOT Forums have now passed 1k registered users! Might not seem like a big deal to you, but we think it's pretty cool how our little community of Sun SPOT users has grown over the past year. This time last year we had a little over 400 registered users, so this is indeed some pretty strong community growth! And the Sun SPOTs are a community project, so community growth, health and vitality is a great thing!
Speaking of community growth, we'd love to see some more (lots more!) YouTube videos of stuff you're doing with Sun SPOTs. Just remember to tag them with the keyword 'spaughts' so they show up in our You Tube Feed.
[ You don't sew with a fork, so I see no reason to eat with knitting needles.
So one of Arshan's latest interns, Lachlan, is taking his internship seriously and doing cool stuff, and blogging about it. Check it out and give him some blog-love!
[ If you think the United States has stood still, who built the largest shopping center in the world?
So it was pointed out to me today that our forums are teetering on the edge of 1k users. That would be a major milestone for us, as it is, for our little project, a lot of interested users. Of course, I'm still the most prolific poster there, but then again, it's my job, so if I weren't, I'd be in big trouble!
Wonder how long those last few users to get us over the top will take?
[ If you can't be good, be careful. If you can't be careful, give me a call. ]
Ok, so I've been lagging in my blogging a lot recently. Too much else to do. You know, work and stuff. I've fallen off the main page, and my popularity has suffered. Guess I have to get back to regular updates, huh? I got distracted by twitter. But as the reliability and performance of twitter rapidly decrease, maybe I"ll get back to actually blogging.
[ You can't hold a man down without staying down with him.
I got Sun SPOT Certified, now you can too! Just take the Sun SPOTs Course, and pass all the tests. Ok, so you're not 'certified' but you get a certificate (suitable for framing, I hear).
Its a great course, with lots of very good information, well presented, interactive, and informative. And I'm not just saying that. check it out.
[ Every four seconds a woman has a baby. Our problem is to find this woman and stop her. ]
So it's official. I'm now pimping myself out to teach a version of the Hands On Lab I taught at JavaOne this year. Yep, that's right. I'm changing the content somewhat, but the basic premise is the same: Hardware development for Software developers. I'll lead you through the entire process of developing a small wireless sensor application that wireless communicates sensor data (bend sensor) to a remote actuator (servo).
I come complete with the Sun SPOT kits and all the hardware. All you have to do it pay my travel expenses. Unless you're in the Raleigh, NC area. In which case we'll have to come up with some other incentive.
Exotic locations preferred.
[ When more and more people are thrown out of work, unemployment results.
So I just get back from 4 days of blissful ignorance (as opposed to my usual miserable ignorance) to see that Sun SPOTs have made engadget (again). This time for Mike's Flying Bike. If you're too lazy to click any of the links, you can watch the video here:
He was actually supposed to come to the Sun SPOTs BOF at JavaOne, but I think he fell off his bike trying to land at Heathrow or something and got injured.
[ There is no distinctly native American criminal class except Congress.
So there have been some questions recently about what part numbers are the socket and header we use for connecting things to Sun SPOTs. So I thought I'd answer as best I can.
The Sun SPOT kits now ship with a socket, though it is not actually attached to the eDemoBoard (it is in a bag inside the box). That socket is a Samtec connector part SDL-110-T-12 and your SPOT kit should have 2 of them in it already. Unless you were an early adopter, in which case, contact us and we'll get you a couple.
That gives you a socket with 0.018" holes to plug stuff in to. But In order to be able to easily attach things like jumper wires, etc. you will probably need the Samtec connector part TD-110-G-A which will give you a 0.025" Male pin to attach stuff to, rather than the tiny 0.018" female you get from the socket.
[ Everyone is a genius. It's just that some people are too stupid to realize it. ]