Skip navigation
2017

We launched the new BitScope Blade product range exclusively with element14 last week. To help explain how BitScope Blade works and what you can use it for, we'll be publishing a series of posts, of which this is the first, describing some example applications that can benefit from using Blade to power and mount Raspberry Pi, sometimes in quite challenging circumstances.

 

In this case, a team lead by Prabesh Sapkota and Binod Kandel from the Robotics Association of Nepal↗ built a battery backed solar powered weather station at very low cost using BitScope Blade UnoBitScope Blade Uno, Raspberry Pi and Arduino. The result of a series of STEM workshops created and lead by Australian educator Michelle Jensen↗ in 2016 and run with the help of Nepalese enthusiasts, this amazing project showed how BitScope Blade can be used to power electronics and computers in remote areas without access to reliable power.

 

Why did they do this?

GF10B-prabesh-sapkota-bitscope-blade-uno-nepal.jpg

Weather forecasting in Nepal is difficult because there is no national weather service and the high mountains produce highly variable conditions within just a few kilometres. A reliable and inexpensive weather station is therefore a vital tool for farmers and those living in remote villages. The weather station design had to be very low cost, reliable, easy to maintain, operate on solar power and use readily available motorcycle batteries for when the sun does not shine.

 

Raspberry Pi, BitScope Blade and Arduino

Clearly Raspberry Pi and Arduino are ideal as the basis for building a system like this. The problem for both platforms is how to get a reliable source of uninterrupted 5V power to run them.

GF10B-raspberry-pi-bitscope-arduino-nepal.jpg

BitScope Blade Uno offered the perfect solution, powering the Raspberry Pi directly and the Arduino via one of its auxiliary power ports. Shown here are the core components put together initially as a prototype with a breadboard just to prove it all worked when powered from a 12V source. It did, so Prabesh and Binod pulled together all other materials required:

  1. Arduino UNO
  2. Raspberry Pi 3
  3. Raspberry Pi 7" Touch Screen Display
  4. GPS Module (NEO-6M-0-001)
  5. Pressure sensor (BMP180)
  6. Humidity sensor (DHT11)
  7. 12V Lead Acid Battery
  8. 20 Watt Solar Panel
  9. Hall Effect Sensor (anemometer)
  10. Reed Switch (8 pcs) (wind direction)
  11. PVC pipes, wood, bearings
  12. PCB (Printed Circuit Board)

The Weather Station has sensors for temperature, barometric pressure, humidity, wind direction and speed as well GPS coordinates. All the sensors are connected to the Arduino to record data which is then sent to the Raspberry Pi for capture and display on a dashboard. Prabesh and his team wrote the weather station software and created the display dashboard all running in Raspbian Jessie for the Raspberry Pi.

 

Building the Prototype

GF10B-binod-kandel-bitscope-blade-uno-nepal.jpg

Binod built the prototype assembling all the electronics using the breadboard before the PCB was ready.

 

Key to the project was BitScope Blade Uno because without it, it would not have been possible to power the system. When deployed, power is provided by a 12V lead acid motorcycle battery. A 20 Watt solar panel charges the battery and can also provide direct power.

 

As the sunlight varies during the day and as the battery charges and discharges, the supply voltage in a simple system like this can vary considerably. The system works well because BitScope Blade has an efficient built-in voltage regulator to manage the variable supply accepting any input voltage from 9V to 48V and producing a reliable 5V at up to 4A output for the Raspberry Pi, Arduino and all the sensor electronics. As Prabesh said, "The Weather Station would not be possible without the Blade. It made the whole project for us."

 

Weather Station One

With all the components assembled and testing the first weather station was installed.

GF10B-weather-station-one-bitscope-blade.jpg

The assembly was mounted on the roof.

The electronics was housed in a simple waterproof plastic container and the 12V battery positioned beside it under the adjoining roof.

The solar panel was mounted beside the electronics and the anemometer for wind speed and the wind vane for wind direction mounted on wooden panels next to it.

It was a fascinating and highly educational experience for the people involved.

Having proven reliable in operation since September 2016, the team are now planning to run a series of regional workshops on basic electronics with the assistance of their Australian sponsors and install more weather stations in rural schools and remote areas. Arduino made connecting and using the sensors easy. Raspberry Pi was at the heart of the monitoring and display system and BitScope Blade Uno provided the platform required to mount the Raspberry Pi and power the Pi, Arduino and all sensors. All that was required was a 20W solar panel and a standard 12V lead acid motorcycle battery (as the uninterruptible power supply battery) to run the station 24x7.

Raspberry Pi is increasingly popular in developing countries but reliable power is often not available. Blade offers a low cost solution enabling the use of Raspberry Pi and other electronics when grid or other power sources are unreliable.

Post reprinted with permission from the BitScope Blog↗.

Having had some fun playing with the display on the Sense Hat I moved on to trying to utilise the Joystick. However copying the examples set out in the Sense Hat API results in the following error

 

AttributeError: 'SenseHat' object has no attribute 'stick'

 

Upon further investigation it turns out that the sense_hat.py library doesn't include any functionality for the joystick, trying to run sudo apt remove --purge sense-hat then sudo apt-get update and sudo apt-get install sense-hat only installs the same version without the joystick functions.

 

Navigating to the github repositories shows that there is an updated version that does include the joystick functions, to get the updates were going to have to manually install them.

 

Time to implement the update!!

 

Step 1.

 

Open up a terminal on the Raspberry Pi (or if your going over ssh just use the terminal your already in).

 

Navigate to the sense_hat python directory

cd /usr/lib/python2.7/dist-packages/sense_hat

 

delete the existing files

sudo rm __init__.py sense_hat.py __init__.pyc sense_hat.pyc

 

Step 2.

 

Download the new files straight from github

 

sudo wget https://raw.githubusercontent.com/RPi-Distro/python-sense-hat/master/sense_hat/__init__.py 
sudo wget https://raw.githubusercontent.com/RPi-Distro/python-sense-hat/master/sense_hat/sense_hat.py 
sudo wget https://raw.githubusercontent.com/RPi-Distro/python-sense-hat/master/sense_hat/stick.py 

 

Step 3.

 

We just need to make a slight alteration to the sense_hat.py file that was downloaded, open the file using nano:

sudo nano sense_hat.py

 

 

Line 17 (highlighted in the picture below) reads

 

from .stick import SenseStick

 

the .  needs deleting from in front of the work stick so it reads:

from stick import SenseStick

 

Press ctrl+o then enter to save changes and ctrl+x to exit nano.

 

shpy.png

 

Thats it! happy playing!!

 

Here's an example code and video showing how to move a pixel around using the joystick:

 

from sense_hat import SenseHat
sense = SenseHat()

x = 3
y = 3

def draw_dot():
 sense.clear()
 sense.set_pixel(x,y,255,90,90)

def pushed_up():
 global y
 y = y - 1
 if y < 0:
  y = 0
 draw_dot()

def pushed_down():
 global y
 y = y + 1
 if y > 7:
  y = 7
 draw_dot()

def pushed_left():
 global x
 x = x - 1
 if x < 0:
  x = 0
 draw_dot()

def pushed_right():
 global x
 x = x + 1
 if x > 7:
  x = 7
 draw_dot()

sense.stick.direction_up = pushed_up
sense.stick.direction_down = pushed_down
sense.stick.direction_left = pushed_left
sense.stick.direction_right = pushed_right

draw_dot()