Categories
General

Vdx – An Intuitive Commandline Wrapper To FFmpeg – OSTechNix

Vdx is an intuitive commandline wrapper to FFmpeg. Using Vdx, we can do most common audio and video encoding and transcoding operations.

Source: Vdx – An Intuitive Commandline Wrapper To FFmpeg – OSTechNix

Categories
General VSCP

“Post is delivered” #vscp #nodered

Snow here today, quite a lot, so I am glad to have the “post is delivered sensor” so I don’t have to walk out to the postbox more than one time. So when I get the message on my phone today I am very pleased.

Yes it should be “there is” and that is changed now. But working. Yes!

I have written about this before here and here and I will probably write about this setup again as it is useful for many other areas.

I have not looked at battery voltage and signal strength before so I decided to email all events the sensor sends to me. This is simple in node-red of course

Just added the last row with a filter on just the sensors GUID.

The full flow is at the end of this post.

Now I receive six emails when the post is delivered. And I will go through them all here

Event #1

The email is

{
  "vscpHead":32864,
  "vscpClass":10,
  "vscpType":6,
  "vscpGuid":"FF:FF:FF:FF:FF:FF:FF:FE:5C:CF:7F:07:76:03:00:00",
  "vscpObId":5,
  "vscpTimeStamp":11704000,
  "vscpDateTime":"2020-10-20T10:51:17.000Z",
  "vscpData":[168,64,214,0,0]
}

which is

a temperature measurement (class=10, Type=6). The data is a bit cryptic when we need to decode it manually. But info on how to do that is here so we can try it out.

The data coding byte is 168 which is 0xA8 in hexadecimal and 0x10101000 in binary. The three leftmost bits (0b101) is the coding and in this case we have a 32-bit floating point value in byte 1,2,3,4. Bits 0,1,2 of the data coding byte is the sensor index and it is zero here so this is from sensor 0. Bits 3,4 is the unit. And if we look in the spec. we see that the unit is degrees Celsius.

The floating point value 64,214,0,0 is on MSB form and I am on a PC so it should be be 0,0,214,64. I can use a simple C program to find the floating point value

#include <stdio.h>
#include <string.h>
#include <inttypes.h>

int main() {
    uint8_t iv[4] = {0,0,214,64};
    memcpy( (uint8_t *)&fvalue, (uint8_t *)&iv, 4 );
    printf("Memconversion: %f\n", fvalue);
    return 0;
}

This will print

Memconversion: 6.687500

which is totally wrong as the temperature is around -1.5 degrees C here right now. Maybe the post bin is a very nice place to be in or maybe there is some self heating going on. Room for investigation.

Event #2

The email is

{
  "vscpHead":32864,
  "vscpClass":1040,
  "vscpType":6,   "vscpGuid":"FF:FF:FF:FF:FF:FF:FF:FE:5C:CF:7F:07:76:03:00:00",
  "vscpObId":5,
  "vscpTimeStamp":11776000,
  "vscpDateTime":"2020-10-20T10:51:17.000Z",
  "vscpData":[0,0,0,1,54,46,54,56,56,0]
}

In the VSCP Specification we find that class=1040, type=6 is also a a temperature measurement, but here as a Level II event and on string form. In the specification we see that first byte is sensor index (0), the second is the zone (0), the third byte is the sub zone (0), and the fourth byte is the unit (1). Byte 4,5,6,7,8,9 make up the string with the value which is 6.688. The zero at the end is the string termination. Not needed but often given. So again the temperature is 6.688 degrees Celsius.

Event #3

The email is

{
  "vscpHead":32864,
  "vscpClass":10,
  "vscpType":16,
  "vscpGuid":"FF:FF:FF:FF:FF:FF:FF:FE:5C:CF:7F:07:76:03:00:00",
  "vscpObId":5,
  "vscpTimeStamp":11849000,
  "vscpDateTime":"2020-10-20T10:51:17.000Z",
  "vscpData":[137,131,11,83]
}

Class=10, type=16 is a Voltage measurement. This is the battery voltage (electric potential). Again we look at the coding byte which is 137, which is 0x89 in hexadecimal and 0b10001001 in binary. Data coding is 0b100 which tells that the data is a normalized integer. For a normalized integer the second byte is the exponent of the number. Here 131 which is 0x83 in hexadecimal. Bit 7 is set which means the decimal point for the integer in the following bytes should be shifted to the left.Bits 0-5 tells how many steps, tree in this case. The integer is 0xB53 which is 2899 in decimal. Shifting the decimal point three steps to the right gives 2.899 V. And we know the battery voltage.

Event #4

The email is

{
  "vscpHead":32864,
  "vscpClass":15,
  "vscpType":6,
  "vscpGuid":"FF:FF:FF:FF:FF:FF:FF:FE:5C:CF:7F:07:76:03:00:00",
  "vscpObId":5,
  "vscpTimeStamp":11921000,
  "vscpDateTime":"2020-10-20T10:51:17.000Z",
  "vscpData":[85,45,56,54]
}

Here class=15, type=6 which is Signal strength. Again the first byte is the coding byte and is 85 which is 0x55 in hexadecimal and 0b01010101 in binary. Data coning is 0v010 which tells the rest of the bytes is a string and if we decode that we get -86 The unit bits are 0b10 (bits 5,6) and we see in the specification that this dBm. So signal strength is -86 dBm. Pretty good for a snowy day.

Event #5

The last email is

{
  "vscpHead":32864,
  "vscpClass":20,
  "vscpType":29,
  "vscpGuid":"FF:FF:FF:FF:FF:FF:FF:FE:5C:CF:7F:07:76:03:00:00",
  "vscpObId":5,
  "vscpTimeStamp":11660000,
  "vscpDateTime":"2020-10-20T10:51:16.000Z",
  "vscpData":[0,0,0]
}

Class=20 and type=29. According to the specification this is an information event telling that something has woken up. Data is index,zone,subzone and they are all set to zero as the GUID clearly tells who woke up in this case.


You may wounder about the vscpHead=32864. What is the meaning? This is a bit field (full definitions is here) giving some info about the event. In this case it tells that this event comes from a dumb node (but 15 is set). That is a node that does not have registers, a decision matrix and the other attributes of a smart node. It also have priority set to normal priority. This is selldome used in VSCP though.

The vscpObId is a channel number that end users normally does not need to care about.

Instead of manually decoding the data, the use of VSCP works would be preferred of course. It would have done the job above automatically. Bur now you know a little more about VSCP events in general.


The promised node-red flow is here

[{"id":"8387a5b3.258038","type":"vscp-tcp-in","z":"5ffcb26.533894c","name":"Localhost","host":"eaaa0283.83ca08","username":"admin","password":"secret","filter":"","keyctx":"vscp2","x":140,"y":120,"wires":[["9fe6d87d.7e56d","bee0ea0b.013a9"]]},{"id":"9fe6d87d.7e56d","type":"vscpfilter","z":"5ffcb26.533894c","vscppriority":"","vscpclass":"20","vscptype":"29","vscpguid":"FF:FF:FF:FF:FF:FF:FF:FE:5C:CF:7F:07:76:03:00:00","name":"Filter on Woken Up from mailbox","x":420,"y":120,"wires":[["b237b908.eb9ee8","e6bf6581.256c98","cb6535fa.e7dc38"]]},{"id":"b8a49e5b.388688","type":"inject","z":"5ffcb26.533894c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Post","payloadType":"str","x":430,"y":220,"wires":[["b237b908.eb9ee8","e6bf6581.256c98"]]},{"id":"b237b908.eb9ee8","type":"function","z":"5ffcb26.533894c","name":"Define message","func":"msg = {\n payload : 'There is post to collect in the mailbox',\n topic : 'There is post',\n to : 'akhe@grodansparadis.com',\n from: 'akhe@grodansparadis.com'\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":120,"wires":[["ccf59966.89df9"]]},{"id":"ccf59966.89df9","type":"e-mail","z":"5ffcb26.533894c","server":"mailhost.ljusnet.se","port":"25","secure":false,"tls":false,"name":"akhe@grodansparadis.com","dname":"Ljusnet","x":1000,"y":120,"wires":[]},{"id":"17d730fb.949a3f","type":"telegram sender","z":"5ffcb26.533894c","name":"telegram","bot":"42a44e6b.b2fde","x":1000,"y":220,"wires":[[]]},{"id":"e6bf6581.256c98","type":"function","z":"5ffcb26.533894c","name":"Define message","func":"\nmsg.payload = {};\nmsg.payload.chatId = \"1105118733\";\nmsg.payload.type = \"message\";\nmsg.payload.content = \"There is post to collect in the mailbox\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":220,"wires":[["17d730fb.949a3f"]]},{"id":"cb6535fa.e7dc38","type":"function","z":"5ffcb26.533894c","name":"Define message","func":"msg.payload = \"Post has been delivered\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":300,"wires":[["6d1af59f.bb754c"]]},{"id":"6d1af59f.bb754c","type":"ui_audio","z":"5ffcb26.533894c","name":"sound","group":"b5541ba5.781d38","voice":"en-GB","always":true,"x":990,"y":300,"wires":[]},{"id":"bee0ea0b.013a9","type":"vscpfilter","z":"5ffcb26.533894c","vscppriority":"","vscpclass":"","vscptype":"","vscpguid":"FF:FF:FF:FF:FF:FF:FF:FE:5C:CF:7F:07:76:03:00:00","name":"Filter on Woken Up from mailbox","x":440,"y":380,"wires":[["3bbfc1f1.3d2f36"]]},{"id":"3bbfc1f1.3d2f36","type":"e-mail","z":"5ffcb26.533894c","server":"mailhost.ljusnet.se","port":"25","secure":false,"tls":false,"name":"akhe@grodansparadis.com","dname":"Ljusnet","x":800,"y":380,"wires":[]},{"id":"eaaa0283.83ca08","type":"vscp-tcp-config-host","name":"Localhost","host":"localhost","port":"9598","timeout":"10000","interface":"","keepalive":""},{"id":"42a44e6b.b2fde","type":"telegram bot","botname":"pi11_bot","usernames":"brattberg_pi11_bot","chatids":"1234","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false},{"id":"b5541ba5.781d38","type":"ui_group","name":"Temperatures","tab":"b0073866.5d3d68","order":1,"disp":true,"width":"6","collapse":false},{"id":"b0073866.5d3d68","type":"ui_tab","name":"Home","icon":"dashboard","order":2,"disabled":false,"hidden":false}]
Categories
General

Again. thanks to our sponsors

This is really a great help.

Thank you again Rusoku and Ajje for you generous support of the VSCP project.

Categories
General

Stacey on IoT | CHIP products will be out next year

The Zigbee Alliance this week offered — nine months after announcing it was forthcoming — an update on Project Connected Home over IP, an effort by Apple, Amazon, Google, Samsung, and others to create some kind of interoperability standard for the smart home. There are A LOT of cooks in this kitchen, with 145 separate companies and more than 1,300 individuals signed working on CHIP. It is a titanic effort.The good news is that the standard is still on track, with a certification coming later this year and actual certified products anticipated in 2021. The Alliance also provided a list of devices that CHIP will focus on; it includes lighting, HVAC, locks, security, shades, and more, but neither smart speakers nor white goods, such as large appliances. And to round things out, it offered a GitHub repository and a detailed look at some of the levels where CHIP will seek standardization. (The diagram can be found in the photo accompanying the podcast post below). But in many ways, the update was disappointing.

Source: Stacey on IoT | CHIP products will be out next year

Categories
General

It works

The mailbox sensor still works. Not for I trust it fully yet. But I will, eventually.

Categories
General

#VSCP and #MQTT

For me its always been a bit strange to dub MQTT as an IoT protocol.  Well noways it’s even a standard. Strange to. It just does not solve the ‘problem’ as VSCP (Very Simple Control Protocol) for instance (and others) do. But nevertheless, as a general transport protocol, it is VERY useful. There is tons of code out there making it even more interesting to use. Very useful. Love it.

I know. It is tempting to send “ON” and “OFF” or “23.789”  on a topic to a MQTT broker. Simple and easy to understand and handle. The one problem is that others solving problems like the one you solve will send  “AUF” and “AUS” and “74.8202” meaning the exact same thing. It is hard to write stuff that can be reused and even work with stuff from different vendors with that approach.

It’s better to standardize what is what and stick to that standard. In that case an “ON” from one vendor of a device is understood by another vendor with a different device. Same for measurements. There are just a few SI units. But many units derive from them. If standardized a temperature in degrees Celsius is equally understandable on the receiving side as a temperature in degrees Fahrenheit (or even Kelvin).

VSCP defined events and other solutions for this twenty years ago. Not many people use VSCP today and have ever been using it for that matter (or will use it) and hopefully one of the big companies make a similar solution – calling it a new invention and revolutionizing – so we get an adoption of a system that help us write thing once and use it many, many times. Move things forward instead of we doing the same thing over again and again. I will be the firsts to applause such a thing when it happens. Because it will. One day.

I will not go further into VSCP and what it is and what it can do here. You are probably not interested (if you are look here https://docs.vscp.org/ ) anyway. That is OK. But I will show how VSCP events are transferred over MQTT. Or rather, I will show one way to transfer VSCP events over MQTT (guess which one is the IoT protocol and which one that is the transport protocol).

VSCP events are more or less the same as messages.  But “event” better describe the asynchronicity of events,  a button is pressed – an event is sent. VSCP events have a source, a class, a type and some data. The source tells who sent it. The class what class of events (measurement/information/data…) it is. The type is more specific of the event type. Data holds the actual info of the event.

Depending on the medium that carry the event a VSCP event is packed in different formats. Ethernet and CAN, for example, use a binary format for efficiency. Higher level protocols like MQTT does not (normally) need this efficiency. So here a VSCP event is packed as either a XML or JSON formatted message.

We are just interested in JSON format here but you have both described in the VSCP specification.

A VSCP event looks like this in JSON format

{   
   "vscpHead":0,
   "vscpObId":0,
   "vscpClass":10,
   "vscpType":6,
   "vscpGuid":"ff:ee:dd:cc:bb:aa:99:88:77:66:55:44:33:22:11:00",
   "vscpTimeStamp":1234567,
   "vscpDateTime":"2018-03-03T12:01:40Z",
   "vscpData":[1,2,3,4],
   "note":"Some optional note about event",
   "unit":0,
   "sensorindex":0,
   "coding":0,
   "value":1.2345
}

There are some extra fields we did not explain above and you have to read the VSCP specification to get info about them. But you recognize vscpGuid which is the ‘source’, this is the id/address for the device that sent the event. vscpClass is the class, vscpType is the type. VscpData is the actual data. This data is always in bytes but very well specified in both format and such things as byte order. Usually on a higher level you can handle this data with higher level functions and don’t need to care about the actual format it have.

So when a VSCP event is sent over MQTT this is what is sent.

For “ON” this will look like

{   
   "vscpHead":16343,
   "vscpObId":9,
   "vscpClass":20,
   "vscpType":3,
   "vscpGuid":"ff:ee:dd:cc:bb:aa:99:88:77:66:55:44:33:22:11:00",
   "vscpTimeStamp":1234567,
   "vscpDateTime":"2020-08-03T12:01:40Z",
   "vscpData":[0,0,0],
}

This is the  VSCP ON event.

Similar for a VSCP OFF event which looks like

{   
   "vscpHead":16343,
   "vscpObId":9,
   "vscpClass":20,
   "vscpType":4,
   "vscpGuid":"ff:ee:dd:cc:bb:aa:99:88:77:66:55:44:33:22:11:00",
   "vscpTimeStamp":1234567,
   "vscpDateTime":"2020-08-03T12:01:40Z",
   "vscpData":[0,0,0],
}

or for a temperature measurement

{   
   "vscpHead":16343,
   "vscpObId":9,
   "vscpClass":10,
   "vscpType":6,
   "vscpGuid":"ff:ee:dd:cc:bb:aa:99:88:77:66:55:44:33:22:11:00",
   "vscpTimeStamp":1234567,
   "vscpDateTime":"2020-08-03T12:01:40Z",
   "vscpData":[0xa8,0x41,0xcc,0x41,0x00],
}

In this case a temperature in degrees Celsius, coded as a 32-bit floating point value.

It is now possible to send VSCP events on any MQTT topic. But it is good to follow a specific scenario for the topics as well. Suggested for VSCP events is

prefix/guid/class/type

prefix‘ can be ‘vscp‘ or ‘/aaa/bb/cc/tt/yy‘ or something else.

Using this schema we can subscribe to the MQTT topic

/prefix/#

to see every event that is received from our setup.

If we just want all events from a specific remote node we can subscribe to

/prefix/guid/#

or if we want all all temperature events from a specific node

/prefix/guid/10/6

or temperature events from all VSCP nodes in the setup

/prefix/%/10/6

It’s just as simple as that.

Don’t just send magic numbers or “ON” or “OFF” anymore. Please!

Categories
General

New version of #Arduino VscpTcpClient available

A new version of the package VscpTcpClient (1.1) was published at 2020-09-01 13:53:17

  • The sendEventRemote method was broken. Fixed.
  • Response check is now returning VSCP_ERROR_TIMOUT instead of VSCP_ERROR_ERROR when a command fails with a timeout.

Categories
General

Don’t Use Arduino (For Professional Work) — Embedded

Arduino is an excellent prototyping platform. It is wonderful for its ease of use and speed with which to get started. I’m happy to say lots of good, heartfelt things about the whole Arduino ecosystem. But don’t ask me to use it in products.

Source: Don’t Use Arduino (For Professional Work) — Embedded

Categories
General

Not easy

It’s not an easy job to take on the job as a sensor in our house.

Categories
General

#Bluetooth® Mesh Masterclass | Bluetooth® Technology Website

This webinar covers a wide range of aspects relating to Bluetooth® mesh lighting control networks and provides next-level understanding of the following principles: Radio network principles Bluetooth…

Source: Bluetooth® Mesh Masterclass | Bluetooth® Technology Website