Andreas released a new version of the VSCP arduino library 1.3.0. Available here.
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.
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
- Woken up – to indicate the mailbox lid is open. VSCP_CLASS1_INFORMATION/VSCP_TYPE_INFORMATION_WOKEN_UP.
- Current temperature (level I & floating point value). VSCP_CLASS1_MEASUREMENT/VSCP_TYPE_MEASUREMENT_TEMPERATURE.
- Current temperature (level II and string value). VSCP_CLASS2_MEASUREMENT_STR/VSCP_TYPE_MEASUREMENT_TEMPERATURE.
- Battery voltage (normalized integer). VSCP_CLASS1_MEASUREMENT/VSCP_TYPE_MEASUREMENT_ELECTRICAL_POTENTIAL.
- RSSI (level I string). VSCP_CLASS1_DATA/VSCP_TYPE_DATA_SIGNAL_QUALITY
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.
The initial release (1.0.0) of the VscpTcpClient library is now available. The VscpTcpClient library can be used to communicate with a VSCP remote host in an easy and intuitive way. The library supports all Arduino Ethernet Client compatible hardware (atmelavr,espressif8266,espressif32).
Repository is here: https://github.com/grodansparadis/arduino-vscptcpclient
Documentation is here: https://grodansparadis.github.io/arduino-vscptcpclient
Info is here.