Tag Archives: thingspeak
In Part 1 of this, I went over the setup of ThingSpeak and several associated and almost-associated packages.
This part will be more about the funner stuff.
Rain Gauge Reader
The first thing I had to do was build a rain gauge reader. I ultimately started that before doing part one, but then moved on to a standalone node.js program that counted clicks from the rain gauge.
The rain gauge is a tipping-bucket rain gauge that tips when the rain gets to 0.2mm. The guts are in the picture below.
The rain gauge initially came with a little board that has a PIC and an EEPROM that stored clicks. I didn’t care for that idea, since the ultimate plan is to see if we can put this on our building’s roof with a battery and a solar panel.
This is where the BBB comes in. I connected the rain gauge to the BBB and started playing with node.js until I came up with the program in the gist below.
After setting it up, it was time to test.
The third part of this will be making this fault-tolerant: fixing the time issue (it doesn’t keep time), starting things during startup, and security.
-73-
Recently, a coworker brought a raingauge to me that was collecting dust somewhere in a storage room at the office. After making it work, I thought that I could certainly rebuild it. Better. Faster. With a much cooler interface.
I also thought that this might be a damn good opportunity for my BeagleBoard Black.
Setup
There are a few initial things that need to be done:
ntpdate time.nist.gov
opkg update
opkg upgrade
These commands set the date and time, update the available package listing, and upgrade all installed packages to the latest version.
The next thing I did was edit /lib/systemd/system/bonescript.socket and change the listening port to 8080. This will break the connection between the board and the website (so you can’t click the buttons on some of the programming example pages and make the LEDs blink… which I admit is a pretty cool feature). Cloud9 will still remain on port #3000. More on that later.
Additionally, I changed /usr/lib/node_modules/bonescript/server.js to port 8080. This was really to try and maintain the connection between the board hardware and the website. It didn’t work, but I wanted things off of port 80 so port 80 could be used for a website.
After all this I rebooted the board.
When it came back up, I lost internet access to the board, so I edited /etc/resolv.conf to add the local DNS server in my office.
After that, I ran several installs:
opkg install mysql5
opkg install lighttpd
opkg install php php-cgi php-cli
opkg install lighttpd-module-fastcgi
Next, I edited the lighttpd config files per this blog post. Once those were edited, I restarted lighttpd and brought up my version of index.php (which included the phpinfo() command to show me that PHP was working).
Ruby & ThingSpeak Installation
I installed Ruby and got the Thingspeak source from GitHub (I created some folders for this, I’m assuming if you’ve made it down here you can figure that part out):
opkg install ruby ruby-dev
git clone git@github.com:iobridge/thingspeak.git
gem install bundle
Then I went to the GitHub project page to follow the instructions to install ThingSpeak. I ran into several problems. One of them related to a file not being able to find assert.h. I fixed this by setting the C_INCLUDE_PATH variable:
export C_INCLUDE_PATH=/usr/include
The next problem wasn’t so easy. The linker was having a problem finding one the libgcc_s library. I ultimately fixed this by linking /usr/lib/libgcc_s.so to /lib/libgcc_s.so.1:
ln -s /lib/libgcc_s.so.1 /usr/lib/libgcc_s.so
Then, I started getting “Command not found” for /usr/bin/mkdir. That was sort of a “WTF?” moment, considering I created a folder for the ThingSpeak source earlier. I figured it must be hard-coded to use /usr/bin and the mkdir command was in /bin. More symbolic links:
ln -s /bin/mkdir /usr/bin/mkdir
Once these symbolic links were in place, I was able to get further in the “bundle install” process, only stopping thrice for the following missing items:
opkg install libmysqlclient-r-dev
opkg install libxml2-dev
opkg install libxslt-dev
After these three items are installed, I could bring up ThingSpeak by running:
rails server -d -p 3001
And bringing up http://localhost:3001
In the next post, I’m going to get into the rest of what I was doing.
-73-