Categories
Python VSCP

#VSCP #Python libs.

I have released updated versions of the Python libs. They are still in alpha so structural changes can still happen. Be aware. Docs are also sparse at the moment but there are some simple samples available in the repositories for each lib. pyvscphelper is documented alongside the standard vscphelper library.

You find the libs here Install with

pip install <lib>

Update with

pip install --upgrade <lib>

For more information about VSCP go to the VSCP main site.

/Ake

Categories
VSCP

State of #VSCP

Hello everyone, must post a state of VSCP to show that things are rolling on even if activity looks dead right now. Yes, VSCP is still on active development. It is maybe not every user/developers favorite IoT framework but at least it’s maintainer (who does not love a child?) and a few others still like it.

For me I work on the next version of VSCP Works which I hope will be more stable and more useful then the present version which I personally never liked much, mostly due to the choice of using wxWidgets as a framework to build it. To get this thing out is the highest priority for me right now.

The new version of the VSCP daemon is quite stable as of the latest release. The thing that still needs to be done there is porting of some of the level II drivers to the new level II driver API. I just have’t found the time to do this yet. But will deliver on this point during this winter. I hope.

New things coming to the VSCP daemon is that MQTT client support will be built in instead being in a separate driver. This is in the line of work to use node-red for user interface tasks.

Also UDP and multicast support will go into the VSCP daemon again.

Both will be present in the next release of the VSCP daemon.

I use node-red with VSCP daily here at my location and much functionality in this house now is dependent on this setup. VSCP and node-red is a really a nice combination. More tools will come also here.

I added some VSCP functionality to ESPEasy (ESP8266/ESP32) for some time ago (a controller). It is hard to add generic functionality to a system that is not at all generic. But I gave up on this. Tired of trying to adjust to another really thoughtless solution. If I ever get time there will be sample code for the platforms some day. Tasmota is very nice but not at all generic when it comes to messages either. I plan to do a VSCP translator on MQTT level for my own use there as I really love many things about it.

Currently I am mounting some hardware here to control some stuff. It takes more time then I expected (does it not always?). But the thought is to have some things to work with and write demos and how-to’s around when the winter arrives with snow and cold temperatures (it’s late this year thankfully). Currently I am mounting hardware for lights and a weather station in my garage. More on this later.

well just a few words to show that this project still is alive and well.

Have fun!
/Ake

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
node-red socketcan VSCP

New release 1.0.7 of node-red-contrib-socketcan

node-red-contrib-socketcan (1.0.7) was published at 2020-09-29T07:13:01.967Z Fixes problem with format for received data.

Categories
VSCP vscpworks

New version 13.2.2 of VSCP-Works

Version 13.2.2

**A bug fix release. **

  • Fixes a problem with abstraction editing when abstraction is float/double/long/longlong

VSCP Works is deprecated.

Categories
the VSCP Daemon VSCP

Version vscpd 14.0.5 Silicon released

A new version vscpd 14.0.5 Silicon of VSCP & Friends has been released. It’s available for download here. This release mainly fixes a resource allocation problem that appears on Raspberry Pi and similar devices. If you have experienced connection problems on this or other platforms you should upgrade. Full list of changes is on the release page.

Enjoy!
/Ake

Categories
Arduino ESP32 ESP8266 VSCP

New version of VscpTcpClient 1.1.2

A new version of the package VscpTcpClient (1.1.2) was published at 2020-09-08 20:31:00

Fixes problem with connect always using admin/secret as credentials.

Categories
node-red VSCP

howto: Notification when mail arrives

Remember the Howto: Snailmail sensor? Of course I need a notification on my phone when mail arrives so I can use my old legs and go out and get it.

I use email and Telegram for this. I also have added a SMS message to but this costs money (to much really) and I like “free”.

The setup is simple.

Common

The first to do is to listen for incoming events from the VSCP daemon where the mailbox thing delivers them. I could have used a MQTT broker here but have chosen to stick to an all VSCP solution for this.

The server is the local machine in this case as I have node-red installed on it as well. Well I have about twelve (last count) node-red installations running here so there are machines to choose from.

The setup is simple

The localhost is setup as

I use a standard setup, just listen on all traffic (no filter), no interface. So at this point I get a lot of events. I could have added a filter here to ease the work for node-red and let the VSCP Daemon do the filtering. But I like when my applications work hard so node-red take care of that task.

Filtering is the next state. The filter looks like this

I filter on CLASS1.INFORMATION /VSCP_TYPE_INFORMATION_WOKEN_UP which is sent when the lid of the postbox is opened. I also filter on the GUID from the postbox device. The GUID from the device is a good example of a GUID derived from a devices MAC address. It is built from a template like this

FF:FF:FF:FF:FF:FF:FF:FE:YY:YY:YY:YY:YY:YY:XX:XX

where YY is the MAC address of the device and XX is something the designer can use the way he/she likes. Read more about this here if you are interested.

After the filter we now only get an event when the Woken up event is sent.

Email

The email setup is using the standard email tool (node-red-node-email). Nothing special with this setup. Just plain old mail delivery.

Before the email node I specify the mail content

I think it is pretty clear from the above picture where all fields go in the email.

Nothing more to it. An email is now sent when physical post arrives.

Telegram

Telegram is a perfect (and free) way to deliver/receive messages. There are apps and tools available for every platform. One just set up a bot (channel) and then subscribe to it on devices that should get the message. Download telegram first for your platform(s) (computer, tablet or phone).

Microsoft have a good walk through here on how to create a new bot. No need for me to repeat the steps.

In node-red I use the node-red-contrib-telegrambot node (telegram sender in this case). There are many other packages around but this one worked fine so I stick to it. My setup is like this

and

The token is the token you get from the setup. It looks something like this

The message needs to be defined here also and that is done in the stage before the telegram sender node. This is how I set it up

Now if you have installed Telegram on your phone/computer/tablet or whatever you will never miss the post delivery again and if you are fast enough you may even have time to wave to the postman/postgirl.

Here is the node-red code for this setup

[{"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"]]},{"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"]]},{"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 are post to collect in the mailbox\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":220,"wires":[["17d730fb.949a3f"]]},{"id":"eaaa0283.83ca08","type":"vscp-tcp-config-host","z":"","name":"Localhost","host":"localhost","port":"9598","timeout":"10000","interface":"","keepalive":""},{"id":"42a44e6b.b2fde","type":"telegram bot","z":"","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}]
Talk

If you want your computer to say “post is delivered” when mail arrives, add this

[{"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":"b5541ba5.781d38","type":"ui_group","z":"","name":"Temperatures","tab":"b0073866.5d3d68","order":1,"disp":true,"width":"6","collapse":false},{"id":"b0073866.5d3d68","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

Have fun!

Categories
Arduino ESP8266 HowTo's VSCP wifi

Howto: Snailmail sensor

Mail delivery. That is the physical type. That land in a box. Outside. There is one problem with it. You don’t know when or if you get any. So quite often, especially when there is a blizzard, one walk out to the postbox to find that it is empty. And if you have mail almost every day like me one wounder. “Are they late or is there no post for me today?” This usually ends up in me taking another trip to the postbox later when the blizzard is even worse.

A flag – the American style – would be possible. Needing binoculars. The later a habit that also might disturb my neighbors. But now, after all I work with computer. Something more firmware + electronics is my way. A perfect topic for a VSCP howto.

So the problem is simple: I need a notification when mail arrives in my mailbox. It also need to be a VSCP based solution. After all, I came up with the damn protocol.

So I set out to do this.

I like to lean new things. I therefore decided to use Platformio and the esp8266 with the Arduino core for this project. En environment I have not been playing with before. For both there are plenty of “getting started” write-ups available on the net.

This was a design that needed a battery. I have previously noticed the deep sleep capabilities of the ESP8266 so it should work. The device should take only ~20uA when sleeping and about 70mA when doing it’s work. In this app, we talk about a device that just need to wake up for a short moment once (when mail arrives) or twice a day (when I collect the mail).

You have the different sleep modes for the ESP8266 in the table below.

For deep sleep RST and CH_PD on the ESP8266 should be connected together. RST needs a pull-up. Now when set to deep sleep a low pulse on RST will wake the device.

So I came up with this schematic

Nothing strange here. Notice that I added a 1-wire temperature sensor also to get the temperature reported also when the lid is opened. Eagle file are here.

There is suggestions around to use a one shoot at the input. I tested without and it looks like things work as expected so I skipped it. An input switch will bounce so the startup of the unit will probably be a bot chaotic. This will take more juice form the battery and I will change this later on if I find it to be a problem.

I also replaced the reed switch with a mechanical switch on the mailbox. I will probably change that back later on but it was a little harder to get the reed switch approach to fit mechanically and I did not have the time to fix it the way I wanted to when I mounted the hardware.

I never reached 20uA in deep sleep. Rather 200 uA but that is OK for this test (theoretically 260 days or ~8 months on two AAA cells). I will investigate this further when I get more time. But apart from that everything works as expected.

For the firmware you can find it here. It is written so it can be used both with VSCP and MQTT (JSON VSCP events is sent). There are switches at the top of the file to select the version to build. With large EEPROM both can be used simultaneously.

I wrote a general library for VSCP and Arduino with the thought that it can be useful for somebody. Full info is here.

The sample code connects to wifi, then it connects to a VSCP remote host or a MQTT broker. Then it sends five events and then go to deep sleep again. The events that is sent are

The two versions of temperature events should be considered as a demo of level I and level II events.

So time to test. Put everything in a box and mount it in the postbox. Our postbox is located a bit from my house

I have a directional wifi antenna in that direction for some stuff in our garage so wifi is OK (-85 dBm) at the location.

I mounted everything a bit after midnight last night.

And now this morning

VSCP Works tells that something has happened at 05:14:44

And yes there is a small package in the mail. Demo accomplished. Might even be useful when connected to node-red so I can get a notification on my phone using Telegram. There may be a short write-up about that also later.

This same setup can of course be used for PIR sensors, window sensors and similar. One can even change the data sent from VSCP to some format. It’s a free world.

Enjoy!

Categories
VSCP

Please support our sponsors

Supporting the VSCP project right now is probably more important than ever. This is the only financing we have to keep servers running and make it possible to buy hardware to do even more releases and provide demos. Currently Github boost community funding so any sponsoring amount actually doubles on our side.

We are VERY grateful to our current sponsors. Please support them.