Test Kamery


Kitesurfing Rules of the Road

Original posters and the text files in English, Korean and Chinese are attached below.

You can help by translating them from English to other languages.

Kitesurfing Rules of the Road

  1. Before launching a kite from the beach, one must be sure that it does not create any danger, not only for other riders but also for other people on the launching spot. In addition, the fact that the kite can drag a few dozen meters during launching this should be taken into account. A rider launching his kite on the beach gives way to anybody around him.
  2. Give way to riders entering the water. Being on land with an inflatable kite is more hazardous than being on water. Always allow others to enter the water even if this means having to take another turn before being able to return to the beach.
  3. When passing one another, the upwind rider must put his kite up and downwind rider must put his kite down.
  4. Give way to riders who are not in control of their equipment. You should give space to riders without their board or who look less in control (students).
  5. If two riders are on colliding course, rider riding right hand forward has the priority. If rider is riding switch (toe side edge), he has left hand forward of course.
  6. When overtaking, faster kiter must not obstruct or impede the slower kiter. Faster kiter must keep clear by a suitable distance, either windward (upwind) or leeward (downwind).
  7. The downwind rider has the priority. The upwind rider keeps out of the way of the downwind rider.
  8. Rider riding a wave has always the priority.
  9. The multiperson meetings increase the risk of collisions and should be avoided. It concerns especially beginners. Seeing that in a moment the multiperson meeting will take place and having doubts whether it is safe, the best way is to make a U-turn on the opposite course. If there is no place for that, just stop, set your kite in the zenith and wait until the situation is cleared.
  10. Give way to other water users over. Remember, even if it is your right of way, it is your responsibility to avoid collision at all costs and to help keep kitesurfing safe and respect as a watersport.

Water meter using NodeMCU ESP8266, TCRT5000, ESPeasy and node-red

pip install --upgrade setuptools
apt install esptool

Download and unpack ESPEasy to known folder

wget https://github.com/letscontrolit/ESPEasy/releases/download/mega-20191003/ESPEasy_mega-20191003.zip

Connect NodeMcu to your PC USB and execute following command (change the path to the .bin file accordingly)

sudo esptool --port /dev/ttyUSB0 --baud 460800 write_flash -fs 4MB -fm dout 0x0 /home/petr/Downloads/ESPEasy/bin/ESP_Easy_mega-20191003_normal_ESP8266_4M1M.bin

IR Sensor for Obstacle Avoidance KY-032 (AD-032)

Jiný senzor, než které jsem zatím testoval.
Obsahuje Vishay HS0038B IR receiver, který je hw nastaven pro detekci signálu modulovaného na frekvenci 38kHz
This sensor is known variously as the Keyes, KeyesIR or Keyestudio KY-032.  It is the the functional equivalent of the IrBeady IR-08H, also known as the AD-032.  The sensor uses a four pin connector, The pins are labeled: EN (Enable), out (Output), + (Power) and GND (Ground).  There are also two potentiometers on the board and one jumper (see picture).

Many posts on the internet about TCRT5000 digital output bouncing.
Nice article with oscilloscope analysis can be found here

I have solved it by adding 200k capacitor betveen DO and ground

    >------------o------> DO
                 o--||--> GND

For this project we need sqlite3 (version >= 2.5) Install from sources.

Raising edge means LED stops lighting

Create sqlite3 database and table

sudo apt-get remove sqlite3 # Uninstalling existing sqlite
cd /tmp
wget https://www.sqlite.org/2019/sqlite-autoconf-3300000.tar.gz
tar -xzvf sqlite-autoconf-3300000.tar.gz
cd sqlite-autoconf-3300000
./configure --disable-dynamic-extensions --enable-static --disable-shared
sudo make install
root@maxbox:/root/.node-red/sqlite# sqlite3 water.sqlite3;
SQLite version 3.30.0 2019-10-04 15:03:17
Enter ".help" for usage hints.
sqlite> .databases
main: /root/.node-red/sqlite/water.sqlite3
root@maxbox:/root/.node-red/sqlite# ls
power.sqlite  water.sqlite3

Python MinimalModbus + SHT20 Modbus RTU RS485 Temperature and humidity sensor

#! /usr/bin/python
import minimalmodbus
import time
# Set the value minimalmodbus.CLOSE_PORT_AFTER_EACH_CALL=True 
# immediately after import minimalmodbus

# default slave address = 1
instr = minimalmodbus.Instrument(port='/dev/ttyUSB0', slaveaddress=1)
instr.serial.baudrate = 9600
instr.serial.parity  = "N"
instr.serial.timeout  = 0.8
#instr.debug = True

read slave address, baud rate, temp. correction, hum. correction
print(instr.read_registers(257, 4,functioncode=3))

change of the slave address 
the change will take effect after reboot only! 
it is possible to continue using the old address till reboot
slaveNewAddress = 5
#instr.write_register(257, slaveNewAddress, functioncode=6)

change of the speed - take effect imediatelly
the change will take effect after reboot only! 
it is possible to continue using the old address till reboot
slaveNewBaudrate = 9600
#instr.write_register(258, slaveNewBaudrate, functioncode=6) 

# read slave address, baud rate, temp. correction, hum. correction
print(instr.read_registers(257, 4,functioncode=3)) 


while 1:
        print instr.read_registers(1,2, functioncode=4) # read temp and hum (list)
        print instr.read_register(1,1, functioncode=4) # read temp 
        print instr.read_register(2,1, functioncode=4) # read hum 
    except minimalmodbus.NoResponseError:
        print("No Response Error")
root@danfoss:/home/pi/danfoss# sudo pip install -U minimalmodbus
Collecting minimalmodbus
  Downloading https://files.pythonhosted.org/packages/6c/d5/77d42e8a0b73da2b5f97acd91900ac50e303b4cb959f76350cfbb38e05a0/minimalmodbus-1.0.2-py2.py3-none-any.whl
Requirement already up-to-date: pyserial>=3.0 in /usr/local/lib/python2.7/dist-packages (from minimalmodbus)
Installing collected packages: minimalmodbus
  Found existing installation: MinimalModbus 0.7
    Uninstalling MinimalModbus-0.7:
      Successfully uninstalled MinimalModbus-0.7
Successfully installed minimalmodbus-1.0.2

Description of the module here

Power consumption (kWh) monitoring using node-red and influxDB

I have got nice 3phase 30(100)A four wire RS485 MODBUS Din Rail watt meter from Aliexpress (US $35.76) (max. baud rate is possible to set to 9600). I am able to read values using USB-RS485 adapter + Raspberry pi and sending data (json) to the mqtt server. So far no problem. Power meter is providing cummulated value (the same value you can read on the display).

At the first beginning I was sending the data in to the sqlite database using sqlite node-red node. The table was very simple:

The issue starts with the simple question: How to get daily (hourly, weekly, monthly… ) power consumption? Something like:
| 22.7.2019 | 450kWh|
| 23.7.2019 | 320kWh|
| 24.7.2019 | 300kWh|
At the first sight it looks as an easy task, but I ended up with this quite complex query. And as data was growing, the execution of the SELECT was slowing down.

The guys from the nice JOYSFERA server were pointing me to the influxDB. Installation was an easy part thanks to the:

To import existing data in to the influxDB you need a text file with the following structure:



power value=0.0 1564391161
power value=270.8 1564583065
power value=272.1 1564583462
power value=272.1 1564583542
power value=272.1 1564583621
power value=272.2 1564583701

While preparing the file, note the line ending has to be linux style and if you are importing big data-set, the error messages are displayed on the top of the import screen – you need to scroll up (which was kind of difficult to me to discover).
Now you are ready to import data in to the database:

> influx -import -path=/path/to/the/data/file -precision=s
2019/08/27 22:53:04 Processed 1 commands
2019/08/27 22:53:04 Processed 26934 inserts
2019/08/27 22:53:04 Failed 0 inserts

Next connect the node-red node to the influx database:

When you are preparing data for the influxDB, remember you need to send the same data-type in to the database. In my case the value datatype was float

> show field keys
name: power
fieldKey fieldType
-------- ---------
value    float

It was necessary to writhe following (note *1.0 at the end of the first row) in to the node-red function node (otherwise the string was send to the influxDB)

msg.payload = msg.payload.POWER.toFixed(1)*1.0;
return msg;

The best part is the simplicity of extracting data:

> root@maxbox:/data/new# influx -precision rfc3339
Connected to http://localhost:8086 version 1.7.7
InfluxDB shell version: 1.7.7

> use mrazirna
Using database mrazirna

> select derivative(max(value)) from "power" where time > now()-7d group by time(1d) fill(0) tz('Europe/Prague')
name: power
time                      kWh
----                      ---
2019-08-21T00:00:00+02:00 200.19999999999982
2019-08-22T00:00:00+02:00 199.5
2019-08-23T00:00:00+02:00 202.10000000000036
2019-08-24T00:00:00+02:00 111.80000000000018
2019-08-25T00:00:00+02:00 309.89999999999964
2019-08-26T00:00:00+02:00 222.5
2019-08-27T00:00:00+02:00 278
2019-08-28T00:00:00+02:00 6.5

sqlite SELECT for power consumption reading

So far I have following working code (working with example data)

WITH miniPow as (
	select date(TIMESTAMP,'+1 day') as d, max(TOTAL_KWH) mini
	from power 
	group by date(timestamp)
, maxiPow as (
	select date(TIMESTAMP) as d, max(TOTAL_KWH) maxi
	from power 
	group by date(timestamp)
select maxiPow.d, ROUND(maxi-mini, 1) from miniPow 
on miniPow.d = maxiPow.d	

Below my first SQL attempt (not really elegant)

WITH consumption AS
          min(TOTAL_KWH) mi,
          max(TOTAL_KWH) ma
   FROM power
     enumerated AS
  (SELECT *,

     (SELECT count(*)
      FROM consumption b
      WHERE a.d >= b.d) AS cnt
   FROM consumption a),
     preenumerated AS
  (SELECT *,

     (SELECT count(*)-1
      FROM consumption b
      WHERE a.d >= b.d) AS cnt
   FROM consumption a)
SELECT strftime('%d.%m.%Y', en.d) AS "období od",
       strftime('%d.%m.%Y', pre.d) AS "období do",
       printf("%.1f", en.ma) AS "počáteční kWh",
       printf("%.1f", pre.ma) AS "koncový kWh",
       printf("%.1f", pre.ma-en.ma) AS "kWh za období",
       (JulianDay(pre.d) - JulianDay(en.d)) AS "počet dnů",
       printf("%.1f", (pre.ma-en.ma)/(JulianDay(pre.d) - JulianDay(en.d))) AS "kWh za den"
FROM enumerated en
JOIN preenumerated pre ON en.cnt = pre.cnt
SELECT strftime('%d.%m.%Y', min(date(TIMESTAMP))) AS "období od",
       strftime('%d.%m.%Y', max(date(TIMESTAMP))) AS "období do",
       "" AS "počáteční kWh",
       "CELKEM:" AS "koncový kWh",
       printf("%.1f kWh", max(TOTAL_KWH)) AS "kWh za období",
       printf("za %.0f dnů", (JulianDay(max(date(TIMESTAMP))) - JulianDay(min(date(TIMESTAMP))))) AS "počet dnů",
       printf("ø %.1f kWh/den", (max(TOTAL_KWH)-min(TOTAL_KWH))/(JulianDay(max(date(TIMESTAMP))) - JulianDay(min(date(TIMESTAMP))))) AS "kWh za den"
FROM power
Link to example table here