Sunday, May 10, 2020

WiPy and how to take advantage of it


For a some weeks I had been looking for something that could in theory replace the Mindstorms EV3/NXT smart bricks, while adhering to some extra criteria:
  • more "directly" programmable than with blocks, preferably using Python
  • low power demand
  • many output ports (at least a dozen)
  • not too expensive
  • connects to WiFi
  • does not strictly need to read values - control is enough
Among several candidates I chose Pycom WiPy, ordered it together with a breadboard, and gave it a try. It runs MicroPython, a subset of Python designed for such SoC devices, and featuring some extra stuff controlling the pins, sensors etc. conveniently. But if you're familiar with Python, you will certainly not need any extra effort to get along with MicroPython.

To sum up: yes, it is possible to conveniently control LEGO motors using its output pins. WiPy's outputs are actually just logic pins (0 or 5V), and not power outputs, meaning there has to be some kind of power control connected to these pins. I took a relay module because I had one handy and wanted to control high-powered stuff too, though it is clear that transistors could be used as well, bringing better response time, reliability and longevity too.

So I simply let one of the relays pass the 5V supply, the same one powering the WiPy, towards a PF motor. As already known in the experimenting circles, the motors work just fine powered by 5V, but at slightly lower speed. Still, they are perfectly usable as long as you don't need plenty of power.

One of my first experiments was building a LEGO device that would physically turn my laptop on by pressing its power button. It works fine, and on the other end, it is actuated when the WiPy device receives a network command for it (which, in turn, comes from the Internet, via a bit of port forwarding and Synology dynamic DNS service). So WiPy simply allows controlling its pins via network, and in this case lets me turn my laptop on while away, and use other means to see the stream from its webcam.

Reading values is impossible with PF and an extra interface could probably be built to handle NXT/EV3 motors, but that is something I will probably do sometime later. For now, I wanted to tell about the "first success" in using WiPy, and confirm that it can indeed be used for the original purpose. It has got 24 outputs (some of which can be used as inputs if that is what you need), so a lot can be automated with it.