Developing on a pi and testing on an arduino

This is somewhat of an admission of failure. You can't easily pigeon-hole everything, and most real projects use commercial software, homebrew, and hardware all at once. So, for you makers out there (including me) - this is where to put whole projects that don't fit well in the other forums.

Developing on a pi and testing on an arduino

Postby Doug Coulter » Tue Nov 18, 2014 10:04 pm

Yup. Just a teaser for now. I recently got a couple new pi B+ cards, and have already had some seeduinos (the seedy version of the arduino uno - ~$3 each if you know where to buy them...). I got a DHT22 temperature/humidity sensor from adafruit, and thought I'd test the accuracy (not too shabby) and response time (glacial) so I can write some "real" code later. Wouldn't it be nice to know the temperature of your plumbing system before it freezes? It's an issue here, since it's in a building I don't use for much else and sometimes it gets cold here in the mountains. Later, I plan to write "real" code for all this and put it on my network, maybe even with early warning-prediction so I don't have to sweat running around heating things if it's not going to be a problem, but get some heads-up ahead of time if it is - for that I need time-constants vs temp diff and windspeed etc and so forth...I'll get that later, right now I'm just testing one of the sensors I want to use (they are cheap).

And for fun, I did all this on the pi itself - perl, gnuplot, the arduino IDE, you name it, all but this post, since right now the pi web browser would like to have a re-boot but I have it busy taking data overnight and streaming live video...it's kind of funny, both the pi and the nuc systems here are totally dominated by the display power draw unless you go to that really dinky/useless one for the pi. We'll have to see about that in the future, as otherwise, either works really well for "no" power, even by my parsimonious standards for that. Though I have to say, the nucs are so much faster than the pi, they'd be used for most of everything themselves that needed any speed. Luckily, this doesn't.

I'll post the code for it all tomorrow after this collection run is over - I plan to let it run overnight. It is, as Bill said, cold as a witches elbow out there, especially for this time of year. We normally have about one day of this, but normally it's in the middle of December. Looks like it's gonna be a cold one.

Here's a plot where I was taking data kinda fast (5 second intervals) and just testing the sensor itself. I went to 1 minute for the overnight run since it's so slow anyway. You can see where after letting it sit on my bed for awhile, I dropped it out the window. It's on one end of a 9 wire flat cable I happened to have some stock of, one wire is +5v, one is data (in the middle) and the rest are ground, and it's about 20' long with a 10k pullup - so these things don't mind a little cable run, cool.

2014-11-18-204404_1600x1200_scrot.png
Screenshot from the pi (scrot) of gnuplot 4.6 running there.


Beer o clock now.

Like I said, more tomorrow, including the code etc. but for now here's the response time plot of the thing. It's pretty obvious where I walked it over to the window and tossed it out, then later brought it back in. Good old exponentials, more or less.

Some might wonder why i work like this. Well, I had a very interruption filled day, so I didn't have the energy to focus on the other stuff on the TODO list like finishing the MCA project or making a new grid, both of which require some mental prep and the right attitude going in...which I didn't have, which is why I have a long list - I just do whatever "is lighting up right now" from a long list, and things get done when they get done. Nice to have the freedom to do that.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Developing on a pi and testing on an arduino

Postby Doug Coulter » Wed Nov 19, 2014 12:22 pm

As promised, I let the thing run overnight on the coldest night here so far this season. When I got up this morning (late, around 10 am), I stopped the run. Since it was cold in here by then (wood heat), I started a couple of gonzo propane heaters to make it tolerable in here, waited for that to happen (it's fast at 200k btu or so), then started another run, pulled the sensor in and set it on the bed, and turned off the propane heaters while I ahem, went to the building next door to use the plumbing (which survived, likely do to my preps and running a blazing fire there, last load at 7 pm). I then started another run and pulled the sensor in and put it on my bed. I saw the usual spike in RH as condensation probabably happened on the sensor, then the usual slow recovery to room temp, which then fell a little as my wood stove in here hadn't yet caught up.

Here are the results.
2014-11-19-103201_1600x1200_scrot.png
overnight




And a zip of the entire thing, including code.
ColdNight.zip
zip of code and data - linux/pi/arduino
(293.87 KiB) Downloaded 358 times


Morning and pulling it back inside:
2014-11-19-120646_1600x1200_scrot.png
This morning - you can see it warm up, then start to cool down again as I'd turned off the heat while waiting for the woodstove to catch up.


I'd love to make an image of the pi as configured and share it, but it's a gb zipped and last time there was a disaster - both dropbox and my "unlimited" ISP shut me down when I tried last time, with only a single download they stopped in the middle (me, testing the upload at 4 mbit/sec). Wow, some unlimited, eh? I'm using a 16 gb micro SD class 4 or better card for the pi. I suppose I could mail them if people sent me a blank one and the usual self-addressed stamped envelope.
It's actually not that bad for minor software work. Yes, the various IDE's (in this case, arduino and geany) take forever to get going, but then...not so bad, as I have a high think to type to compile to test ratio on stuff like this.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Developing on a pi and testing on an arduino

Postby Donovan Ready » Wed Nov 19, 2014 11:26 pm

Host it at my Joint.
Donovan Ready
 
Posts: 239
Joined: Thu Apr 17, 2014 1:22 pm
Location: Austin, Texas

Re: Developing on a pi and testing on an arduino

Postby johnf » Thu Nov 20, 2014 3:29 am

Hi Doug
you should now be able to test it in snow!!
johnf
 
Posts: 433
Joined: Sun Aug 08, 2010 3:51 pm
Location: Wellington New Zealand

Re: Developing on a pi and testing on an arduino

Postby Doug Coulter » Thu Nov 20, 2014 3:37 pm

It missed us, thankfully. It got far too cold for snow here - the water all dropped out far north of me. I do plan to carefully calibrate one to put on my cistern, though, and use excess solar power we sometimes have to store heat there in winter so it won't freeze. I suppose I could put this sensor in a baggie and immerse it in an ice bath to find 0c or whatever water freezes at at this altitude accurately.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Developing on a pi and testing on an arduino

Postby Jerry » Sat Nov 22, 2014 3:14 am

You ought to check out the intel edison. I am using one for work and intel gave us a box of them the other week to play with. These are much more for embedded projects than then Pi, it has no video out for one thing. It has a 500mhz dual core Atom running a linux distro and what is neat is you can have arduino stuff running on top of it at the same time. All on a module the size of my thumb.

Their arduino version is pretty neat too, it comes on a breakout board that has the standard arduino shield headers. To make it compatible they stuck a pretty nice 12bit, 8 channel, 1MS/s ADC on it.
Jerry
 
Posts: 573
Joined: Sun Jul 18, 2010 12:07 am
Location: Beaverton, OR

Re: Developing on a pi and testing on an arduino

Postby Doug Coulter » Wed Nov 26, 2014 10:21 am

Right. Well, the point(s) of a pi:
dirt cheap, a belly button, everyone has one.
Video output - pretty hard to develop code for a machine with no video (far from impossible, but...these days we're spoiled).

Yes, a pi, or for that matter, anything that runs a modern, preemptive opsys, doesn't do well at all for anything time-critical or with hard realtime deadlines. Time slicing means that if you're not at ring-0, you're hosed there.
On the other hand, video, bulk storage and so on make things like that ideal for controlling a farm of little embedded things - arduinos, my PIC board, whatever. That's the point of this, it's dirt cheap, draws almost no power and can control a lot of little arduino-like things. It may as well also provide the development and testing enviornment - testing with the real thing always makes it simpler to implement vs moving code etc back and forth wearing out one's sneakers.

EG, what I'm presenting here is a system, in my case for homestead automation of everything from taking care of the water system(s), solar systems, deciding what to do with any extra power I have; unpredictable when, but there are uses for it from heating the cistern so it doesn't freeze, charging the car, heating the house. That requires high level complex decision making to "just do the right thing" at any given time - perfect for a higher level, slower kind of thing that runs high level languages - a pi, a laptop etc, but the pi wins hands-down over most other options for that. You can cheaply keep hot spares for it's bulk storage taped into the box. It drives common monitors that don't have to be powered up all the time, any USB junk and so on, for human interface. It's the bridge between the human and the dinky little things that measure temperature, control valves, turn inverters and SSRs on and off and so forth. For that, it's hard to find anything else that compares when you have a very serious power budget and are talking about having a "vampire load" on a fully off-grid system. As I get older, learning umpty new boards just isn't worth it over and over and over. The Pi has already demostrated staying power in the real world, they're everywhere, there's a community and so on. Hence that choice, even though yeah, a lot of it is sub-optimal for a general purpose computer. It will still do all that stuff, just not fast.

I now own 3 intel NUCs (and a ton of older machines). If I need to go up in computational power from a pi, and sometimes I do - that's the thing of choice for me. They rock, and share the property of drawing less power than the monitor does, and leave that other stuff in the dust utterly. The one I'm typing on now has 2.5 tb storage (.5 tb is SSD), 8 gigs ram...an i5 haswell, runs two displays...go big or go home! And oh yeah, draws about double the power of a pi. It was a tossup whether I'd use a pi at all instead of another of these (but cost, wow, what a difference! - No keeping spare NUCs around just in case.).

But here we have a set of applications where speed isn't the issue so much as being able to do complex things with smart peripherals (eg other small computer boards) and act as the human interface to those.
FWIW, it's also blinding fast with a direct-connect camera running apache - it can stream HD! Or do time-lapse or motion detection (which doesn't eat much of the pi's few cycles, actually). I don't see that combo out there in other platforms, and if I'm going to do all the work to build this stuff into my homestead, I want something that will be around awhile, or that's so cheap to have a couple hot spares it doesn't matter.

That's my thinking, anyway. Looks like a pi can control a virtually unlimited number of little boards out there via it's built in serial port using a wired-or protocol we developed here (master slave) with them all on the same port - talk when you're spoken to kind of thing, letting the little guys do the hard real-time stuff with a small amount of smarts (limit switches, grab the latest data point an buffer a little, and so on).
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA


Return to Combined projects

Who is online

Users browsing this forum: No registered users and 3 guests