Friday, April 29, 2022

Be carefull with cloud applications

For an index to all my stories click this text

This is a short story but a severe warning.



Have you heard about Insteon ???
No shame if you haven't. Neither did I until I stumbled upon this news. You ought to know about it because it is of importance to all of us.

Insteon was a company that offered a complete home automation system. They sold switches, door-sensors, wall-keypads, thermostats etc. etc. etc. A bit like the famous Dutch KlikAanKlikUit, Philips Hue and Tuya do. So it is something we all could have in our homes.

 


But then distaster struck. They went belly-up this week. And pulled the plug out of their servers.
This affected (hearsay) about a hundred thousand (yes 100.000) users.
And as usual with these systems, most users had multiple devices. Some invested hundreds of dollars into the system to automate their complete home.
And basically the lights went out for all those users.

If the servers plugs are pulled nothing works anymore. If you had bought a hub from them you would have some local functionality but even the hub connected to the cloud for a complete experience.

The Philips Hue system does the same. And so does Tuya.

Imagine having your complete house automated with products that rely on a cloud server and then suddenly nothing works anymore. This demonstrates that depending on an external company or service proves to be extremely dangerous.


I am using the former mentioned KlikAanKlikUit system. But I am using it in a different way. I am using it with my Domoticz home automation system which comfortabely runs on my own Raspberry Pi in my own Local network. Next to that I am using several ESP's (ESP8266 and ESP32's) as sensors and actuators. All controlled locally.

This is a plea for you to do the same.

Before you think about investing in a complete Home Automation system: for your own good do not turn to a cloud based service. Take some time to look into a local Home Automation System. There are plenty around like: Domoticz, eGeoffrey ,FHEM, Home Assistant, HomeGenie, Homeseer, Homey, Hoobs, Indigo Domotics, ioBroker, Jeedom, MajorDoMo, Misterhouse, MyController.org, OpenHAB, openLuup, PiDome, pimatic, Vera, WebThings Gateway and XTension to name a few. Most of these use a local hub/server so they keep working even if your internet connection is down.

All have their advantages and disadvantages. The looks is one aspect, ease of use another and open source and Raspberry installable are in my opinion very important. Another very important aspect is wether your home automation can connect to microcontrollers like the ESP to build your own devices. So do a bit of research. Also look if they have a forum, see how active that is and check what is happening there.

Better investing some time now then regretting it later.
The most important part is: DO NOT MAKE YOURSELF DEPENDEND ON A SINGLE MANUFACTURER AND/OR A CLOUD SERVICE. That is the lesson Insteon tought us.

Till next time
have fun

Luc Volders




Friday, April 15, 2022

Simulate your controllers with WOKWI

For an index to all my stories click this text.

There is always something new to play with just around the corner.
And for one reason or another I frequently stumble on something called WOKWI. So I decided to have a look on what's it all about.

Short cut
WOKWI is a simulator. It simulates several Arduino and Raspberry controlers. In the right part of the screen you draw your circuit by placing the micro-controller and adding sensors and actuators. Then connect all items with wires just like you would do for example on a breadboard. At the left part of the screen you type your code. When everything is done you press the run button and your circuit runs on the screen just like it would do in a real setup.

So let's have a look on how it functions.

First WOKWI is a free service. You can find it here: https://wokwi.com/

The opening page offers you to login. The good part is that you do not need to. You do not have to login to use the service. The draw-back is that you can not save your projects if not logged in. You can build them, test them but just can not save them. So the choice is yours. I decided to create a login.



Start with choosing the controller you want to simulate. The opening screen shows that you can choose from:
- Arduino Uno
- Arduino Mega
- ESP32
- Arduino Nano
- Raspberry Pi Pico
- MicroPython on ESP32
- Franzininho Project (never heard of it)
- MicroPython on Pi Pico



Clicking on more options reveal some more.

So next to programming the ESP32 with C++ (Arduino) you can also try programming the ESP32 with MicroPython. And for the Raspberry Pi Pico there is C++, MicroPython and CircuitPython. And there are several Arduino's to experiment with. All in all a lot to dive into.

As you might (no should !!) know I have written a book on the Raspberry Pi Pico which focussed on programming the Pico with Python for beginners. 

You can find more information here: http://lucstechblog.blogspot.com/2021/08/raspberry-pi-pico-simplified-now.html

And as you can see WOKWI offers a simulation for the Raspberry Pi Pico with Python. So I just had to try that !! I tried two examples from my book.



At the main page on the top right side there is a drop down menu. Choosing my projects gives a graphical list of all your projects. That is if you made some previously ;)



The first example is a simple setup with a button and a led. The led turns on when the button is pressed.And it worked direct. Pressing the start-simulation button showed a range of 1's when the simulation started and that changed into 0's when the blue button was pressed.

Please remember that WOKWI is a simulator, so the code on the right side of the screen has to be written by yourself. Like said, this example was taken from my book.

You can try this simulation yourself with this link:

https://wokwi.com/projects/328570227913654868




The second simulation is also from my book and that uses a joystick to alter the position of the servo. And as you can see that worked also as it should.

The servo's arm indeed moved according to the position of the joystick.

You can try this simulation using this link: 

https://wokwi.com/projects/328572656023503444



When the simulation is not running you can add sensors. You can choose them by clicking on the button in the middle on top of the simulation screen. At the moment of writing there were about 40 sensors and actuators that you can use.

Wokwi is free to use. But there is a paid membership. Paying members have some privileges. They can choose what the next sensor/actuator or feature is that will be implemented.

Altering the schematics is easy.



If the above picture is not to your liking you can click on a component.



When the component (here the Pico) is selected simply press the letter R on your keyboard and it will rotate. The wires will stay connected to their pins but it does not look fancy.



So you have to alter the wiring manually. Which I have done here.



At the right side of your screen is the editor for the program. There is also a tab called diagram. Clicking that tab shows the JSON code for the components of your schematic.



This detail shows the JSON code for the connection of the LED to the Pico.



As you can see by manually changing the colors in the JSON code you can alter the colors of the wires in your schematic. Originally the wires were black and green and I changed them into black and blue.





This is the JSON code for the led itself. WOKWI chooses a red led standard as the led component. By altering the line attrs (attributes) in "attrs": {"color": "green"} the led will change from a red led to a green one.

There is a lot more to be discovered and please do so, as it is fun to play with.

Any Flaws ?

Well while playing with the first example (the led and the butrton) I noticed that when the simulation starts the led is ON just like if the button is pressed while it is not. After once pressing the button everything functions as normal.

This is a small flaw I noticed in my brief tests with WOKWI. At this moment I am not sure if there are more flaws.

Is it usefull ???

Well if you do not own one of the supported microcontrollers Wokwi offers a fun way to explore the possibilities. You can learn programming microcontrollers with MicroPython or C++ (arduino language) without actually owning one. Another option is when you want kids to learn working with microcontrollers without having to fear that something breaks. And you can use Wokwi to test some setups before actually building a prototype on a breadboard.

And: yes it is fun to play with.

Till next time
have fun

Luc Volders



















Friday, April 8, 2022

Visible indication for the: more buttons on fewer pins

For an index to all my stories click this text.

In a previous story I showed how to attach many buttons on just a few IO pins. I did this by using diodes to binary decode the buttons. Sounds complicated but it really isn't and it is a great way to have more buttons, switches, door contacts, pir sensors etc without sacrificing too many IO pins. You can re-read that story here: http://lucstechblog.blogspot.com/2019/07/more-buttons-on-fewer-pins.html
 
The setup was just an example for the tutorial. And in real life pushing one of the buttons would evoke some action. However, how about immediate feedback. Then I had this idea.

Let us look at some basic electronics.



On the left you see the symbol for a diode and on the right side the symbol for a led. That shows that a led is basically a diode that transmits light. Duh..... Hence the name Led: Light Emitting Diode.

So what if I would exchange some of the diodes in my project by a leds. That would show which button was pressed, no matter what actions would follow you would get an instant feedback,



Here you can see that the strip at the right side of the diode points to where the - side is. This is the side to which the buttons are connected. When replacing a diode by a led test with a battery which side of the led is the + and which is the - side. Then replace the diode by a led using the same polarity.

At the buttons where just 1 diode is attached replace that diode by a led. At the buttons where multiple diodes are attached hust replace 1 of the diodes by a led.

That's all.

What leds to use.

Not all led's can be used as for some the forward voltage is to high. The dimmed red and green ones worked for me as did the clear red ones. Just experiment and see what works best in your setup.



Here you can see my setup with 7 buttons attached to just 3 IO pins of a Wemos D1. In this setup I replaced 3 diodes (as a test) with clear red leds.



And here you can see what happened when I pushed the first button. From the string of Neopixels only the first one lightened up just as it should but the led attached to the button also lightened up.

There you go. An immediate feedback when you press a button.

Till next time
have fun

Luc Volders





Friday, April 1, 2022

Something special for you all

This time I only have a special video for you.




Till next time,

Luc