BME280 in Domoticz – updating the sensor data via Python

[Update: 30.07.2017 – as of now – latest stable domoticz version supports BME280, so this is now obsolete! The Hardware menu has now I2C Sensors and BME280 is present in submenu]
This is a modification of: https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/python/bme280.py, which after you change the IP address and port of Domoticz in ip_domoticz, and creating dummy sensor in Domoticz – “Temp+Humi+Baro” – and then changing the IDX to it’s value in: idx_dummy_bme280 – will update the sensor with the same data as you can see while running the program. This program will update Domoticz via JSON.
Continue reading BME280 in Domoticz – updating the sensor data via Python

Domoticz part 4: connecting the DS18b20 thermometer

Temperature readout is one of the first sensor we add to domoticz. It’s a very simple task and allows to connect multiple thermometers via the 1-wire bus. 1-wire means that thermometer has a single data wire, on top of VCC and GND. This wire is used to send back data to 1-wire controller and then it gets verified.

Termometr DS18b20
Thermometr DS18b20

What will you need?

Hardware:

  • thermometer DS18B20 (Dallas) – comes in variety of housings – usually it’s a chip with 3 pins. It’s good to measure from -55 degrees Celsius and up to +125, but it’s accurate till about +95 – +100.
  • 4,7kOhm resistor – used to pull up to VCC the data pin
  • Raspberry Pi (any model – A, B, B+, 2, 3 or new Zero)

Software:

  • domoticz – the same we installed in part one

Let’s do it!

This thermometer is able to perform very well on a long cable, being powered just by RPi using the PIN +3,3V. It’s OK to get 20 meters of calbe with 5 such thermometers, to check on recuperator and chimney. Recuperator has 2 inputs and two outputs – this allows to use the ‘custom’ mode of drawing the temp graphs to check on it’s performance.
Now first thing is to change the way our Wheezy or Jessie Raspbian starts. Add to /boot/config.txt this line:

dtoverlay=w1-GPIO,gpiopin=4

Now reboot RPi and connect the thermometer – add the 4,7kOhm resistor between the (red) data pin and the +3,3V (white) – just like on the first picture. This will make the signal crisp & clear on the 1-wire bus. The GND is using (blue) cable. All set? Connect to Raspberry Pi in this way:

Connecting Dallas DS18b20 to Raspberry Pi
Connecting Dallas DS18b20 to Raspberry Pi

Pin +3,3V to +3,3V, Pin Data (the middle on the thermometer) to GPIO#4 on RPi, and GND to GND of RPi (blue). If you have more (i.e. 5) connect them in parallel.
Now – let’s use console to find out if RPi can see the thermometer on the 1-wire bus:

cat /sys/bus/w1/devices/28-*/w1_slave

Now you should get RAW readout of the temperature – this example shows the real system with 5 thermometers:

3d 01 4b 46 7f ff 0c 10 75 : crc=75 YES
3d 01 4b 46 7f ff 0c 10 75 t=19812
3b 01 4b 46 7f ff 0c 10 e6 : crc=e6 YES
3b 01 4b 46 7f ff 0c 10 e6 t=19687
39 01 4b 46 7f ff 0c 0c 5e : crc=5e YES
39 01 4b 46 7f ff 0c 0c 5e t=19562
35 01 4b 46 7f ff 0c 10 5f : crc=5f YES
35 01 4b 46 7f ff 0c 10 5f t=19312
26 02 4b 46 7f ff 0c 0c b7 : crc=b7 YES
26 02 4b 46 7f ff 0c 0c b7 t=34375

You should expect just one entry for single thermometer. The part crc=xx YES – tells you that we have good readout.
All that’s left is to add the 1-wire to domoticz, using: Settings->Hardware:

Adding 1-wire to Domoticz
Adding 1-wire to Domoticz

Our themometer(s) will be at once visible via Settings->Devices:

Dallas tehrmometers DS18b20 in Domoticz (1-wire)
Dallas tehrmometers DS18b20 in Domoticz (1-wire)

This is really all – add them to make’em visible in Temperature tab!




Domoticz part 3: ESP Easy – quick and easy sensor for weather station using ESP8266

ESP8266 has become so popular that a beginner can choose from multitude of projects/firmwares and then – just start using them. Advanced IoT adopters will praise it’s quick implementation and stability. Today we will check out the Richard Ten Klooster’s project ESPEasy – https://github.com/ESP8266nu/ESPEasy. Basically ESPEasy is a firmware that can be flashed onto ESP8266 – preferably ESP-12E or ESP-12F and right after boot – we can join it’s WiFi access point (AP) to configure it via web interface. No console needed. Then, it is as easy as adding sensors (can be multiple) and ESPEasy starts to upload the data to Domoticz. The WiFi networks to connect to is named ESP_01XYZW, we should use “configesp” as WPA password and point our browser to 192.168.4.1

TL DR; If you ever wanted to use ESP8266 but it was too complicated – ESPEasy is the right tool for you and great remote sensor for weather station

What will you need ?

ESPEasy requires at least ESP8266, best if it’s the ESP-12E or ESP-12F version. To make it even more easy – take a look at ready prototype boards with ESP8266, they have gold pins, own power supply that uses 5V/micro USB. This allows you to re-use old phone charger or powerbank with USB output. Let’s choose for this project a very nice and precise sensor – DHT22, that gives you temperature and humidity. Advanced users can simply get a ESP-12E, solder cables and use classic VCC of 3,3V.
Putting the software is also very easy – flash a */bin file, but I will get you through (optionally) full compilation & build phase. This might come in handy for testing newer version of EasyESP. YOu will need to download and install Arduino Studio, libraries and ESP Easy source, build it and flash it.

Hardware:

  • I choose the NodeMCU (2.0) with ESP-12E V2 (search for: Amica NodeMCU in your favorite online shop)
  • DHT22 sensor

    ESP8266 na NodeMCU Amica Board z czujnikiem DHT22
    ESP8266 na NodeMCU Amica Board z czujnikiem DHT22
  • jumper cables
  • one 4,7k up 10k Ohm resistor
  • OPTION: Raspberry Pi – used to flash, debug – also for console

Software:

  • the easy path: ready ESPEasy firmware (*.bin file)
  • the optional, interesting path: Arduino Studio – exactly 1.6.5 version
  • sources from ESP Easy

OPTIONAL: Building the ESPEasy firmware

Let’s look at our ESP8266 board – we can now flash it with firmware that we can build from sources or flash the bin. As our polish commenter noticed (huczas) – we can use the 078 (or 120) version, that has three distinct versions for different size of the flash in tour ESP8266. Since we have NodeMCU – we use the “biggest” file. In case this doesn’t work for you – use the installed Arduino IDE in specific version – 1.6.5. This is a IDE software that is capable  (but of course not limited to) of compiling – building firmware for ESP ESP8266. Let’s install (MS Windows, Linux) exactly this version 1.6.5: https://www.arduino.cc/en/Main/OldSoftwareReleases#previous.
But why 1.6.5 ? IT’s suited to support our board and will work with this tutorial.

Arduino IDE
Arduino IDE

So let’s download now the board description for the IDE to understand what we will be building for: enter in preferences the Additional Boards Manager URLs:

Arduino IDE - preferencje
Arduino IDE – preferences and the field to enter URL

Type into “Additional Boards Manager URLs:” address: http://arduino.esp8266.com/stable/package_esp8266com_index.json that holds the ESPEasy 2.0.0 definition – Then go to Tools -> Boards Manager:

Arduino IDE - Boards Manager - instalacja płytki ESP8266
Arduino IDE – Boards Manager – instalacja płytki ESP8266

Install the esp8266 2.1.0-rc2 (or newer). Again go to Tools – and choose the right board:

Wybór płytki ESP
Wybór płytki ESP

Now to get the sources (I was using here version 048), today (January 2017) we have stable version 120: http://www.letscontrolit.com/

After downloading – unpack the file into ESPEasy folder in Arduino IDE, copy the libraries – from folder Libraries to folder in Arduino IDE – libraries.

Open the ESPEasy.ino file via Arduino IDE and choose Export compiled binary

Eksport firmware ESP8266
Export (compile & build) – firmware ESP8266

you should see the progress bar

Kompilacja w toku...
Compilation in progress

and then it should finish like this:

Ukończona kompilacja ESPEasy
Finished ESPEasy compilation

Look into the ESPEasy folder for file: ESPEasy.cpp.thing.bin

Flashing  ESPEasy firmware

Connect your  NodeMCU board to RPi, just like last time and choose either current version downloaded (078 4M) or the above 4M file: ESPEasy.cpp.thing.bin. Check the current firmware on the unit either:

=node.info()

or this command will work:

AT+RST

Since a lot of cheap UART converters on MS Windows has issues with the chip and drivers (IP problem) – we are using here RaspberryPi. Put the file to the folder with already used esptool.py and let’s flash as before with some extra commands (SPI flash 4M): https://blog.jokielowie.com/2015/10/domoticz-cz-2-termometr-wifi-z-precyzja-do-dwoch-miejsc-po-przecinku-czyli-esp8266-dla-poczatkujach-w-praktyce/:

python esptool.py -p /dev/ttyAMA0 write_flash 0x0 ESPEasy.cpp.thing.bin -fs 32m -fm dio -ff 40m

Flashing finished ? Now you got the ESPEasy installed! Reboot to run it, but first:

Connecting the DHT22 and Domoticz integration

As you probably noticed on the first photo – I did not connect the DHT22 using a pull-up resistor. You should – connect the middle  DATA pin to VCC pin via ~10k resistor. It’s only my good luck that it works stable.

Connection

The NodeMCU has the interesting pins right above the WiFi logo:

ESP8266 na NodeMCU Amica Board z czujnikiem DHT22 - podłączenie z boku
ESP8266 on NodeMCU Amica Board with DHT22 – side view
  • +3,3V -> first pin on the left on DHT22 (looking en-face at DHT22, where you see the markings, serial number etc.)
  • GND pin -> last, fourth pin from left DHT22
  • D4 -> second pin from left  DHT22, donlt forget to put also 10k resistor from D4 to +3,3V

Configuration

The NodeMCU v 1.0/2.0 requires +5V with microUSB cable – the same as RaspberryPi, and it could be an old 300-500mA phone charger (it could be also even 2A). After turing on the board – look on your PC/Tablet for new WiFi network (password “configesp”) in format of ESP_01WXYZ (last six characters are from the MAC address of the WiFi interface on ESP8266). Connect to this WIFi via browser: http://192.168.4.1/ and you will get this nice looking configuration menu:

ESPEasy - Main Screen
ESPEasy – Main Screen

In this example we have already preconfigured the device so lets move to the Config tab, and enter our normal home netwokr WiFi details:

ESPEasy - konfiguracja sieciowa
ESPEasy – network config

OK, so let’s give our device a friendly name, and access password to protect the Web interface (you can reset it via console – reset.). Next – the WiFi details – we expect that device can reach Domoticz  via this network. Use if you can DHCP. The WP Ap Mode Key should be left with default value, but change the protocol to Domoticz HTTP, enter IP address of Domoticz and port. The important Sensor Delay parameter will determine the interval of the reporting the values – 300 seconds – we will update the data from DHT22 every 5 minutes!

Next – let’s tell ESPEasy that we have DHT22 connected – via the Hardware tab:

ESPEasy-devces

The key here is to use the pin on the NodeMCU – D4 is GPIO2 which is not THE BEST solution, and IDX – the virtual sensor index that we create in Domoticz. What’s that ? Just like here: https://blog.jokielowie.com/2015/07/przekazniki-kontaktrony-wake-on-lan-oraz-z-wave-czyli-domoticz-w-sluzbie-domu/ we need to create a “virtual’ sensor – which tells Domoticz that it’s not going to be linked to it’s hardware but rather it’s going to be updated via network, using for example JSON. So this time let’s create “Temp+Humidity” sensor!

Dodawanie wirtualnego czujnika temperatury i wilgotności
WIlg is Humi in Polish

So move to Domoticz – Settings -> Devices, find our newly created sensor and remember the IDX value – copy it to IDX / Var in  ESPEasy. And… that’s it!

After couple of days you will get this nice graph:

Wykres z czujnika ESPEasy
ESPEasy gathered data – drawn by Domoticz

Right now the sensor is using mains charger, but after the overal temperature goes up (it’s outside the house) I’ll move to solar power.



Domoticz part 2: WiFi remote thermometer for weather station, dual digit precision – it’s ESP8266 for beginners

Last time we installed Domoticz, and soon we will move to Z-Wave, but first – let’s take a look at fantastic little gadget: ESP8266

What is an ESP8266?

ESP8266 (also called  ESP here) is a SoC – System on a Chip, which in our case is – CPU/RAM/FLASH with GPIO and WiFi interface – so another mini komputer with wireless interface. You can think of it as scaled down version of Raspberry Pi, less power hungry, but with own WLAN and a lot (minimum 2) GPIOs. Ad it runs it’s own WWW server!

  • CPU – 80MHz  (much faster than Arduino, much slower than Pi)
  • RAM – 64kB for instructions and 96kB
  • ROM – 64kB (just for boot)
  • FLASH: 4Mb (512kB)
  • WLAN: radio 2,4GHz – 802.11 b/g/n with WPA2
  • GPIO, I2C, ADC, SPI, PWM
  • Power: 3,3V (just what we have available using PIN 1 in Raspbery Pi)
  • Interpreter and LUA compiler (sic!). Or pure C using Arduino IDE
  • Price: $3. Yes. 3 US dollars

The SoC’s manufacturer is Espressif, other companies produce ready boards with interfaces and antennas:

    • ESP-01 (v1 and v2) – you get pins for +3,3V, GND, TX,RX and GPIO 0 i GPIO 2 (they spawn pull-up). WiFi antenna is printed on the module. Very popular due to price, best for beginners – it’s easy to connect it to Pi
    • ESP-03 – we get 8x GPIO
    • ESP-12 – SoC with shielding, better antenna and 10x GPIO
ESP-12
ESP-12

But why?

Let’s summarize: we have a possibility to use two or more GPIOs on WiFi enabled device, using very little power (10x less than RPi) – ideal for a weather station sensor. We can write a small program that would update the values in Domoticz (i.e. sensors) – because we can not only use the internal Web server but also sent periodically data to Domoticz – using nodejs or JSON format URL that Domoticz understands well. The latter is much more stable – and it’s great for starters.
It’s decided then! We’re building remote thermometer – based on ready examples.

Hardware

  • Raspberry Pi (any model – A, B, B+, 2 or 3 or even Pi Zero)

    Raspberyy Pi B+
    Raspberyy Pi B+
  • ESP8266 (any version, the best for start is ESP-01 with two GPIOs)

    ESP-8266 01 PINout
    ESP-8266 01 PINout
  • Dallas DS18b20 Thermometr – we can get chip or waterproof versions

    Dallas ds18b20 thermometr
    Dallas ds18b20 thermometer
  • 4,7k resistor – allows good readout from thermometer (pulls-up the DATA PIN), but if you are not getting results – change it to 2,2k:
    Rezystor 4,7k
  • OPTIONAL: Step-down module which will provide stable 3,3V out of input 5V (just make a search on your favorite portal for: step-down 3.3V)
    pi-esp-1
  • OPTIONAL: One or two Li-Ion type 18650 batteries – you can extract them from old notebook battery packs or power banks – but be carefull when disasembling the pack – 18650 are very dangerous when short or punctured! It could also cell phone battery – any Li-Ion that you can easily set-up. Fully charged battery is about max 4,2V and total capacity of around 2300mAh-2500mAh
  • OPTIONAL: charging module for working at 5V to properly charge and protect Li-Ion battery – it has USB and micro-USB connectors for input and output and soldiering pads for 18650. Check on how you can attach 18650 (be extra careful when soldering!)

    Regulator i zasilacz dla baterii Li-Ion
    Charging module for Li-Ion batteries

Connecting the ESP8266 module and updating the firmware

The ESP8266 has a standard UART – with TX,RX PINs, 3V logic – and it’s great since we can use the Raspberry Pi as a console!. In my optionion this is the best way to deal with this module. Our Raspberry Pi UART port is by default used as RPi own system console, so we have to free it to use as communications channel to ESP8266. To do that we have to delete in /boot/cmdline.txt this part: console=/dev/ttyAMA0,115000. Now let’s reboot RPi.
We should install now:

Raspberry Pi + ESP8266
Raspberry Pi with ESP8266 connected

Since ESP8266 is often used as Arduino module it comes to us with a firmware that uses AT commands – just like modems do. We will use the NodeMCU firmware – that uses LUA intereter/compiler – another very nice BASIC-like type of software (very powerfull!). At the time of writting we had: nodemcu_integer_0.9.6-dev_20150704.bin version available with the tool – esptool.py. Let’s hook up the ESP8266 to Raspberry Pi:

  • We will be using 3,3V as VCC form RPi: +3,3V connecting to VCC and CH_PD on ESP (look at the picture). Now it’s not recommended for a longer period, because ESP8266 can draw 3x more than 3,3V PIN on RPi can support!
  • GND from RPi to GND at ESP
  • PIN 13 on RPi to TX on ESP, and PIN 14 on RPi to RX on ESP
  • Additionaly, we have to connect GPIO 0 to GND on ESP-01, to allow firmware upgrade (and re-power ESP after connecting). Upgrading is as easy as this:

Installing proper serial support library for python:

sudo apt-get install python-serial

Updating the firmware:

python esptool.py -p /dev/ttyAMA0 write_flash 0x000000 nodemcu_integer_0.9.6-dev_20150704.bin

If GPIO0 is NOT connected to GND you will see this error:

pi@raspberrypi ~/esp8266 $ python esptool.py -p /dev/ttyAMA0 write_flash 0x000000 nodemcu_integer_0.9.6-dev_20150704.bin
Connecting...
Traceback (most recent call last):
  File "esptool.py", line 353, in 
    esp.connect()
  File "esptool.py", line 138, in connect
    raise Exception('Failed to connect')
Exception: Failed to connect

If GPIO0 is connected to GND and re-powering of the ESP unit – firmware will be upgraded:

python esptool.py -p /dev/ttyAMA0 write_flash 0x000000 nodemcu_integer_0.9.6-dev_20150704.bin
Connecting...
Erasing flash...
Writing at 0x00005800... (5 %)
Writing at 0x00031800... (45 %)
Writing at 0x00057c00... (80 %)
Writing at 0x0006dc00... (100 %)

Leaving...

After successful upgrade we should get to know our new toy. To do that we need serial console -let’s install picocom and enter:

picocom -b 9600 --omap crcrlf /dev/ttyAMA0

We can see the “>” prompt, so if you already know LUA you can start testing or use: official examples form NodeMCU..
First, let’s get IP address via WiFi, enter the commands line per line:

--nil
print(wifi.sta.getip())
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","password")
print(wifi.sta.getip())
--192.168.1.12

You need to change the SSID and password to correct values for your home network – and ESP will connec to Access Point and will ask for IP address via DHCP client. Great, we have IP address now. Now, let’s connect the Dallas DS18b20. It’s a very cheap sensor, that is supported by NodeMCU example – download from the module library the file : ds18b20.lua.
But we need changes, since we will get only single digit precision in Celsius mode – find the line:

 t = t / 10000

and replace with:

 t = t / 100

Double digit precision is ready! Changed file looks like this:

--------------------------------------------------------------------------------
-- DS18B20 one wire module for NODEMCU
-- NODEMCU TEAM
-- LICENCE: http://opensource.org/licenses/MIT
-- Vowstar <vowstar@nodemcu.com>
-- 2015/02/14 sza2 <sza2trash@gmail.com> Fix for negative values
--------------------------------------------------------------------------------

-- Set module name as parameter of require
local modname = ...
local M = {}
_G[modname] = M
--------------------------------------------------------------------------------
-- Local used variables
--------------------------------------------------------------------------------
-- DS18B20 dq pin
local pin = nil
-- DS18B20 default pin
local defaultPin = 9
--------------------------------------------------------------------------------
-- Local used modules
--------------------------------------------------------------------------------
-- Table module
local table = table
-- String module
local string = string
-- One wire module
local ow = ow
-- Timer module
local tmr = tmr
-- Limited to local environment
setfenv(1,M)
--------------------------------------------------------------------------------
-- Implementation
--------------------------------------------------------------------------------
C = 0
F = 1
K = 2
function setup(dq)
  pin = dq
  if(pin == nil) then
    pin = defaultPin
  end
  ow.setup(pin)
end

function addrs()
  setup(pin)
  tbl = {}
  ow.reset_search(pin)
  repeat
    addr = ow.search(pin)
    if(addr ~= nil) then
      table.insert(tbl, addr)
    end
    tmr.wdclr()
  until (addr == nil)
  ow.reset_search(pin)
  return tbl
end

function readNumber(addr, unit)
  result = nil
  setup(pin)
  flag = false
  if(addr == nil) then
    ow.reset_search(pin)
    count = 0
    repeat
      count = count + 1
      addr = ow.search(pin)
      tmr.wdclr()
    until((addr ~= nil) or (count > 100))
    ow.reset_search(pin)
  end
  if(addr == nil) then
    return result
  end
  crc = ow.crc8(string.sub(addr,1,7))
  if (crc == addr:byte(8)) then
    if ((addr:byte(1) == 0x10) or (addr:byte(1) == 0x28)) then
      -- print("Device is a DS18S20 family device.")
      ow.reset(pin)
      ow.select(pin, addr)
      ow.write(pin, 0x44, 1)
      -- tmr.delay(1000000)
      present = ow.reset(pin)
      ow.select(pin, addr)
      ow.write(pin,0xBE,1)
      -- print("P="..present)
      data = nil
      data = string.char(ow.read(pin))
      for i = 1, 8 do
        data = data .. string.char(ow.read(pin))
      end
      -- print(data:byte(1,9))
      crc = ow.crc8(string.sub(data,1,8))
      -- print("CRC="..crc)
      if (crc == data:byte(9)) then
        t = (data:byte(1) + data:byte(2) * 256)
        if (t > 32767) then
          t = t - 65536
        end
        if(unit == nil or unit == C) then
          t = t * 625
        elseif(unit == F) then
          t = t * 1125 + 320000
        elseif(unit == K) then
          t = t * 625 + 2731500
        else
          return nil
        end
        t = t / 100
        -- print("Temperature="..t1.."."..t2.." Centigrade")
        -- result = t1.."."..t2
        return t
      end
      tmr.wdclr()
    else
    -- print("Device family is not recognized.")
    end
  else
  -- print("CRC is not valid!")
  end
  return result
end

function read(addr, unit)
  t = readNumber(addr, unit)
  if (t == nil) then
    return nil
  else
    return t
  end
end

-- Return module table
return M

Save it for later – we will upload this to ESP in a moment- first let’s see how to autostart programs on ESP

Autostarting programs on ESP8266

 

ESP8266 with NodeMCU firmware after booting executes the init.lua, which is residing on the flash. It is extremely important that init.lua is TESTED and won’t put the ESP in boot-loop. We all heard horror stories about bad loop that executes indefinitely. Rule of a thumb – our init.lua should be short, minimal. In our case – let’s just get IP address and run the domoticz.lua which will report the temperature back to domoticz. Also – let’s try to have a backup WiFi in case we cannot connect with main – we can use the second WiFi network for debug purposes. Another important part of init.lua is the pause. Before getting/asking for IP address we should have enough time to issue a command to delete the init.lua file, so we can replace it in case no WiFi network is available. Our init.lua should look like this example:

--init.lua
 wifi.setmode (wifi.STATION)
 wifi.sta.config("MAIN SSID 1","extra_secret_no_1")
 wifi.sta.connect()
 tmr.alarm(1, 6000, 1, function()
  if wifi.sta.getip()== nil then
  print("No IP address, trying again...")
  wifi.sta.config("BACKUP SSID","other_secret_pass")
  wifi.sta.connect()
 else
  tmr.stop(1)
 print("WiFi mode ESP8266: " .. wifi.getmode())
 print("MAC address ESP8266: " .. wifi.ap.getmac())
 print("Success, IP is: "..wifi.sta.getip())
 dofile ("domoticz.lua")
 end
 end)

This init.lua changes ESP mode into AP client (ESP is also used as AP), sets the SSID, password and issues command to connect to home AP. Next – after 6000ms we check if wifi.sta.getip() returns something else than “nil” (nothing). If not – we move to configure backup network and we repeat that every 6000ms until ESP gets IP address. This 6000ms is here to login via serial console and delete the init.lua if we do not have any WiFi network. But if all goes well – ESP runs via  dofile, another script that does the readout of temperature and sends it to domoticz – it’s called:  domoticz.lua

Main temperature readout program, sending data to domoticz

--domoticz.lua
require('ds18b20')
gpio0 =3
gpio2 =4
ds18b20.setup(gpio2)
t=ds18b20.read()
print("RAW output from ds28b20:" .. t .. " C\n")
if(t==nil) then
t=0
end
tmr.alarm(0,240000, 1, function()
 t=ds18b20.read()
 tpre=t/100
 tsub=string.sub(t,-2)
 temp=tpre .. "." .. tsub
 print("Sent temperature:" .. temp .. " C\n")
 conn=net.createConnection(net.TCP, 0)
 conn:on("receive", function(conn, payload) print(payload) end )
 conn:connect(8080,"192.168.1.15")
 conn:send("GET /json.htm?type=command¶m=udevice&idx=11&nvalue=0&svalue=" .. temp .. " HTTP/1.1\r\nHost: thermometer.sheed\r\n".."Connection: keep-alive\r\nAccept: */*\r\n\r\n")
end)

This main program/script has the following structure; first it includes the attached previously library from NodeMCU (with the slight modification – remember?). Next it changes the GPIOs to allow for temperature readout in the Dallas mode – using GPIO2. For debugging we display both raw readout to check if we got 4 digits. This is the hack that allows for spliting the data into XY.ZW format and constructs simple HTTP request in JSON to send to domoticza, which has IP of 192.168.1.15 and port 8080. Since we need a virtual sensor – we need to set proper IDX here, so the data land in proper place. Now – test and wait for negative temperatures to see what’s going to happen. Check the comments section to find out for an alternative version. Let’s put those file on ESP8266’s flash.

Uploading files to ESP8266

Thanks to another python program, that we downloaded – we can quickly put files onto ESP8266 – using luatool.py:

python luatool.py -p /dev/ttyAMA0 --src init.lua --dest init.lua
python luatool.py -p /dev/ttyAMA0 --src domoticz.lua --dest domoticz.lua
python luatool.py -p /dev/ttyAMA0 --src ds18b20.lua --dest ds18b20.lua

Since we already connected via picocom, luatool.py will just work. It’s a good idea to test init.lua NOW because we can later end up in a loop.

OPTIONAL: Powering via solar module with battery backup

As we said before the RPi is not a perfect way to power ESP, because it cannot sustain it (too much mAps are drawn). And more importantly – this is a remote temp sensor, so it should be in WiFi range but not next to RPi. Let’s build our solar powered system:

  • one, two or three Li-Ion type 18650 battery
  • integrated charge controller from power bank with 5V input
  • step down module with output of 500mA max 3,3V
  • solar panel of 5V and 400mAp
  • WARNING: Do not use if temperature is OUTSIDE the 18650 spec, this can be dangerous! Do not use the 18650 battery if any parameter is out of it’s spec.

Solar panel should be mounted on some pice of plastic and secured with glue to allow operation in different weather conditions. The perfect angle towards sun is 45 degrees.

Panel fotowoltaniczny 5V, zamontowany na pleksi
Photovoltanic panel, rated 5V, 400mAp

Gluing the panel (I know – lousy job here…):

Tył panelu fotowoltanicznego
Tył panelu fotowoltanicznego

And then we connect it to power back charge controller via USB:

ESP8266 na NodeMCU Amica Board z zasilaniem bateryjnym oraz czujnikiem DHT22
ESP8266 with NodeMCU on Amica Boardwith battery power and DHT22 sensor

Above you can see the next version of this project – moving to more advanced firmware and hardware – the ESPEasy on ESP-12E using Amica Board with +5V VCC.




OpenVPN Raspberry Pi – split-tunnel with Internet access

Would you like to connect from any place, usually using open WiFi network in town, at friends or airport – with your’re own home network? Virtual Private Network (VPN) is here to allow you to log-in securely to your home network, with additional perk of using it to get secure Internet access.

Raspberyy Pi B+
Raspberyy Pi B+

What will you need?

Hardware:

  • Rapberry Pi (A, A+ or B, B+, 2, Zero)
  • Home Router with Port Forwarding or Virtual Server support – any will do

Software:

  • Raspbian – standard Linux distribution for Raspberry Pi
  • OpenVPN – free OpenVPN server
  • OpenVPN – clients – different for Linux, Android, MS Windows etc.

As you see nothing fancy.

Security

Let’s talk about how we should secure our access:

  • physical access to your Raspberry Pi should be controlled (only you)
  • access to /etc should be restricted to the user that OpenVPN is running under
  • the files with .key are TOTALLY SECRET
  • the certificate .crt or .crs – are to be sent, lost, revoked – could be always renewed.
  • each device connecting to OpenVPN server (PC, tablet, smartphone) has it’s own key/certificate pair

Let’s do it

Well, as always the first thing is to update out RPi – let’s login via ssh or console:

sudo apt-get update && sudo apt-get upgrade

Now, lets install OpenVPN package:
sudo apt-get install openvpn

All commands used require root privileges, so I suggest to enter:
sudo su -

Next we should configure the server, first to generate SSL certificates, that allow securing of the connection and also – authentication.
All files should be stored in /etc, let’s create appropriate folder and copy over the example files to create certs, which reside in Raspbianie Wheezy here:
cd /etc/openvpn
mkdir easy-rsa
cp -R /usr/share/doc/openvpn/examples/easy-rsa/2.0/* easy-rsa/

If you’re on the newer Jessie, as noted in comments by Dom/OloX – folder with examples is located in /usr/share:
cd /etc/openvpn
mkdir easy-rsa
cp -R /usr/share/easy-rsa/* /etc/openvpn/easy-rsa/

Examples provided by easy-rsa package default to USA based data. Wait, what ? It’s all about the fact that the certificate has to have identification – who’s the authority that issued it. Since it’s going to be ours – we should put some familiar data here to identify it later.

Let’s edit the file ( or accept the fact that all certificates are from San Francisco…):

sudo nano /etc/openvpn/easy-rsa/vars

The changes are about the folder where we store the certs and keys, length of the asymetrical key – it’s usually1024 – but 2048 might be too much from RPi 1, or even 2 or 3. Let’s use the value of 1024:
export EASY_RSA=”/etc/openvpn/easy-rsa”
export KEY_SIZE=1024
export KEY_COUNTRY="US"
export KEY_PROVINCE="CA"
export KEY_CITY="SanFrancisco"
export KEY_ORG="Fort-Funston"
export KEY_CN=SerwerOVPN
export KEY_ALTNAMES="OVPN"

Country code – PL,  county/voivodeship: WA and so on – use what you like or don’t, but the KEY_CN – this should be changed.
Let’s prepare to create the keys:
cd /etc/openvpn/easy-rsa
touch keys/index.txt
echo 01 > keys/serial
. ./vars  # set environment variables
./clean-all

Now we will build a certificate authority::
./build-ca

All you need to do is to confirm values previously entered in vars:
Generating a 1024 bit RSA private key
..........++++++
..........................++++++
writing new private key to 'ca.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [PL]

The folder keys will now have ca.key and ca.cert.

Now, important port – generating the key to our system:

./build-key-server server

We will be asked to provide password. STOP. OK, enter a password – but then you will also have to enter it with each connection. We can remove the password and lower our security – the choice is yours!
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:

Answer yes to remaining questions and you will get in folder keys new files: server.crt and server.key in (/etc/openvpn/easy-rsa/keys/), they will be signed with your root certificate.
Now let’s build the Diffie-Hellmann parameters required for client and server to talk to each other. The process is quite interesting – check out  https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange 
./build-dh

This produces 1024.pem file, change the name to dh1024.pem
Now lets build the pairs – files – for a client:
./build-key client1

…along with the password:
./build-key-pass client1

That’s nearly the end – now let’s generate common HMAC key for TLS:
openvpn --genkey --secret /etc/openvpn/easy-rsa/keys/tls.key

Let’s copy all the files /etc/openvpn/mykeys/
cd /etc/openvpn/easy-rsa/keys
mkdir -p /etc/openvpn/mykeys
cp dh1024.pem /etc/openvpn/mojeklucze
cp ca.crt /etc/openvpn/mojeklucze
cp server.crt /etc/openvpn/mojeklucze
cp server.key /etc/openvpn/mojeklucze
cp tls.key /etc/openvpn/mojeklucze

It’s time to configure our OpenVPN server using certificates and keys.
First create the /etc/openvpn/openvpn.conf file with following entries:
push "redirect-gateway"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 192.168.11.1"
server 192.168.22.0 255.255.255.0
dev tun
verb 5
proto udp
keepalive 10 120
port 1194
dh /etc/openvpn/mykeys/dh1024.pem
ca /etc/openvpn/mykeys/ca.crt
cert /etc/openvpn/mykeys/server.crt
key /etc/openvpn/mykeys/server.key

user nobody
group nogroup

persist-key
persist-tun
status /var/log/openvpn-status.log
verb 3
client-to-client                                                                                                                                      
log-append /var/log/openvpn

The configuration of the server will get all the traffic coming from it (apart from static routes on the client – accessing the other LAN) and steer it to tunnel. Thanks to this we will also have Internet access through our tunnel and VPN (but check below!). The resolvers for DNS operation – let’s use Google and our local as secondary. The important line is ‘server’ this creates a network used only for the actual connection – so use private network you don’t use anywhere. The port is 1194 – we will have to reconfigure our home router for connection – see below for Port Forwading options. The protocol used is UDP.

Port forwarding

The forwarding of the public port from your router to private port on Raspberry Pi is quite easy to configure:

Port Forwarding - Linksys
Port Forwarding – Linksys
Port Forwarding - D-Link DIR
Port Forwarding – D-Link DIR
Port Forwarding - Archer VR900
Port Forwarding – Archer VR900
Port Forwarding - TP-Link
Port Forwarding – TP-Link
Port Forwarding - TP-Link
Port Forwarding – TP-Link

Split-tunnel – safe access to Internet by means of VPN

To allow split-tunnel – we need to add configuration at the end of the /etc/rc.local file.
Do mind that you need to change the example RPi address of 192.168.11.11 to yours, and as mentioned above – choose unused VPN – here: 192.168.22.0/24

The file should have following lines:

echo "Enabling routing for proper VPN operation..."
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "Remote port mapping for VPN service..."
iptables -t nat -A INPUT -i eth0 -p udp -m udp --dport 1194 -j ACCEPT
echo "SNAT of the VPN addresses to allow split-tunneling..."
iptables -t nat -A POSTROUTING -s 192.168.22.0/24 -o eth0 -j SNAT --to-source 192.168.11.11

exit 0

Client

Let’s configure the client – first mobile devices – Android. Download the OpenVPN (check for fakes!) and after installing – it’s going to ask for .ovpn file. Let’s create it, don’t forget to change the IP_ADDRESS_OR_FQDN_OF_THE_SERVER to your OpenVPN server.

Back to console of your Raspberry Pi:

cd /etc/openvpn/mojeklucze/
echo "client" > client.ovpn
echo "verb 4" >> client.ovpn
echo "dev tun" >> client.ovpn
echo "connect-retry-max 5" >> client.ovpn
echo "connect-retry 5" >> client.ovpn
echo "resolv-retry infinite" >> client.ovpn
echo "proto udp" >> client.ovpn
echo "remote IP_ADDRESS_OR_FQDN_OF_THE_SERVER 1194" >> client.ovpn
echo "nobind" >> client.ovpn
echo "persist-key" >> client.ovpn
echo "persist-tun" >> client.ovpn
echo "keepalive 10 900" >> client.ovpn
echo "inactive 3600" >> client.ovpn
echo "set CLIENT_CERT 0" >> client.ovpn
echo "<ca>;" >> client.ovpn
cat ca.crt | grep -A 100 "BEGIN CERTIFICATE" | grep -B 100 "END CERTIFICATE" >> client.ovpn
echo "</ca>" >> client.ovpn
echo "<cert>" >> client.ovpn
cat client1.crt | grep -A 100 "BEGIN CERTIFICATE" | grep -B 100 "END CERTIFICATE" >> client.ovpn
echo "</cert>" >> client.ovpn
echo "<key>" >> client.ovpn
cat client1.key | grep -A 100 "BEGIN PRIVATE KEY" | grep -B 100 "END PRIVATE KEY" >> client.ovpn
echo "</key>" >> client.ovpn

We got – client.ovpn. Rewiev the file, change: proto to udp, remote – IP address – to our public router address (or name if we have Dynamic DNS service), and enter the IP addresses into server line. Remove any ca cert key references to the files if they exist in imported example. The ready file goes to Android device – import, run connect and there it is!. Do mind that for mobile devices (i.e. Android/iOS- OpenVPN Connect requires the certificates to be embedded in the *.ovpn file!



Domoticz part 1: Relays, magnetic sensors, Wake-on-LAN and Z-Wave – Domoticz with Imperi Home serving your house

Domoticz on PI with relay
Domoticz on PI with relay

This entry was initially about single and simple purpose: how to quickly develop a solution that would open gate or garadge door by simulating the remote’s operation mode – pressing a button – but using smartphone, tablet, web browser, app. Domoticz is such an overkill and also blessing for such project – that it evolved into a lot of small sub-projects – more or less andvanced.

Direct inspiration was another entry by colleague on  MalinowePi Facebook group – Roman Kubat, who showed ImperiHome. This application has great interface but does not support press-type (dorbell) buttons. Hence the whole idea!

Continue reading Domoticz part 1: Relays, magnetic sensors, Wake-on-LAN and Z-Wave – Domoticz with Imperi Home serving your house

Light effect for any device with Video output based on raspbmc or OpenELEC and RaspberryPi

“Good news, everyone!”. If you succeeded in creating light effect using the previous entry:  https://blog.jokielowie.com/en/2014/02/efekt-swietlny-dla-media-playera-operatego-o-raspberty-pi/ you must’ve noticed that it’s limited to the content being played by raspbmc or OpenELEC. Luckily thanks to constant development by hyperion’s creator (tvdzwan) we’ve just got ability to use the effect with other devices that have video output the http://pl.wikipedia.org/wiki/Composite_video. Usually modern STB, Blu-Ray player or amplituners sport a SCART output or the yellow colored ‘Video’ output. What is important – they allow both HDMI and Composite video outputs to be working simultaneously.

What is needed ?

This time we need to get a cheap $10 ‘TV grabber ‘ or Video DVR’ USB dongle. It has Composite Video and Audio (L+P) inputs, and those sticks are used to transfer to new world movies from old VHS cassettes:

Ikona dla Grabbera
Raspberry Pi – with grabber

Hardware and software configuration

So those $10 dongles with different names (i.e. EzCap) are equipped with two chipsets: STK1160 or Fushicai. To check which is in our dongle issue

sudo lsusb

OpenELEC

Both are supported by latest OpenELEC (Ghost 13), but make sure that lsmod contains (but not limited to) this modules when Fushicai chipet is present:

# lsmod
spi-bcm2708
videobuf2_core
videobuf2_vmalloc
usbtv

When STK1160 is present lsmod contains (but not limited to) this modules:

# lsmod
spi-bcm2708
videobuf2_core
videobuf2_vmalloc
stk1160

The working grabber can be checked in many ways, for starters let’s issue:

ls -al /dev/video

Plese do remeber if you’ve identfied video0 – or maybe video1 this is important for configuration.

So we’re ready to test – lets grab our first video frame:

OpenELEC:~ # LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/storage/hyperion/bin /storage/hyperion/bin/hyperion-v4l2 --screenshot
V4L2 width=720 height=576
V4L2 pixel format=YUYV
V4L2 grabber signal threshold set to: {0,0,0}
V4L2 grabber started
V4L2 grabber stopped

The result should be the screenshoot.png file – you can use the Pictures menu in  OpenELEC to view it or transfer via Filezilla to PC and view it there.

If you don’t have input video the picture is going to look like this:

Brak sygnału Composite
No Composite signal

If the composite input signal is present and OK you will get a greenish picture – just like form the first days of television:

Niezły domyślny sygnał Composite
Good quality Composite signal

So it works! Don’t worry about the greenish tint we will get rid of with by decimating the frame – we don’t need such precision. Now the part of the kernel that takes care of the grabbing is called Video 4 Linux 2 or simply V4L2. This is enough to make it running – please add the new section of the configuration to /storage/.config/hyperion.config.json but before last bracket:

 /// Configuration for the embedded V4L2 grabber
    ///  * device          : The V4L2, you would like to use [default="/dev/video0"]
    ///  * input           : Input of the V4L2 you're going to use [default=0]
    ///  * standard        : Standard Video (no-change/PAL/NTSC) [default="no-change"]
    ///  * width                : Width of the frame for V4L2  [default=-1]
    ///  * height               : Height of the frame  [default=-1]
    ///  * frameDecimation      : Decimation factor klatki [default=2]
    ///  * sizeDecimation       : Decimation value [default=8]
    ///  * priority             : Hyperion priority channel [default=800]
    ///  * mode                 : 3D mode to use 2D/3DSBS/3DTAB (note: no autodetection) [default="2D"]
    ///  * cropLeft             : Cropping from the left [default=0]
    ///  * cropRight            : Cropping from the right [default=0]
    ///  * cropTop              : Cropping from the top [default=0]
    ///  * cropBottom           : Cropping from the bottom [default=0]
    ///  * redSignalThreshold   : Signal threshold for the red channel between 0.0 and 1.0 [default=0.0]
    ///  * greenSignalThreshold : Signal threshold for the green channel between 0.0 and 1.0 [default=0.0]
    ///  * blueSignalThreshold  : Signal threshold for the blue channel between 0.0 and 1.0 [default=0.0]
    "grabber-v4l2" :
    {
        "device" : "/dev/video0",
        "input" : 0,
        "standard" : "PAL",
        "width" : 360,
        "height" : 240,
        "frameDecimation" : 2,
        "sizeDecimation" : 8,
        "priority" : 1000,
        "mode" : "2D",
        "cropLeft" : 26,
        "cropRight" : 27,
        "cropTop" : 20,
        "cropBottom" : 20,
        "redSignalThreshold" : 0.1,
        "greenSignalThreshold" : 0.1,
        "blueSignalThreshold" : 0.1
    },

Now lets allow OpenELEC to use remote controll – menu Settings->Services->Remote Control->Allow other programs to control remotely. This is crucial to tell OpenELEC that we’re in menu or we’re palying a movie using OpenELEC – which will use the proper source for LED control.

Let’s test then! The effect should be visible while you’re in  OpenELEC or raspbmc main menu (so right after start), but please check if Hyperion, is grabbing the frames while in menu. To turn of the grabbing – go to   hyperion.config.json – and change –  “grabMenu” : false,:

"xbmcVideoChecker" :
    {
        "xbmcAddress" : "127.0.0.1",
        "xbmcTcpPort" : 9090,
        "grabVideo" : true,
        "grabPictures" : true,
        "grabAudio" : true,
        "grabMenu" : false,
        "grabScreensaver" : false,
        "enable3DDetection" : true
    },


What’s the stress for Rpi 1 ? Using 96 LED,  Raspberry PI B 256MB (the oldest model available) looks like this:

 293     1 root     R     397m106.4   0 63.9 /usr/lib/xbmc/xbmc.bin --standalone -fs --lircdev /run/lirc/lircd
 401   400 root     S    72328 18.9   0 17.1 /storage/hyperion/bin/hyperiond /storage/.config/hyperion.config.json

But what if you no longer have Composite/AV output from your other devices ? The answers is simple – use HDMI splitter and HDMI to AV converter.



Light effect for Raspberry Pi based media player – raspbmc or OpenELEC/LibreELEC

Raspberry Pi can be easily used as media player. We can choose from many variations, but the one I’d like to focus on is Raspbmc based on XBMC. Raspbmc with hyperion has ability to drive RGB LED strip or daisychain using Raspberry Pi. The important part is that it will lit the RGB LEDs accordingly to the screen borders in realtime. It’s used to make the visible part of the picture more vivid and extend it beyond the display, and it’s simply quite cool:

So, the effect is interesting, but … it doesn’t bother you ? Will my eyes hurt, or am I going to be distracted by it ? What about fast changing scenes ? Well in fact – no worries, you’ll forget about it in 5 minutes, mostly becasue it effects only perephrial vision. Try it out yourself! As it turns out it’s very important to use original Pi board, since Piotr (more in comments) had bad experience with clones – there’s no communication with LEDs!

Let’s begin, our system will not require any soldering!

List of material

  • 1 piece of Raspberry Pi 2,3 or 4B: RaspberryPi shield
  • 10 jumper cables that fit PINs in Raspberry Pi, you’ll need two male-female and two female-female ones: P2210009-small
  • 1 power source 5V 2 to 6A based on the length and type of LED strip. It’s going to power both LED strip and Raspberry Pi.
  • 1 socket with ability to fit the power source and attach jumper cables: OLYMPUS DIGITAL CAMERA
  • 1 piece of RGB LED strip with  WS2801 chip or other form of RGB LED WS2801 enabled “x-mass liights”. 2 meters strip will fine for 24-36″ TV, while 3 metrs will last for 42-46. You might also find strips using GRB configuration, as one of the commenter noticed – software can also support such configuration – see the Software section and HyperCon

Connecting

CAUTION:  RGB LED strip with WS2801 chips is powered via 5V power supply (PSU) and usually will need about 7 Watts  per meter, so be very carefull when calculating the PSU! We’re going to connect power for Raspberry Pi using it’s PIN – not via USB. Why ? Most of the problems with strip comes when using separate PSUs and it also allows to use just one powerfull PSU, without worrying about USB cable with thin lines. But the downside is that we will be bypassing the internal fuse in Raspberry Pi, so choose a very stable PSU!

Should you choose strip or xmass lights ? Each have pros and cons, but let’s deal with that later.

Lets start by preparing our power socket for connection to RaspberryPI and the LED strip:
Connecting Power Wires
The important step now is to connect data & clock signals to proper end of the strip (look at the arrow):

  • PIN 23 – connect to CLOCK on the stip (abbrv. CL)
  • PIN 19 – connect to DATA on the strip (abbrv. DO)
  • PIN 2 – the +5V – to PSU
  • PIN 6 – the GND – to PSU

Let’s properly wire the power to Raspberry Pi:
2. Power Pins Connected
Same wiring for the LED strip:
3. Connected LED Strip
And finally – clock and data wires connected to LED strip:
4. Everything is Connected
Now STOP:  Did you connect the data & clock lines on the correct end of the strip?

Our cabling should looke like this:

Chip WS2801

Software

raspbmc

Let’s start with raspbmc distribution – first we need to log in via ssh to raspbmc running on Pi. User/password are the same as in default Rasbian distribution pi and raspberry (as of January 2014).
Now let’s prepare to install ‘hyperion’.

Wait, what is ‘hyperion’ ?

Well it turns out that raspbmc already includes the support for  RGB LED strips – it’s called  ‘boblight’. This is a very well working software, but it happens to be slow – when using more LEDs (i.e. 150 when using 3 meters strip). So let’s replace it by better and faster software – hyperionem.

First of all we need to install proper libraries to build the software:

sudo apt-get update
sudo apt-get install libqtcore4 libqtgui4 libqt4-network libusb-1.0-0 libprotobuf7 ca-certificates

Now let’s turn off boblight:
sudo /sbin/initctl stop boblight

All that’s left is to install hyperion:
wget -N https://raw.github.com/tvdzwan/hyperion/master/bin/install_hyperion.sh
sudo sh ./install_hyperion.sh

Let’s test the connection to the strip – lit some LEDs!
hyperion-remote --priority 50 --color red --duration 5000

Now all you need to do is to configure hyperion according to your LED positions and quantity and enjoy the view!
Hyperion manual gives us Java program (), which looks like this:

hypercon_mainscreen_01

So it’s quite easy to select proper number of LED, their placement, clockwise orientation, etc. It’s also the place to check right configuration of the color coding on the strip – RGB or GRB.
Leave all other to defaults and save the file as hyperion.conf.json

Now using scp or FTP – upload the hyperion.config.json file to Raspberry Pi running RASPBMC. Then, login via ssh onto RASPBMC and issue:

sudo cp hyperion.config.json /etc/hyperion.config.json

That’s it!

OpenELEC

Now, OpenELEC is very XBMC-centric distribution, with little overhead of operating system. This comes down to simpler installation, but still I’d like you to go and read the raspbmc paraghraph, as we will need it for configuration.

Hyperion installation is similar, after logging in via SSH – you’ll get direct root access with root password openelec – you need to issue in console:

curl -L --output install_hyperion.sh --get https://raw.githubusercontent.com/tvdzwan/hyperion/master/bin/install_hyperion.sh
sh ./install_hyperion.sh

Next please store your config file here:

/storage/hyperion/effects

That’s it!

How to uninstall

But what if we would like to return to boblight and uninstall hyperion ?

sudo /sbin/initctl start boblight

and:
sudo /sbin/initctl stop hyperion
rm /etc/init/hyperion.config.json

SDR using Raspberry Pi: Tracking airplanes above our heads – recieving ADS-B data with visualization using DVB-T dongle

Raspberry Pi SDR

 

Note: There’s a newer version of this entry – updated with latest tests, much easier to install: https://blog.jokielowie.com/en/2017/01/sledzimy-samoloty-cz-2-ads-b-i-mlat-najtanszy-odbiornik-dla-flightaware-oraz-flightradar-24/.

Last time I’ve shared with you the Raspberry Pi “computer for a buck”. Unless you’re are learning Python or playing Minecraft – or better – you’re already bored – I have a new thing fro you. It’s a very nice idea that you can use as your graduation or school project – and it’s all about tracking airplanes high in the sky. From hardware point – you will need a DVB-T/DAB USB dongle – quite easy to obtain and also – quite cheap. We will be aiming to build a very cheap platform to send data back to Flight Radar 24 (and for us too), which gives us premium access and increases coverage of this particular service. So what’s it all about ?

  • spotting – it’s basically taking photos of the airplanes (regular airlines) that are travelling at RNAV. To take a photo – you need to know exactly when they are gonna fly-by and you need to know who’s flying – where to, where from etc.
  • receiving radio signal – we need to receive a specially modulated signal that airplanes are sending and interpret it – I’ll get back to this
  • drawing on the map the up to date position of the airplane and sharing this over local network
  • you can also try to listen to classic FM radio
  • as well as CB, TAXI corporations chatter
  • tracking amateur baloons that go up high into stratosphere
  • if you live near the airport you can also listen to chatter just like LiveATC.net does
  • basically listening to any radio from 50MHz to 2GHz, and demodulating digital signals
  • feeding FlightRadar24 with data and getting premium access

Continue reading SDR using Raspberry Pi: Tracking airplanes above our heads – recieving ADS-B data with visualization using DVB-T dongle

RaspberryPI – best & cheapest computer out there for everybody

pi-unbox There’s no doubt that non-profit organization behind http://www.raspberrypi.org/, the $25  computer (well let’s just say $35 + some xtras) had a huge success and is the next big thing for every computer enthusiast. Raspberry Pi is a full blown computer based on the ARM  architecture  that allows to run different sorts of operating systems. Today we have a choice of many Linux distributions, and the one to start and one to stay with is the Rasbian, based on another famous Linux distribution – the Debian. This little computer is designed in a very smart way allowing you to display video both on Composite only monitors (just back when I had Atari ST in the ’90, and every other Atari/Amstrad/Commodore C4 or Amiga) but also HDMI output, that you can optionally configure to work with any screen. Most HDMI->VGA converters do also work just fine. Raspberry Pi is now shipped in few variants – the classic 512MB RAM in model B is only available as used (just as the A model, that lacked Ethernet port), but previously they had – A i B just 256MB RAM. Today as of 2015 we have still B+ and A+ models – redesigned to allow better power management and distribution as well as the factor of outputs. The flagship today is of course the Raspberry Pi 2 and 3 – 1GB RAM, four cores and backward compatibility, while the version 3 has also WiFi and BLuetooth (LE) onboard, and the cores have been updated to A53 1,2GHz, 64-bit.  To continue the sound is also being transferred over  HDMI, which allows for decoding – but also you can choose analog (it’s on the jack along with composite video). For multimedia player enthusiast – this device is AVC hardware-decoding capable – way up to 1080p with sound – but there’s not default MPEG-2 license – you can order it separately. The original A, A+,  B and B+ had a CPU horsepower comparable to old Pentium II 350MHz, but don’t forget that GPU is 1080p capable. Just to start Raspbery Pi offers: Continue reading RaspberryPI – best & cheapest computer out there for everybody

Embedded devices: Linux on Raspberry Pi, ESP 8266 and others