Bee Stock Hive Logger (weight, temperature, humidity, light) via 2G/3G using GSM Sim900

Inspired by the demand of a working collegue of mine, who has a few bee populations, I developed a small Arduino based device which:

– measures weight, temperatures (in bee stock, outside, in electronics box), humidity, light intensity, battery voltage
– does temperature compensation for weight result
– transfers results via 2G/3G network to a backend server
– goes into a deep sleep to save energy (because we have to use a battery, because of offsite installation on field/ in forrest)

There are a few comparable projects out there in the hackerspace, which did not fit our requirements, but were used as inspiration regarding different aspects:
http://beelogger.de
http://makezine.com/projects/bees-sensors-monitor-hive-health/

A PCB was created to connect all the components in a clean way (the breadboard was horrible in the end):
– Arduino Pro Mini (I removed the power led to safe power)
– Pololu 5V, 500mA Step-Down Voltage Regulator D24V5F5 (to power the Arduino directly and efficient with 5V)
– Pololu 5V, 2.5A Step-Down Voltage Regulator D24V22F5 (to power all sensors and the Sim900 and shut them down via the POWER-EN pin of the regulator)
– Sim900 GSM module (connected via pin header)
– 2x HX711 breakout boards as we use two weight cells (via pin header)
– DS18B20 temperature sensor on pcb (for temperature directly at electronics; for temperature compensation)
– DS18B20 IP67 with cable (for temperature inside stock)
– DHT21/DHT22 with cable (for outside temperature/humidity; for temperature compensation)
– voltage divider (for battery voltage monitoring)
-Luxmeter BH1750FVI via I2C

The working procedure will be:
– wakeup from sleep, powering up devices, waiting 20sec for let them come up
– communicate sim pin to Sim900 module to let it search for cellular network and login
– performing 5 measurements with a delay of about 10 secs, calculation the median of each value
– dial into internet with Sim900, transferring data to Thingspeak via http-URL-call
– shutting down devices, bring Arduino into deep sleep for 1h

The Sim900 module needs to be prepared (correct band selection, fixed baudrate 4800) as described here: https://kaistech.wordpress.com/2016/05/22/http-request-e-g-to-thingspeak-using-arduino-and-sim900-gsm-module/

The first version of the PCB is currently in production at OSH Park and looking like this:

65aa4df3404e60227c951c14b5d122e1

I will post pictures of the assembly after building it up. When confirmed to work properly, I will publish the schematic as well the Arduino code here.

HTTP Request (e.g. to Thingspeak) using Arduino and Sim900 GSM Module

Sim900 module connected to Arduino
– Sim900 GND to Power-Supply GND
– Sim900 5V to Power-Supply 5V (not Arduino 5V, can be up to 2A!)
– Sim900 GND to Arduino GND
– Sim900 TXD to Arduino PIN 2
– Sim900 RXD to Arduino PIN 3

Using a Softserial passthrough sketch @4800baud

Initial configuration using AT commands


//Set to European Mode 900/1800
AT+CBAND="EGSM_DCS_MODE"
//Set to fixed Baudrate 4800
AT+IPR=4800

AT-Command-Set for HTTP-request


AT
//Should reply ok if ready

//Unlocking SIM
AT+CPIN=1234

//AT+CPIN?

//Should reply +CREG: 0,1 if ok
AT+CREG?

//Configure bearer 1 (change to your datat; this is for Congstar Germany by T-Mobile)
AT+SAPBR=3,1,"Contype","GPRS"
AT+SAPBR=3,1,"APN","internet.t-mobile"
AT+SAPBR=3,1,"USER","t-mobile"
AT+SAPBR=3,1,"PWD","tm"

//Open bearer 1
AT+SAPBR=1,1

//Check bearer 1 (should reply IP)
AT+SAPBR=2,1

//Start HTTP using bearer 1
AT+HTTPINIT
AT+HTTPPARA="CID",1

AT+HTTPPARA="URL","http://api.thingspeak.com/update?api_key=1234&field1=1&field2=12"

//HTTP GET
AT+HTTPACTION=0

//Echo HTTP response
//AT+HTTPREAD

Raspberry as RTL SDR server

First of all blacklist DVB-T module:
sudo nano /etc/modprobe.d/rtl-sdr-blacklist.conf

Add to file:
blacklist dvb_usb_rtl28xxu
blacklist e4000
blacklist rtl2832

Then based on
http://photobyte.org/using-the-raspberry-pi-as-an-rtl-sdr-dongle-server/
http://www.hamradioscience.com/raspberry-pi-as-remote-server-for-rtl2832u-sdr/

sudo apt-get install -y git cmake pkg-config libusb-1.0 build-essential

git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr/
mkdir build
cd build
cmake ../ -DINSTALL_UDEV_RULES=ON
make
sudo make install
sudo ldconfig

sudo reboot

rtl_test -t

rtl_tcp -a IPofRaspi

WiFi WLAN on Raspi

Just a reminder to myself how to set it up 🙂

Based on: https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

Scan and show networks:
sudo iwlist wlan0 scan

Add network:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add to file:
network={
ssid=”The_ESSID_from_earlier”
psk=”Your_wifi_password”
}

Then do a
sudo ifdown wlan0
sudo ifup wlan0

Check if it connected and git IP:
ifconfig wlan0

DVB-T Live TV on Fire TV with Kodi using Raspi Raspbian Jessie, tvheadend, RTL2832U

Today I made my first steps playing around with the PVR (Live TV) capability of Kodi. My personal target is, to eliminate the additional sat receiver I have connected to my TV and add a recording feature.

To set up and test the general funcionality, I deceided to use a RTL-SDR (RTL2832U) I already own. The setup works as follows:

TV-Tuner usb stick (DVB-T, DVB-S etc) -> Raspi2 with tvheadend server -> network -> Kodi (on FireTV)

Lets start…

Update system

In general its not a bad idea to get the latest updates:
sudo apt-get update && sudo apt-get upgrade

Setup of tvheadend on Raspi2 with Raspbian Jessie:

Add keys of additional Repo to your system
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61

Modify apt sources list
sudo nano /etc/apt/sources.list

Add line at end of file
deb http://dl.bintray.com/tvheadend/deb/ jessie release

Update apt sources
sudo apt-get update

Install tvheadend
sudo apt-get install tvheadend

Check if DVB-T tuner was detected (no driver install required):
dmesg

[1430354.151936] usb 1-1.4: new high-speed USB device number 4 using dwc_otg
[1430354.263931] usb 1-1.4: New USB device found, idVendor=0bda, idProduct=2838
[1430354.263960] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1430354.263977] usb 1-1.4: Product: RTL2838UHIDIR
[1430354.263992] usb 1-1.4: Manufacturer: Realtek
[1430354.264007] usb 1-1.4: SerialNumber: 00000001

Sources used:
https://tvheadend.org/projects/tvheadend/wiki/AptRepository

Configure tvheadend via webinterface

Open webinterface in webbrowser: http://:9981

Go to Configuration – DVB Inputs – Networks
Press “Add”, Select type “DVB-T Network”, give a name on your choice and select your region from Pre-defined muxes.
Press Create

Go to Configuration – DVB Inputs – TV adapters
Find your DVB-T device there, check “enabled” and select the network created on the step before under “Networks”

Go back to Configuration – DVB Inputs – Networks
Select you network and press “Force scan”
Wait a few minutes

Go to Configuration – DVB Inputs – Services and find detected channels there.
Mark all channels and press map all (this will create Channels out of the services, which you can find under Configuration – Channel/EPG – Channels

Go to Configuration – Access entries and create a user for streaming client devices. Check all services you want your devices to access.

Configure Kodi

Start Kodi and go to Options – Settings – Addons.
Find in category PVR the plugin “Tvheadend HTSP Client”
Configure the IP adress (of your raspi and the former createt user/password)

Done! You will find TV in your Kodi home.

Remark: I tried using tvheadend on a rasi where I had dump1090 for ADB-S installed before. Even after commenting the blacklist in /etc/modprobe.d and disabling the dump1090 service the channel scan and receiving a signal didnt work. Using a fresh raspbian minimal did the job…

Jdownloader headless on Raspberry Pi

Old: Mount remote SMB (via SSH):
http://geeks.noeit.com/mount-an-smb-network-drive-on-raspberry-pi/
using:
//192.168.x.x/JDownloader /media/smb/JDownloader cifs username=xxx,password=xxx,rw,file_mode=0777,dir_mode=0777 0 0
plus activate “Wait for network at boot” via raspi-config

Update: Mount remote SMB (via SSH):
I changed to using AutoFS to mount my NAS share, because it seems to be more stable/reliable. Using the fstab approach lost connection sometimes (maybe because of standby of NAS or short connection break).
https://anteru.net/2014/09/20/2480/

Install Jdownloader (via SSH):
sudo apt-get install oracle-java8-jdk
mkdir jdownloader
cd jdownloader
wget http://installer.jdownloader.org/JDownloader.jar
java -Djava.awt.headless=true -jar JDownloader.jar

(wait a loooong time until updates have been installed and JDownloader tells you that it has restarted itself…)

Kill process using shown PID (message of restart after updates installed).

Insert email and password of your MyJDownloader login:

sudo nano /home/pi/jdownloader/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json

Restart and check, if it appears in your http://my.jdownloader.org/

Create init-scrip
sudo nano /etc/init.d/jdownloader
insert

#! /bin/sh
### BEGIN INIT INFO
# Provides: jDownloader2
# Required-Start: networking
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: jDownloader2 Server Daemon
# Description: jDownloader2 Server Daemon
### END INIT INFO

DIR=”/home/pi/jdownloader”
PIDFILE=”$DIR/JDownloader.pid”
JAVA=”/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre/bin/java”
PARAM=”-Djava.awt.headless=true -jar $DIR/JDownloader.jar”

start_daemon () {
start-stop-daemon –start –background –oknodo –chuid pi –group pi –make-pidfile –pidfile $PIDFILE –exec $JAVA — $PARAM
}

stop_daemon () {
start-stop-daemon –stop –pidfile $PIDFILE
}

#Switch case fuer den ersten Parameter
case “$1” in
start)
#Aktion wenn start uebergeben wird
echo “Starte jDownloader2”
start_daemon
;;

stop)
#Aktion wenn stop uebergeben wird
echo “Stoppe jDownloader2”
stop_daemon
;;

restart)
#Aktion wenn restart uebergeben wird
echo “Restarte jDownloader2”
start_daemon
stop_daemon
;;
*)
#Standard Aktion wenn start|stop|restart nicht passen
echo “(start|stop|restart)”
;;
esac

exit 0

Install init.d with defaults

sudo systemctl daemon-reload
sudo systemctl enable jdownloader

Horizon Blade Nano QX with Devo 7E Devistion TX

Today I received my Nano QX preloaded with a Fatshark FPV module (about 140€ plus a few additional batteries).
The idea was to have a small indoor quad for the winter months.
The Nano QX is also available without the FPV module (about 60€) but I deceided to get it with FPV because of more indoor fun.

I was able to bind it in the first try with my DeviationTX Devo 7E with the following settings:
Protocoll DSMX / 7 channels (default)

CH1 THR
CH2 AIL (Expo 30%)
CH3 ELE (Expo 30%)
CH4 RUD
CH5 none
CH6 Switch (eg DR0)

The CH6 is used to change the flight mode between stable (red led) and acro (blue led) when toggled.

Its a big fun to fly around in the home using FPV…

The batterie lasts about 4-5 minutes of flight time (moderate crusing).