Raspberry Pi and Sensor Tag

image
A while back I documented my first ride with Raspberry Pi. Most recently I wanted to put together a simple system to do data collection from multiple small IoT devices.
The key objective was to collect data from a Sensor Tag then run the data through some R code and to generate insights and some plots that could be reviewed through a website hosted on the Pi.
Today I started putting together this project and I am documenting as I go through the exercise. Here is what I need to do:
  1. Configure and Update the RPI
  2. Install NodeJS
  3. Build a script in Node that retrieves data from one or more sensors
  4. Add database support where data can be stored
  5. Install R server to run scripts on a daily basis
  6. Wrap it up & testing
Since it’s going to be a big project to put together just in one day I will blog as I learn and make progress about it. This get it installed on the system
sudo apt-get install tux
and just running tmux starts the session. Now, if your SSH connection is interrupted, you can reconnect and use tmux attach to continue the shell session.
If you are going to follow the instructions below through a secure shell then you want to install tmux which lets you resume the session from where you left it in case you drop the connection for whatever reason.

Configure and Update RPI

By default, the PI auto logins you can disable that using the configuration tool. Just runt the following command from the CLI
sudo raspi-config
The update task is pretty simple just it might take some downloading time
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
At this point It is worth to check what version of hardware you are using as some commands might have dependencies on that. A quick way of doing it is to type
cat /proc/cpuinfo
image
That is what mine looks like. The output tells us a few things about this Raspberry Pi: It has a processor based on the ARM architecture, the processor uses the ARMv6 instruction set, and that the processor is the BCM2708, which is from Broadcom.
There’re other means of getting the same info and on this thread, you can some of that. If you want to dig deeper into system information then check this excellent write-up.
The next part is to add support for Bluetooth so that we can connect to the sensor-enabled device. I followed the instructions from this well-done video to get that going. The part that you care starts at minute 3:30
Watch the video for extra details but for the lazy ones or more advanced users :-) the installation boils down to the following commands
sudo apt-get install bluetooth blues blueman 
lsusb
hciconfig hci0 up
If you run into troubles after running the command hciconfig hci0 up, specifically you get “no such device” that means that you are either relying on a USB hub that doesn’t carry enough power or your device might not be supported. Try to place the dongle straight into the RPi for the first instance or try a more common USB BT dongle for the latter case. I found the Cambridge Silicon Radio being painless in my experience.

Install NodeJS

sudo dpkg -i node_latest_armhf.deb
node -v  
The last command is to check that everything went well. You could save some time from installing a distro of Linux that comes already with Node and MongoDB, that is Archilinux. I wanted to learn and set up my own path so I chose to not do that.

Next

In the next post, we’re going over the testing of the Sensor Tag via the Gatt Tool and the code for reading the data from the tag.

Comments

Popular posts from this blog

Zen-inification - The art of decluttering

Postgres on Synology

The Making of Basculo