Tag Archives: internet of things
I've run into a situation where I need to be able to read a temperature with my Beaglebone Black (I really don't care about humidity). After setting up the sensor on my Rpi, a few have emailed me and asked about doing the same for a BBB, and I haven't had much by way of response. The file that I previously used didn't work on a BBB.
On the Beaglebone Black, there are a few preparation items that must be completed:
1: Make sure you have Internet connectivity (I had to add DNS servers to /etc/resolv.conf)
3: Make sure Python and some Python tools are installed:
opkg install python
opkg install python-pip python-setuptools python-smbus python-misc
4: Install the Adafruit BBIO Python tools:
pip install Adafruit_BBIO
5: Follow LadyAda's steps to install
At this point, you can connect the sensor, make sure to use SYS_5V (P9 7 or 8) and not VDD_5V.
At this point, you can go into the examples and it should work... in Centigrade:
...which is great for those of you that use that standard, but in America we use Fahrenheit, which is a pretty simple code change that you can see in my fork on Github.
At this point, a mix of Python and Cron would make this able to send data to ThingSpeak, Xively, Phant, or any of the other IOT logging services (which may become a future blog post).
PS: for full disclosure, I'm looking at this because I've been brewing beer and I'd like to THINK my basement temperature is under control, but with temperatures possibly starting to fall in my area I'd like to keep a better eye on it. 🙂
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.
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.
There are a few initial things that need to be done:
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 firstname.lastname@example.org: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:
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.
I am trying to have a green thumb. Right now, it is more of a pale yellow with a hint of orange. One thing I thought about doing was a temperature logger for plants that I'm starting and will be transplanted outside in mid-April, after the frost season ends in this area.
I initially thought about using an Arduino, but connecting the Arduino to my network would have required me to buy an Ethernet shield or a Wifi shield, both of which are quite expensive. I happen to have a USB wifi adapter hanging around and a Raspberry Pi that wasn't being used. Match made in heaven!
So the first thing I did was go search around on the Internet and found something from Adafruit that included source code and a hookup diagram for a DHT22 temperature and humidity sensor. Mine is an RHT03, which is similar.
I did find that my RHT03 does not run with 3.3v, so I changed the power rail to 5V, and viola!
The next thing I looked at was the source code. I made one minor change and recompiled - I edited everywhere where I saw temperature in Centigrade and changed it to Fahrenheit.
So the next step was to make it easy to get to. I don't want to log in to my Raspberry Pi via SSH terminal just to check the temperature. So I decided that it seems Node.JS is the way to go because I can very easily write a web server for it.
Nice and simple. And of course, the code:
UPDATE: I've had this running a few days, and realized that it seems Node.js does not like to update as fast as I would like. In fact, it doesn't update until I restart the server... not sure what to do about that, but it drastically limits the usefulness of that tool as a solution in this situation.