RaspberryPi + LinkMeter blue sky discussion


 
Well avrdude supports SPI transfers via a bitbang interface, but not any Linux spidev interface that I know of. The source I am looking at is avrdude 5.8 though so maybe they've worked it out since then. The source is so generic and config file driven that it can be hard to follow, and the AVR SPI protocol is so dead simple that it was easiest to just implement it myself. I'm sure the reason everyone is using FTDI cables is probably because the default kernel spits out logging on UART0 and I think it may put a getty on it too. Also most people think Arduinos are all 5V, so it is probably for the best that they don't try to hook a 5V arduino to a 3.3V Pi.

There's other data coming out too besides the HMSU sentence every 2 seconds-- configuration data exchange, rf probe statuses, etc. It still isn't much data and 19200 baud is fine. The high baud rate was just to work around various limitations of the platforms, which is funny that now I'm lowering the baud rate to get around the limitations of this new high-performance platform! I checked the Arduino HardwareSerial source code too and thank jeebus it blocks if the serial buffer is full (albeit with a comment that says "???: Should we just return 0" NO!) so there shouldn't be any problem losing information when linkmeterd does its big config query on startup.

I used to update every second back in the very first version of HeaterMeter but when I looked at trying to write a log, first with a connected SPI dataflash chip, then with an XBee transmitter to a logging machine, it became clear that nothing really happens in a second. I was looking toward moving to the Linksys platform, which might only have RAM as storage. A full 1 second log file with all the probes plugged in was like 250kB per hour (moving averages used to also be sent) and we certainly wouldn't have room for more than an hour or two of that.

I picked an RRD file as the storage mechanism and came up with some intervals that made full resolution graphs for the amount of time that BBQs take. The entire storage is 77kB and holds up to 24 hours of data at the largest time slice. You can't update an RRD more than once per second, and if you try to do it every second sometimes you'll end up trying to update in the same second and RRD gets all mad. Given the slow response time of what we're trying to control, I can't see where more frequent updates would be of any use anyway.

The Pi doesn't have a RTC but it does keep time just fine. When the network starts an ntpd syncs the clock to GMT and linkmeterd notices the time skip and recreates the RRD with the new time. The times displayed on the website are adjusted for local time in the browser.
 
I finally got some time with my rPi. Hoping to try the latest linkmeter image this weekend. I'm lacking the rest of the parts of course, and the wifi card....

Is the wifi card you are testing with appropriate? I saw talk of the polyfuses causing problems, then potentially driver issues that seem worked out now... should I get one in the mail? (I'm aware multiple cards will probably work, but I may as well get the same one since the price is right).
 
I finally got some time with my rPi. Hoping to try the latest linkmeter image this weekend. I'm lacking the rest of the parts of course, and the wifi card....

Is the wifi card you are testing with appropriate? I saw talk of the polyfuses causing problems, then potentially driver issues that seem worked out now... should I get one in the mail? (I'm aware multiple cards will probably work, but I may as well get the same one since the price is right).
The sdcard image is in flux, I am still working on shrinking the image and there appears to be a point where if you make the first partition "the wrong size" the Pi doesn't boot at all. I haven't figured out what exactly about the wrong size makes it the wrong size though. I'm going to try to work that out tonight and I'll link a zip file suitable for playing with.

I still like the wifi adapter I've got. It seems to work ok with the polyfuses, and I've tried it on two different rPis, one with the fuses shorted and another with them stock. I have got a problem with the driver I am tracking down where the OpenWrt utility can't do a scan unless wpa_supplicant is already running. Of course, the only way for that to be running is if you're already connected to an AP! The tool tries to create a second virtual adapter off the first and change the mac address but the kernel is returning ENODEV so I'm thinking the virtual adapter creation isn't working properly. I can modify the source to scan on the primary adapter and it works fine so it isn't a problem there. `iw dev wlan0 scan` also works great.

There are still a couple minor issues to work out as well. I need a better way to conditionally compile script files. I use sed to replace some variables, but there's a couple linkmeter scripts that have several lines of difference between them and I want to basically do:
Code:
#ifdef CONFIG_PLATFORM_BCM43XX
  shell command
  shell command
  shell command
#end
#ifdef CONFIG_PLATFLROM_BCM2708
  shell command
  shell command
  shell command
#end
I can't use the C preprocessor because it hates other things with # hashmarks. Anyone know of a... bash shell script... templating method?
 
I can't use the C preprocessor because it hates other things with # hashmarks. Anyone know of a... bash shell script... templating method?

I think 'awk' may do what you need... You can do amazing things with it. I've also used a program called xacro to make dynamic xml files, but I'm not sure it will do what you want for bash scripts.

I'll give it more thought and see what I can come up with.

So, you want to create a slim script that works with one system or the other, rather than keeping a script that checks which you are on and runs the appropriate commands?

Edit:

Here is a decent example with Sed, what is causing you problems using sed?

Code:
$ cat template.txt 
#!/bin/sh

echo Hello, I am a server running from %DIR% and listening for connection at %HOST% on port %PORT%

$ cat create.sh 
#!/bin/sh

sed -e "s;%PORT%;$1;" -e "s;%HOST%;$2;" -e "s;%DIR%;$3;" template.txt > script.sh

$ bash ./create.sh 1986 example.com /tmp
$ bash ./script.sh 
Hello, I am a server running from /tmp and listening for connection at example.com on port 1986
$
 
Last edited:
Bryan, Is the wifi module that you got working the "Rosewill RNX-MiniN2" from your previous posts?

It looks like the Rosewill RNX-MiniN1 is a lot smaller...
 
Yeah it is easier to determine the type of system at build time rather than at runtime. I can use /proc/cpuinfo to figure it out but it would be a couple commands due to the fact that the formats of the two cpuinfos aren't the same across platforms. That would mean that each script would need to have this code copied into it or each would have to load a function script which starts to get a little convoluted and/or have duplicated code. I'm not a fan of having the same thing in multiple places because keeping it in sync is problematic.

You can see in the current Makefile I used sed to do variable replacement but I need to have whole separate commands per platform and I'd like to have the source of both in the actual file rather than in the Makefile. I considered having a script that runs through all the directories and cuts out anything between some tags but that method would only work for two conditions. I was hoping there would be a way to build with multiple defines and have it work like the C preprocessor.

The fallback option would be to have a script run on firstrun that figures out the target system then stores it in UCI config that things can then reference and then do it at runtime.

I have both the RNX-MiniN2 and Edimax EW-7811Un working. I bought the N2 over the N1 because I thought because it was roughly the size of a 1/4 wavelength 2.4GHz antenna, it would have better reception over the teeny tiny module. They both report roughly the same RSSI though so I'd recommend the Edimax. Both use the rtl8192cu chipset.
 
Here's a working OpenWrt RaspberryPi HeaterMeter LinkMeter build zip file:
http://home.capnbry.net:22674/rpi/

  • Grab openwrt-rpi.zip
  • Uncompress the img file in it
  • On Windows use Win32DiskImager to write it to an SD card. On Linux, just use `dd` to blast it to the sd device.

I go to San Francisco for work and come back to discover they changed the forum. Now I will try to digest what you and Evan MJ were talking about.

I cannot believe how fast OpenWRT runs on the Pi...amazing! When I left for San Fran I was almost done with my SMD board design. I am moving to NC next week so I am probably going to wait to do anything else on my design until you test your latest board (should be b28a489).
 
I *know* it is shocking, right? LuCI seems to be a lot more stable too, everything actually works rather than hanging for a minute then never coming back!

The tons of storage space and RAM also also allow a few other neat features, like if you're on a Mac with that image you'll see LinkMeter show up in the network browser (via the Bonjour service discovery protocol). I'm also working on having it show up in Windows' network devices but that is a little less straight forward. I didn't mention it elsewhere in the thread but I've also got all the packages working using full hardware floating point which makes some things marginally faster.

My boards are already in the mail to me, so hopefully I will have them Tuesday or Wednesday and have a chance to slap one together before I leave for a little holiday next weekend. Moving from Seattle to North Carolina? Some people will do anything for better BBQ! Good luck with your move, Dave, that's a big one.
 
Bryan,
If I get myself a rPi can I use it with my v3.1 board? I would think all we need is the serial connection to hook them together?

thanks
dave
 
Theoretically I don't see any reason why it wouldn't work. You're going to have to run two separate power connectors to it though, unless you swap out the LM7805 with a switching regulator like the Murata. Haha "On Backorder" oh Mouser. Do you ever stock anything I want? Digikey carries it too,
 
Moving from Seattle to North Carolina? Some people will do anything for better BBQ! Good luck with your move, Dave, that's a big one.

Haha doesn't seem like a logical choice does it? I am from North Carolina. I have been on the west coast for about four years (2.5 years in Alaska and 1.5 years in Seattle). My wife and I are with child now so we are trying to get closer to my mom. The BBQ is the perk. I work as a civilian for the U.S. Army Corps of Engineers so the move is no big deal because they pack it and move your stuff for you. I also get 9 days paid travel to drive to NC so my wife and I are going to hit up a handful of National Parks on the way.

So what is the final word on the wireless adapter? The EDIMAX EW-7811Un is supper cheap on newegg.com ($9.99 w/ free shipping). Is this your choice adapter? It looks like the reviews are pretty good and from what I can tell the company that makes the adapter has very good customer support (they respond to all complaints on neweggs website).

I see you have another programmer reading the forum (Evan). I wish I was more than just a groupie.

I found a super low profile mono jack (0.399mm) for my board (http://www.mouser.com/ProductDetail...cPJWgAPNrd3whO8UJJQVHZNcHln21bIrOv9O/%2bahvg=). I had to make the part in eagle for it which was fun to learn but not intuitive at all.
 
Last edited:
I love the National Park system myself. I spent the Spring of last year hiking in Olympic and the Cascades although there was still snow over 10 feet thick in some of the higher elevations which my better Florida-boy judgement told me to keep away from.

I'm going to make that EDIMAX EW-7811Un work for sure. The only issue right now is that the OpenWrt "scan" only works after it is already connected. I can patch in a workaround but I'd rather get it working they way that OpenWrt wants it. Amazon had it for $9.99 too, but I think they're selling a lot of them due to all the Pi people snatching them up and they adjust their prices based on demand. I haven't had any issues with it once it is connected (and scanning with the standard `iw` tool works too, just not OpenWrt's way) so I'm confident it will be dependable.

Nothing in EAGLE is very intuitive. I had built a few parts for HeaterMeter some months ago and when I had to make some new parts for the 4.0 board, I once again had to go through figuring it out what was what all over again. That jack is teeny! Then again, I'm sure most of your parts are pretty teeny.
 
I see you have another programmer reading the forum (Evan). I wish I was more than just a groupie.
Dave,
Though I am a programmer by trade, I am more than a bit behind on the Linux embedded stuff. I'm trying to learn more, which is the main reason I'm interested in this project. Bryan did all the hard work up front, so I can learn from what he has found out, and benefit from his code base. I have plans for automating a greenhouse in similar fashion, and I think internet based monitoring and control is really appealing when it can be done for under $100.

I have 10+ years of linux experience, but it has been spread out across a lot of different things, none of which were embedded, so I'm a bit behind the curve. I'm working on getting up to speed though, hopefully I can contribute something useful soon.

Edimax is up to $12! Breaking the bank. I should have ordered last week :p
 
Last edited:
Dave,
Though I am a programmer by trade, I am more than a bit behind on the Linux embedded stuff. I'm trying to learn more, which is the main reason I'm interested in this project. Bryan did all the hard work up front, so I can learn from what he has found out, and benefit from his code base. I have plans for automating a greenhouse in similar fashion, and I think internet based monitoring and control is really appealing when it can be done for under $100.

I have 10+ years of linux experience, but it has been spread out across a lot of different things, none of which were embedded, so I'm a bit behind the curve. I'm working on getting up to speed though, hopefully I can contribute something useful soon.

Edimax is up to $12! Breaking the bank. I should have ordered last week :p

I replied to a post over at the Arduino forums. Someone wanted to use a router for Greenhouse monitoring, so i told him that this would give him what he was looking for.
 
I'm pretty stoked about the rPi as well. My goal has always been to create a meat curing controller. It is my next project to undertake and starting with what Bryan has here is a big help. For meat curing you have to control humidity and air flow as well has temperature. Just a few more sensors and you're good to go.

dave
 
I'm pretty stoked about the rPi as well. My goal has always been to create a meat curing controller. It is my next project to undertake and starting with what Bryan has here is a big help. For meat curing you have to control humidity and air flow as well has temperature. Just a few more sensors and you're good to go.
dave

Hey! RoundRock, TX. I'm in Buda, TX.

We should try to avoid hijacking the thread, we do have a subforum after all.... but hopefully the rPi will allow us some headroom to extend the heatermeter to other "environment" control/monitoring.
 
Bryan,

What OS do you develop in? I was going to get a VM up and running. Not having any luck at home getting things done from the rPi side, I thought I'd get the dev environment up and running. Debian Squeeze 32bit seems fine from the OpenWRT guides, but you probably have some guidance that will save me lots of time :)

Thanks.
 

 

Back
Top