r/MicroPythonDev • • Feb 28 '21

New Here? Reply to say hi!

6 Upvotes

Have you ever used MicroPython?

Let me know!


r/MicroPythonDev • • Oct 10 '21

Index of hardware timers in machine.Timer

2 Upvotes

Hello everyone. I'm looking to find out how to set the ESP8266 Hardware timer in Micro Python. I'm pretty new here, just started using Micro Python some days ago but know C, Python... So it was an easy start. Ok, I read trough the Doc's but there does not seam to be any specific way on setting the 32Bit hardware timer with NMI source (so it can interrupt every other timer) I can't even find out witch of the timers (I tried -1, 0, 1) is the real deal (and not a Software Timer). Pleas help!

Thx

David


r/MicroPythonDev • • May 03 '21

MicroPython Newsletter Issue 11

Thumbnail
forum.micropython.org
4 Upvotes

r/MicroPythonDev • • Mar 02 '21

Pi Pico and MicroPython library documentation?

3 Upvotes

Hey all, I'm incredibly new to micro controllers and scripting in Thonny so apologies if the answer here is blatantly obvious.

I've been following along with the "Get started with MicroPython on Raspberry Pi Pico" book and it's been great. I've started tinkering on my own, and fully understand why we import libraries (like import machine or import utime), however one thing I'm stumped on is knowing what functions are actually available in a library, and what they do?

For example, I know the machine library has Pin (because it's used in all the tutorials), however how do I find out what other functions the machine library has available?

I feel like there's all these neat functions locked away but I have no clue how to find out what they are, and googling for documentation has failed me. Is there a way to find out what each library contains?

Thank you!


r/MicroPythonDev • • Feb 28 '21

Micropython SmartHome Node, integrate your devices to Home Assistant with MQTT.

10 Upvotes

https://github.com/kevinkk525/pysmartnode

I'm posting it because I didnt knew this lib before I spent a decent amount of time developping code to integrate my devices (lights) with HomeAssistant.

Until finding this lib, that did the work better and had more features.

It's pretty easy to implement new devices and you only need a couple of configuration files to setup your projects.


r/MicroPythonDev • • May 08 '21

Me, my dog, and micropython

1 Upvotes

Hello all!

I have a little project to work on hopefully using a couple of D1 mini boards programmed with my favorite little language, Micropython. I'm afraid I'm about as novice as they come, so I'm looking for some advice.

My dog, bless his little heart, has really bad separation anxiety. He doesn't bark when I'm gone, but instead lets out a low and very melancholy howl. Because most sound activated devices on the market are built to react to loud barking, they don't pick up on my little dudes voice. I think if there were a way to interrupt his howling it would stop the spiral and he would calm down, but nothing I've bought or read about online has worked so far.

I am aware of the issue because my next door neighbors tell me about it. Luckily we're good friends so there is no animosity, but its definitely negatively effecting their lives. So I had the idea, why not put some control into their hands?

The device I had in mind would simply be this; an esp8266 connected to a small speaker that emits a high frequency tone that only the dog can hear and another esp to act as a wireless remote to activate the speaker in short bursts (we live very close together and in fact we both live in yurts so I don't think there would be any problems sending signals from one home to another).

So here are my questions,

Is it possible to generate high frequency tones with micropython? If so, what hardware is appropriate? Is there a way for the esp's to communicate without connecting to an exterior wifi network? I don't have home wifi.

Thanks in advance!


r/MicroPythonDev • • Apr 23 '22

Need Help: pyBricks stopwatch in LEGO Mindstorms with nanoseconds

1 Upvotes

Hello,

I am using my LEGO Mindstroms EV3 with pyBricks and want to stop the time in nanoseconds. Sadly, the stopwatch class from pyBricks returns only second, but i need it much more precise than this. As far i know, the EV3 is running microPython. Is there a way to do so?


r/MicroPythonDev • • Apr 13 '22

Working with MIT App Inventor on my ESP32 with Bluetooth

4 Upvotes

Hey dear app-Inventors!

So today I spent a whole day trying to work out a Micropython code to work with MIT-App Inventor. There's a basic Micropython-sketch available and it works only with Serial Bluetooth Apps like Serial Bluetooth Terminal or nRF Connect.

So I followed Microchip University's Guide (you have to click on curriculum, navigate to resources and register, but it's really worth it!) to get it working and my success was to scan for BLE Devices, yet I still couldn't connect to my ESP32. I learned that the Classic Bluetooth isn't really supported in Micropython on the ESP32, and the MIT App didn't work at all with classic Bluetooth, when I tried it. All the Micropython tutorials were using the Serial Bluetooth Apps for communication, I also got that working for me. For BLE in the MIT App Inventor, I had to set UUIDs for Service, Receive and Transmit, which I copied out of the Micropython Sketch. I understand that they're needed to address where the data is sent and received. The App from Microchip University which I replicated had me also some questions open, like variables for ble itself. For example I had to set the ble_mac_address, which I understood to type in the MAC-address from the ESP, also I gave the ESP a name, where I had to put in the Name from the code as in ble_name = ESP32BLE (you'll also find that in the uPython-Sketch) but a third variable had to be defined which was ble_address. I don't know exactly what was meant here and the guide doesn't really show as well. Also there was an open part of code in the direct-connection which made not much sense.

If anyone can help me get this working, I'd be so relieved, all I wanted was to connect my ESP via Bluetooth with an App to control a robot car. Should I ditch it all and go for Arduino? I like Micropython so much more :x Arduino takes ages to compile. Also, does Arduino simply make the Classic Bluetooth happen on the ESP?


r/MicroPythonDev • • Feb 28 '21

Anyone tried to use cpppo library with micropython?

2 Upvotes

r/MicroPythonDev • • Dec 24 '21

Pan Tilt controlled by Raspberry Pi via micropython

Thumbnail
youtube.com
3 Upvotes

r/MicroPythonDev • • Mar 04 '21

Fun with the NeoPixel on the WiPy development board.

Thumbnail
matthewfelgate.wordpress.com
1 Upvotes

r/MicroPythonDev • • May 31 '22

What is the status of MicroPython support on VS Code?

8 Upvotes

I'm using VS Code for Python and C/C++ programming and would like to stay with it for MicroPython as well. The extensions I found seem marginal in popularity, no longer developed (https://github.com/dphans/micropython-ide-vscode) or targeting narrow range of hardware (https://github.com/pycom/pymakr-vsc). What is the current status of MicroPython extensions for VS Code supporting RP2040, SAMD and ESP32? Does anyone have good experience and can recommend a specific extension?


r/MicroPythonDev • • Feb 06 '22

Pi Pico Blinking light is backwards.

2 Upvotes

I am trying to blink a light on my Pi Pico, and the light blinks, at regular intervals... just not how I would expect it to. When I turn the pin "off", it gets power, and when I turn it "on" it does not. Is there a way to fix this? Seems to be the case with circuit python as well... have not tried any other firmware. Here is the code I'm using currently to read a button on GPIO 15, and change the like at GPIO 3.

import time
from machine import Pin

led = Pin(3, Pin.OUT)    # create output pin on GPIO3
button = Pin(15, Pin.IN) # create input pin on GPIO15

led.on()                 # set pin to "on" (high) level
time.sleep(1)
led.off()                # set pin to "off" (low) level
time.sleep(1)

while(1):
    if button.value():
        led.off()
        print("Led is on")
    else:
        led.on()
        print("Led is off")
    time.sleep(1)

I also tried something in PIO(I think thats what it's called), and it did the same reversed behaviour.

from machine import Pin
import rp2

@rp2.asm_pio(set_init=rp2.PIO.OUT_LOW)
def blink_1hz():
    # Cycles: 1 + 7 + 32 * (30 + 1) = 1000
    set(pins, 1)
    set(x, 31)                  [6]
    label("delay_high")
    nop()                       [29]
    jmp(x_dec, "delay_high")

    # Cycles: 1 + 7 + 32 * (30 + 1) = 1000
    set(pins, 0)
    set(x, 31)                  [6]
    label("delay_low")
    nop()                       [29]
    jmp(x_dec, "delay_low")


    # Cycles: 1 + 7 + 32 * (30 + 1) = 1000
    set(x, 31)                  [6]
    label("sleep1000")
    nop()                       [29]
    jmp(x_dec, "sleep1000")



# Create and start a StateMachine with blink_1hz, outputting on Pin(25)
sm = rp2.StateMachine(0, blink_1hz, freq=3000, set_base=Pin(3))
sm.active(1)

r/MicroPythonDev • • Oct 09 '21

Raspberry Pi Pico: Add audio to animation

Thumbnail
youtube.com
2 Upvotes

r/MicroPythonDev • • May 13 '21

MicroPython I2S Audio with the ESP32

Thumbnail
youtube.com
5 Upvotes

r/MicroPythonDev • • Apr 20 '22

Can't import a single library

1 Upvotes

Hello ! I'm working on a project where I use a FiPy Board and a temperature sensor (SHT31), i'm supposed to send the data using LoRawan. But while importing the sensor library (found on GitHub) I have an error telling me that there is no module named sht31.py even if it's in the same repertory as my main.py, I thought that it was that specific librray problem so I created another empty python file that I tried to import feom the main file, I keep having the same error :) Does anyone know how to solve this ? (个_个) Thank you ! EDIT : I thought visual code uploads automatically the code when i click on run but i had to click on "upload" button that i didn't see... Hope that this will help someone someday


r/MicroPythonDev • • Jun 01 '21

Micropython module for telegram bots

Thumbnail self.esp32
7 Upvotes

r/MicroPythonDev • • Apr 13 '22

Unable to put code in separate modules due to apparent memory allocation fail

1 Upvotes

I'm using a 1.54" LCD screen with my raspberry pi pico, and I want to put a big chunk of code that draws something to said screen in a separate module. The code to initiate the screen is the following, and is what seems to be giving me my issue:

buffer = bytearray(BreakoutColourLCD240x240.WIDTH * BreakoutColourLCD240x240.HEIGHT * 2)
display = BreakoutColourLCD240x240(buffer)

Since all the display functions have to be preceded by display. I have to define display in both my main script, and the separate script. However when I do so, I get this error:

MemoryError: memory allocation failed, allocating 115200 bytes

I'm stumped as to how to have code in a module to be referenced in my main.py for later use. Any help would be appreciated!


r/MicroPythonDev • • May 31 '22

Performance reality

2 Upvotes

Hi guys!

I am fairly fresh to python and total noob with any other programming language.
Staring my journey with microcontrollers as I find it fun and useful.

However I have been strongly advised to stay away from micropython for boards such as TTGO display or even ESP32. Few experienced programmers highly recommended C & C++ for those boards saying they are more efficient and generally this is how it is done.

As you can imagine both of those are not as easy to write as python and it will take me w good while to learn other languages in order to make my ideas reality.

What are your experiences with micropython and microcontrollers in regards to for examples plotting graphs on the displays?


r/MicroPythonDev • • May 25 '22

I made a module to create simple games

9 Upvotes

I've just released a library to craft games in micropython and arduino

this is a very simple demo!
You can find everything on github https://github.com/polldo/dolp

Check this out!!


r/MicroPythonDev • • Apr 25 '22

Protocol Buffer implemetation for MicroPython

3 Upvotes

Hi everybody,

This library was inspired by https://github.com/jazzycamel/micropython-uprotobuf. I've spent a fair amount of time triing to fix encode-decode issues in it.

Then I decided to write my own implementation from scratch.

As a result I have https://github.com/T0ha/uprotobuf.

I tried to keep it as simple, lightweigh and ideomatic as possible.

Currently, it implements only main features, but I'm going to enhance it.

Any help, code review and suggestions are appreciated.


r/MicroPythonDev • • Apr 15 '21

How fast and reliable is MicroPython?

2 Upvotes

Hello, I have been playing around with micropython from time to time and as far as I got is to make my esp32 boards to pull time from internet and report to a server with a sensors data and time over mqtt. And here my knowledge stops. I never used it for more serious things like to use it on field and didn't have to relay on it that much. I want to start small business and I am planing to use esp32 and micropython on it, so I have a lot of question and fears. I hope that you can help me with some of them.

So, can you please tell me your experience with micropython in real world scenarios and answer to my following questions:

  • How fast it is?

  • How reliable it is? Did you use it for some mission critical systems or some sort of critical systems?

  • Did you have a problem with lack of flash storage (for those who used it on esp32 and esp8266)?

  • What was your biggest issue that you had with micropython?

  • What advice can you give me regarding this language that I am probably not aware of?

Thank you!


r/MicroPythonDev • • Mar 02 '21

micropython on a Sparkfun ATP board

1 Upvotes

Their MicroMod board is a great concept, if it worked. You have a main board with an M.2 connector, the ATP board, where you can swap the processor that's on a tiny board. I'm unable to get MicroPython installed on it; it's failing at the first step. Has anyone used MicroPython on this thing?

See picture 6 and the ones after it:

https://www.sparkfun.com/products/16781

$ esptool --chip esp32 --port /dev/ttyUSB0 erase_flash
esptool.py v2.5.1
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____..
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse
MAC: 24:6f:28:8f:5b:f8
Enabling default SPI flash mode...
Erasing flash (this may take a while)...

A fatal error occurred: ESP32 ROM does not support function erase_flash.

I've posted a query on their forum; hopefully someone will have a solution there but I thought I'd ask here as well.


r/MicroPythonDev • • Dec 04 '21

Basic Syntax questions

2 Upvotes

Hey Everyone! I’m working on a project that makes good use of the Pico hardware, so thought i would give MicroPython a go, Im just about dangerous in C.

So, i have a very basic hang-up in my project, I’m 99% sure I’m just ignorant, but having a hard time finding similar low-level questions after an afternoon Googling,

For the life of me I cant can’t get the syntax right for or, a simple, “return true if a string is one of two options”

Is there anything obviously wrong with:

direction = input (‘Clockwise or counterclockwise? ‘)  
If direction != (‘cw’ or ‘ccw’):
   print (“unknown direction”)
   Continue
else:

. . . .

Everything works as I am expecting it too if i only give myself one option after if direction !=

Any help appreciated!


r/MicroPythonDev • • Apr 03 '22

Why this execute just the first task?

Thumbnail
gallery
4 Upvotes