Easy Raspberry PI and Sense Hat Datalogger

Decided to have look at the Raspberry PI after reading about the Astro PI project

The Raspberry PI have been around for some time and exist now in several versions. The one I purchased was the Raspberry PI B+

Raspberry PI
Raspberry PI

Together with that I got the Sense Hat module.

Raspberry PI, Sense Hat
Raspberry PI, Sense Hat

Besides these two components, a micro SD (16 GB in my case) is needed and an USB power supply.

Download the linux image and copy it to the SD ( great guide here )

I downloaded NOOBS and installed the image (formatted too many times, really). Then I hooked up the components and inserted the SD card. Added a monitor, keyboard and mouse and finally power.

Initial Raspbian window running on Raspberry PI
Initial Raspbian window running on Raspberry PI

That was easy. I now have a running, working linux system. There were some more steps to do, to get really ready, here is a video of a working system and what the sense HAT module is. (from The Raspberry PI Guy)

I have installed some python packages for interface, database and communication. The process is simple as long as you have connected the Raspberry PI to the net.

Update packages that may be old in the NOOBS image. Open a terminal and enter the following commands


sudo apt-get update
sudo apt-get install sense-hat pillow tightvncserver mysql-server python-mysqldb

References:

https://www.raspberrypi.org/documentation/hardware/sense-hat/

https://www.raspberrypi.org/documentation/remote-access/vnc/

http://raspberrywebserver.com/sql-databases/using-mysql-on-a-raspberry-pi.html

I had some issues with the VNC server, when X: is running then display 0 is already in use. (I choose to use display 10 )

One other important step is to set the password for the PI user if you want to use ssh from a remote system.

Now the system is (almost) ready. Some code is needed to read the data from the Sense HAT and write them in the database.


#!/usr/bin/python
from sense_hat import SenseHat
import time
import MySQLdb
db    = MySQLdb.connect(host="localhost", # your host, usually localhost
user  ="user", # your username
passwd="password", # your password
db    ="database") # name of the data base
cur   = db.cursor()
sense = SenseHat()
temperature = sense.get_temperature()
pressure = sense.get_pressure()
humidity = sense.get_humidity()
# formula see below
temp = round ( 0.0071*temperature*temperature+0.86*temperature-10.0,1)
humidity = round ( humidity*(2.5-0.029*temperature),1)
pressure = round(pressure, 1)
dateTime = time.strftime("%Y%m%d%H%M")
sql="insert into weather(datetime,temp,pressure,humidity) values ('%s','%s','%f','%f','%f');" % (dateTime,temp,pressure,humidity)
cur.execute(sql)
db.commit()
db.close()

Calculation for the temperature. As the sensor is close to processor and led’s the value returned is imprecise. This is the formula to compensate.

It is now possible to get one reading from the Raspberry PI Sense HAT and write it to the database.
201512252355 23.3 978.9 67
201512281740 23.3 972.9 64.1

What Is Internet Of Things

The latest hot topic in IT is the Internet Of Things (IoT), but what is that really?

Simply speaking it is any device that can be connected to the Internet and send or receive commands.

It is not really new, in the sense that we already have many ‘things’ connected to the internet. Computers, disk arrays, printers, bank tellers, video cameras, mobile phones, cars, medical devices, various production machines. The ‘new’ part is that we see a massive number of new Internet enabled devices coming on the market and with them, we are going to make the same errors as we have already done.

Just think about the problems with unauthorised access of your computer, aka, hacking. With the new devices arriving, example intelligent light switches, we will see numerous cases of IoT devices being hacked and abused. One reason is the relative simple designs and interfaces of IoT devices and the cost of building in security.

Hacking is not the only issue facing IoT. Privacy is another. Just like putting your personal data on the Internet and then having to spend a lot of energy to get the ‘wrong’ information out of Google again.

Take the example of temperature control. If you have your house full of temperature sensors and can turn on and off the heating from remote. The sensors will report a daily pattern, like warm between 6am and 8am, warm again from 5pm to 11pm on weekdays and from 7am to 12pm in the weekend. Then you go on vacation and have the heating turned down. The pattern is broken, constant low temperature and that indicates you are not at home. An invitation to burglars.

And what about interfaces? Right now companies like Amazon, MicroSoft, Google, Cisco and others are promoting their API’s which will let the various devices connect to proprietary data collection and monitoring systems.

In the report June 2015  The Internet of Things: Mapping The Value Beyond The Hype by McKinsey, it is found that the economic impact of IoT applications could be from $3.9 trillion to $11.1 trillion per year in 2025.

So it is understandable that all major IT Service Providers are active in this area. This also ties into the offerings of cloud based systems and services. We will be able to collect massive amounts of data, we must store it somewhere and compute it.

But how do we find the relevant data in this wast amount of data. If we take the temperature example, we would want to monitor thresholds and have actions defined when exceeding a threshold. Example, the temperature in a room rises above 38 degree C, 100 degree F. On a summer day it may not be a problem, on a winter day we may have a fire.

The extraction of data will require detailed specifications, in fact this is likely to create way more work than is required at present. So for individual IT people it may be a good thing.

What will happen in the next years is difficult to predict, but it is surely going to be exciting.

Prediction is very difficult, especially about the future.” (unknown)

 

You do not have sufficient permissions to access this page

Updated a friends blog (new Akismet) and then wanted to add a plugin.

Adding the plugin went ok, but trying to activate it I got the following error

“You do not have sufficient permissions to access this page”

Looked in the database and at permissions, googled all over the place. Loads of 5 years old answers.

Hey, Google, you need to update your databases!!!

Wanted to check if the theme was the issue and found that there was no “Edit” link.

Another round of googling and I came across this on wordpress.org

Disable File Editing
The WordPress Dashboard by default allows administrators to edit PHP files, such as plugin and theme files. This is often the first tool an attacker will use if able to login, since it allows code execution. WordPress has a constant to disable editing from Dashboard. Placing this line in wp-config.php is equivalent to removing the ‘edit_themes’, ‘edit_plugins’ and ‘edit_files’ capabilities of all users:

define(‘DISALLOW_FILE_EDIT’, true);

I changed it to

define(‘DISALLOW_FILE_EDIT’, false);

and Edit menu appeared and I could start the plugins.

Since I will probably forget everything about this in a few days, I added it here, so I can find it again.

 

How To Create An Income Using PLR Content

One of the most challenging tasks is keeping your website updated with new content.

There are two immediate reasons for this.

1) You want your readers to come back for more.
2) You want the search engines visiting your site often, to keep the listings fresh.

This takes time and sometime you just don’t have that extra time available.

So this is where PLR (Private Label Right) have a lot of promise.

You can now leverage the time of other people and get a vast collection of information in a short while.

Note, I ma not saying a vast number of articles or postings.

Because, just dumping in the PRL content in your blog is not going to help you.

Your readers may recognise the content from other places, may not recognise your style and voice, and surely the search engines will recognise the contents from other sites and, while they may not penalise you, they are also not going to show your site in the search results.

So, bear in mind, PLR is a great help, but you still need to add your personal touch.

If you are going to use PLR content as an input for your own writing you will need a steady supply, and there are many membership sites where this is possible.

One of these sites is Matt Callen’s simplyplr.com


simply plr

A few extracts from the site.

Matt Callen SimplyPLR Unique PLR Niche Content for Article Marketing

You can get 225 new articles each month.

Matt Callen SimplyPLR Unique PLR Niche Content for Article Marketing
You can monetise the PLR articles with Adsense.

If you build 100 sites that earn $1.00 per day in adsense income you are making $100 dollars per day. When you decide to increase your income, you simply increase the number of sites that you own.

You can use your PLR sites to conduct what is called Arbitrage. This is where you bid on very low paying Pay-Per Click terms to get traffic to your site. Your article site is displaying Googles own ads to the visitors. The visitors that are sent to you by Google click on your ads.

When the visitor clicks on your ads you earn income from Google. You set up your adwords campaign so that you make more on the clicks than you spend on advertising. This is an effective strategy to get traffic to your site.

Another strategy for traffic is to rewrite the PLR articles so that they fit your niche. Submit these articles to the major directories.

The most crucial element of building a moneymaking empire with articles is to have a cohesive plan on the niche that you are targeting.


simply plr

Getting password less login with SSH to work when all hope is lost.

Had access to two servers. On one I could login without password, on the second I could not.
No root access, not that it mattered in this case.

Googled a lot, and everybody told me to

chmod 700 .ssh
chmod 600 .ssh/authorized_keys

and it should work, still the computer said NO …

There was one more thing (!)

SELINUX

To really find out about SELINUX (ask Google)
Checking the SELINUX permissions
[[email protected] ~]$ ls -dZ .ssh .ssh/authorized_keys
drwx——. asbjorn users unconfined_u:object_r:home_root_t:s0 .ssh
-rw——-. asbjorn users unconfined_u:object_r:home_root_t:s0 .ssh/authorized_keys

debug1: Next authentication method: publickey
debug1: Offering public key: [email protected]
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/asbjorn/.ssh/identity
debug1: Trying private key: /home/asbjorn/.ssh/id_rsa
debug1: Trying private key: /home/asbjorn/.ssh/id_dsa
debug1: Next authentication method: password
[email protected]’s password:
debug1: Authentication succeeded (password).
chcon -t user_home_t .ssh .ssh/authorized_keys

[[email protected] ~]$ ls -dZ .ssh .ssh/authorized_keys
drwx——. asbjorn users unconfined_u:object_r:user_home_t:s0 .ssh
-rw——-. asbjorn users unconfined_u:object_r:user_home_t:s0 .ssh/authorized_keys

debug1: Next authentication method: publickey
debug1: Offering public key: [email protected]
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: Authentication succeeded (publickey).
Reference:
Security Enhanced Linux Contexts Labeling Files