Adafruit, code

For vendors who sell new stuff.
Forum rules
This is for links to mainstream, long established vendors you like -- or you don't, please comment on the service you've gotten from them in the past either way. Ebay stuff goes on surplus subforum, even if they are an "official ebay store" as most of those are more or less surplus vendors who cannot get more after they run out of something -- even if what they are selling is "new".

Adafruit, code

Postby Doug Coulter » Mon Nov 14, 2016 11:35 am

I use and like Adafruit for a lot of small computer supplies. While not always the cheapest out there, there is a good reason - they put in the work to make things work (drivers and breakout boards for new tech that'd be a PITA to do yourself), and have a lot better customer service than some unknown guy in China....
I'm also posting on their forums, and mentioning some things here. To make it easier for those guys, I am putting some of the code I describe (in both places) in this thread so I can link back to it easily from posts "over there", in this case where I post as dcfusor (which is also my gmail address). I will put code examples for their products that I use in this thread as I get around to it. My forums are sometimes getting to large for me to maintain and keep up to date on some things, so I'm just making some shortcuts for that here.
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: 3056
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Adafruit, code - batbox

Postby Doug Coulter » Mon Nov 14, 2016 12:53 pm

Here's the code for the battery box pi and arduino. I don't have (never made) detailed schematics or a step by step tutorial for much of this, as this is intended for the more advanced maker type who will inevitably have to change a bunch of it anyway. Instead of wasting my time on that, I'm onto doing the next cool thing (I don't get paid for this - see all the ads? No? Guess what...there aren't any).
All my stuff is GPL_V2 - share and enjoy.
Here is the arduino sketch for the uno/metro in the box. I'm using an a/d to look at a shunt that sees net battery amperes (which has somewhat of a tempco and is on a heatsink anyway), a MAX 31855 glued to the cylinder head of a water cooled Listeroid diesel generator under some insulation as a way to monitor the engine temperature so as to control a coolant pump - there's no thermostat in this 1908 design - and a radiator fan (the radiator is from an MG, don't ask, I didn't build this thing, I use use it). I'm using a one-wire DS 18b20 temperature sensor down between the battery cells for that reading. I'm using the cold junction reading from the MAX to know the battery box temperature, and the pi itself knows its internal temperature. Hopefully you can figure out the rest....
This arduino mostly just spits out data on the usb serial port, which is looked at by its master pi in the same box, and stuffed into a mysql database there. CGI programs run from NGINX then grab data from this, create plots using gnuplot, and serve up the webpage you see in the examples. (that code will go here too, as much of it as I can manage). Arduino first:
Arduino sketch for the batbox "thing".
(4.56 KiB) Downloaded 58 times

Moving on to the's running my LANDNS stuff, tellem and tellme, which are started in /etc/rc.local along with the program that talks to the arduino. Here's that file:
/etc/rc.local file for the batbox pi
(355 Bytes) Downloaded 112 times

Here's the link to the landns stuff - be sure to read to the end. You can ignore my auto install, it doesn't work on later versions. You probably want the latest version of tellem (at the very end of the thread) and any tellme (there's a zip earl on). The later version of tellem doesn't hang if for whatever reason you lose connectivity (eg you're wireless). Earlier versions did.
You just put these in /usr/bin and chmod 6711 both of them before trying to start them from rc.local. They are already daemons so they play nice with the world.
viewtopic.php?f=33&t=687 (landns stuff)

Here is the pi program that reads the arduino data and stuffs it into the database:
Yes, it's perl....but it's not line noise at all
(3.65 KiB) Downloaded 57 times

I'll get to putting up an sql schema at some's just one table at any rate. Putting mysql on a pi is beneath the scope of this (but really easy - you shouldn't need my help with that part).

Here's the contents of batbox's /usr/share/nginx (the web content). Note that a symlink to its phpmyadmin install didn't make it over. To get that, you basically install phpmyadmin and skip all the webserver choices (which at that point anyway, didn't include NGINX), and then make a symlink from wherever phpmyadmin was to the appropriate place here - a link to the whole root dir of phpmyadmin will do, NGINX will find its index.php in there. The stuff:
This dir goes under /usr/share/nginx in my lashup
(143.65 KiB) Downloaded 55 times

How to put in NGINX and configure it (there's a good tutorial for Wheezy, some additions here I explain that you need for Jessie, and pixel required no changes from there - read the whole thread!) and LANDNS (including a newer more robust version).

Why did I use NGINX? Because it totally kicks butt over all the other options I'm aware of and I don't have a ton of effort invested in Apache (too heavy) or the others. This was easy to learn for me.

Again, this is not for beginners who need a step by step, this is an outline of how "someone who really does this stuff - does it".
This link might be of general interest as it chronicles the start of all this: viewtopic.php?f=59&t=904&hilit=landns+v.97

I think you can see why I'm not bombing Ada's forums with all this, just linking here from there. This is really for the more-advanced audience, not the noob they are more patient with than I can afford time to do. My hope is this will help someone cross that line from noob to...well, something better.
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: 3056
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Return to Mainstream, new stuff

Who is online

Users browsing this forum: No registered users and 1 guest