Showing only posts from category: MicroPython

Blynk

Read more

#MicroPython: Home Automation using Blynk connected to a WiPy 3.0 / 2.0


This time a quick tutorial to control your WiPy 3.0 / 2.0 or an ESP32 using Blynk.

Blynk is the most popular mobile app for the IOT. Works with anything: ESP8266, Arduino, Raspberry Pi, SparkFun and others.

I found a library to connect MicroPython to Blynk but it is only compatible with the WiPy 1.0. Thus, I modified it and made it compatible with the WiPy 3.0 / 2.0 and with the ESP32 running MicroPython. If you do not have any idea about MicroPython, I recommend you to read this tutorial.

This is what I will try to accomplish in this tutorial:

  1. Install MicroPython (if you are using an ESP32, otherwise it is already installed on your WiPy)
  2. Connect the WiPy or the ESP32 to Blynk

Let's start! but first the code:

Python Code: https://github.com/lemariva/uPyBlynk

Micropython Jupyter

Read more

#MicroPython: Programming an ESP using Jupyter Notebook


I was looking at my last articles about MicroPython and my new articles about Jupyter and Docker, and I thought if it is possible to make a mix between Jupyter and the ESP boards. I use usually Visual Studio Code to program the ESP but for analytics I use Jupyter. I looked if it was possible to connect the Jupyter kernel to the ESP using the serial port and: Yes!, it is possible. This can be a great tool to teach kids to access data from connected sensors and analyze it using a browser with Jupyter.

This is what I will try to accomplish in this tutorial:

  1. Install MicroPython
  2. Install the Jupyter Kernel:
    • on a host PC
    • inside a Docker Container
  3. Connect the Jupyter kernel to an ESP32
  4. Use a ST7735 display using Jupyter
  5. Get data from sensors

Let's start! but first a video example:

Happy new year 2019 min

Read more

Happy New Year!


Out with the old, in with the new! Happy 2019!

It's been a two years now since I started this blog. It's a hard job to maintain it up-to-date but I still have fun writing and coding for this purpose! I hope the next year will be better than this one! :)

This post includes a new video for happy new year! The video combines some of the MicroPython code, that I've published this year. I'll be uploading the repo to GitHub in the next days. But, in the meantime enjoy the video, and check the MicroPython projects here!

Micropython vscode min

Read more

#MicroPython: Visual Studio Code as IDE


Quoting the official MicroPython's website:

MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimised to run on microcontrollers and in constrained environments.

Besides C++ and C, I use MicroPython to program microcontrollers, especially the ESP32/ESP8266 types. These two microcontrollers are compatible with MicroPython and it is easy to integrate sensors and actors programming using this language. I wrote a tutorial about installing MicroPython on the ESPs, as well a lot of articles about these microcontrollers and MicroPython. This is an update to the "Getting started with MicroPython": I am changing from Atom to Visual Studio Code (VSCode), and using the PyMakr extension, it is possible to program and debug MicroPython on VSCode.

Marry christmas banner min

Read more

Merry XMAS and Happy 2019!


LeMaRiva|tech wishes you a Merry Christmas and a Happy New Year! To celebrate I made a video using the Xmas-lights from last year, but this time I connected the ESP32 to a Jupyter kernel to control the lights. A new Jupyter-ESP32 tutorial is coming soon. In the meantime, you can track Santa and spend time with your family!

Python Code: https://github.com/lemariva/Xmas-lights

Teckin ESP32

Read more

#Zerynth: ESP32 & Google IoT Core - Part 2: Getting data from Smart Power Outlets


This part 2 of the tutorial will allow you to get data from the smart power outlets and send it to the Google Cloud Platform (GCP) throught the Google IoT Core and using an ESP32 programmed with Zerynth (Python). This data is not usually available to the user (directly, you need to use the power outlet application), and it is sent to the company servers.

If you want to check, if your power outlets are compatible for this tutorial, they should have the port 6668 opened. To check that:

>>> nmap <<ip-address>> -p 6668
[...]
Host is up (0.13s latency).

PORT     STATE SERVICE
6668/tcp open  irc

If the answer is as shown above, the port is opened. If you don't have the nmap application and you are on Windows, look at the Nmap Network Scanning tool. On Ubuntu type on a terminal sudo apt-get install nmap.

Teckin ESP32

Read more

#MicroPython: Controlling Smart Power Outlets using an ESP32


Today there is a wide range of offer for home automation devices. A lot of sensors, actors etc. can be connected to the cloud and be controlled using Google Home, Amazon Alexa, your smartphone, etc. There are a lot of companies offering low cost devices, e.g. Sonoff, Tuya, Teckin etc. Most of these solutions are based on ESP32 or ESP8266, and all of them send data to cloud solutions usually deployed on Amazon services, and the data is only accessible using the Android/iOS applications. They can be also controlled using voice commands over Google Home or Amazon Alexa devices.

Nice, but... my aim was to control these devices locally (using LAN and not Wi-Fi) and send the data to the Google Cloud Platform (GCP) to make some analytics later. To be clear, when you use the Android/iOS application (or Google Home/Amazon Alexa) and you switch on/off e.g. a smart power outlet, the application connects with the company server in which the smart power outlet is registered and it sends the command. Then, the server sends back the action to your smart outlet. An exception is Amazon Alexa that sometimes connects directly to the devices (e.g. Belkin switches / Philips Hue), when you are at home on the same network (Wi-Fi). That's why you can re-program the Sonoff devices using Sonoff-Tasmota and then, you don't need a cloud connection anymore. However, if you use Google Home, this is not possible.

To sum up the aim of this post: Using this tutorial, you'll be able to control locally (LAN) most of the low-cost smart power outlets using an ESP32 programmed in MicroPython. Additionally, you can use the available data to do some analytics.

Note: Application like home assistant allows you to make this too, but you need at least a Raspberry Pi to run it, and that means power consumption. That's why, I like to do this with an ESP32 and of course, using MicroPython!

ESP32 LoRa

Read more

#MicroPython: ESP32 sending data using LoRa


LoRa (Long Range) is a patented digital wireless data communication technology. It was developed by Cycleo of Grenoble in France and then acquired by Semtech in 2012. Semtech defines the Lora Technology "as the DNA of IoT, which connects sensors to the Cloud and enables real-time communication of data and analytics that can be utilized to enhance efficiency and productivity".

To sum up, LoRa is a wireless data communication technology that enables very-long-range transmissions (more than 10 km in rural areas) with low power consumption. It uses license-free sub-gigahertz radio frequency bands as the 169 MHz, 433 MHz, 868 MHz for Europe and 915 MHz for North America. The technology can be divided in two parts:

  • LoRa: the physical layer,
  • LoRaWAN (Long Range Wide Area Network): the upper layers.

Here the code:

Python Code: https://github.com/lemariva/uPyLora

Rpi zero rt performance min

Read more

#Zerynth: ESP32 & Google IoT Core - Part 1: Sending data to the Cloud


There are lot of tutorials about connecting the ESP32 to a cloud service, but I planned to connect these boards using MicroPython directly to the cloud. That means, I didn't want to use a hardware or software bridge. I wanted to use the Google IoT Core, but MicroPython doesn't support JSON Web Token (JWT), which is needed for the device authentication. I tried to write the library myself, but it didn't work, because of the needed dependencies and the small memory available on the ESP modules. But, I found Zerynth. Zerynth supports JWT and using it, it is possible to connect the ESP32 directly to the Google IoT Core. The company Zerynth defined its product as "the middleware for IoT and Industry 4.0" and the ecosystem was stable as far as I tested it. The IDE (Zerynth Studio) can be a little bit improved, but it works well enough.

Zerynth is neither free nor open-source but every new user gets a welcome pack with 10 Zerynth VM licenses with FreeRTOS (5 Starter and 5 Premium) for free (more info here). If you need to register more sensors, you can use the store to purchase the additional licenses.

Important NOTE: I didn't get any money to promote Zerynth, I just wanted to use Python to connect the ESP32 directly to the Google IoT Core and this was the only option that I've found. If you know another one, please comment this post or send me a message. Thanks!


MicroPython

Read more

#MicroPython: Camera stabilisation application


To continue the series of posts "connecting sensors to MicroPython", this article is about the MPU6050 (you can use also the MPU9255, I am still waiting for the Chinese sensor package) and the WiPy 3.0. Combining the IMU sensor with the WiPy and two micro servos 9g, it is possible to stabilize a camera (tilt/rotate).

To calculate the compensation needed for the stabilisation, I added the umatrix, quaternion and ulinalg libraries to the project to make matrix multiplication and quaternion to Euler conversion. The ahrs library from Madgwick fusions the data of the accelerometer, gyroscope (and magnetometer, only with MPU9255) and allows to calculate the rotation of the IMU in quaternion coordinates. I rewrote (most of) the libraries to be compatible with MicroPython.


Wemos micropython min

Read more

#Tutorial: Getting started with MicroPython: Sensors - Part 1


One of the most visited articles on my blog is the Getting started with MicroPython! tutorial. If you still don't know what is MicroPython and you want to start programming microcontroller boards (ESP32, ESP8266 etc.) using a small version of Python 3, you should look at that article. Don't expect to use machine learning or/and other big libraries (the available RAM and microcontroller performance is far away for that aim), but you can do some projects like these:

Wemos & MicroPython

Read more

#Tutorial: Installing dependencies on MicroPython


While I was reading my getting stated tutorial about MicroPython again, I noticed that I've forgotten to tell something about dependencies or packages.

Here is possible to find some MicroPython packages. On the WeMos or the ESP8266, it is possible to install these packages using the upip package manager. The WiPy doesn't have the package.

Wipy2.0 Xmas-lights

Read more

#Micropython: Merry Xmas & Happy New Year!


It has been a while since my last post! Sorry, I was a little bit busy and then I was on a business trip in Melbourne for the CDC2017 and then I had a week holiday in Bangkok. I will be posting some photos on the next days!

It's been a year now since I started this blog. It's a hard job to maintain it up-to-date but I still have fun writing and coding for this purpose! So let us start!


The first video that I published a year ago was using the Wipy2.0 and a WS2812b led strip for some Christmas lights (click here). Now, this time I bought a WS2812b panel (100 bits or 10x10 pixels -or leds- see fig. 1) and as we have/had christmas again, so I wrote some code for this panel to make again some Xmas lights! :).

WiPy & Geolocalization

Read more

#MicroPython & #WiPy 2.0/3.0: Geolocation using WLAN


I was surfing the services that Google offers, I found the Geolocation API. As Google describes the API: it returns a location and accuracy radius based on information about cell towers and WiFi nodes that the mobile client can detect. As I was writing the last post using MicroPython, I thought the WiPy 2.0 could be a nice "mobile client".

To use the API you need to get an API key from Google. As a standard user of the API, you get:

  • 2,500 free requests per day, and
  • 50 requests per second, per user.

I thought I could play with it to test the accuracy of the geolocation.

Python Code: https://github.com/lemariva/uPyGeo

If you’re not up to speed with MicroPython, Wipy see earlier articles in here.

Wemos & Amazon Echo

Read more

#MicroPython: WeMos (ESP32) and Amazon Echo (Alexa) - Switching LED Colors!


I don’t have any Belkin WeMo system or Philips Hue light bulbs. However, I have two ESP32 running MicroPython (see my last article), and a W2812b LED strip, and I thought I should be able to say, "Echo/Alexa, turn on the kitchen light" or "Echo/Alexa, turn on the blue light" and It should work with this setup.

And... it works as you can see in this video!

If you are interesting in only using the code, then click here. Otherwise, you can read the complete story... ;)

Python Code: https://github.com/lemariva/uPyEcho

If you’re not up to speed with MicroPython, Wipy see earlier articles in here.

  • 1
  • 2