r/MicroPythonDev • • Jun 16 '24

microPython acting weird on Thonny

Thumbnail
self.esp32
1 Upvotes

r/MicroPythonDev • • Jul 13 '23

Experienced newbie here

5 Upvotes

Hello folks! I'm excited to start yet another journey in learning technologies. I'm a software engineer with fifteen years of experience. I have some experience in writing C++ for microcontrollers and now I'm starting to learn MicroPython. Let's have some fun together!


r/MicroPythonDev • • Sep 28 '22

Use micropython integer as value in HTML input

2 Upvotes

Hello!

I am making a webserver with a raspberry pi pico, and I want to use an integer as value for a number Input.

I think the code should be something like this but I dont exactly know how:

theInteger = 10

<input type="number" name="number" value= theInteger>

Can someone help me with this?


r/MicroPythonDev • • Sep 06 '22

Extract number from request string on pico w

3 Upvotes

Hello, I am building a web server on my pico w and i want users to be able to input a number the site, then I want to use the number to change a variable on my pico in micropython, when I enter a number into my website this is wat i get:

Request: b'GET /?led=on&number1=100&number2=200&number3=300&number4=400&number5=500 HTTP/1.1\r\n'

How do i get the numbers out of this request into my code?


r/MicroPythonDev • • Apr 29 '24

Bluetooth between micropython and standard python

1 Upvotes

I'm trying to send sensor information from my esp32s3 to my laptop through bluetooth. My esp is running on micropython.

I read that I can send information between devices using the example ble_simple_client.py and ble_simple_peripheral.py, but I was wondering if it would be possible to send information between ble_simple_client.py and a peripheral set up using standard python (specifically bleak).


r/MicroPythonDev • • Jan 12 '24

How to save to sd?

1 Upvotes

Can I save my code to sd card using repl?


r/MicroPythonDev • • Jan 17 '23

Is there language support Micropython in VScode?

4 Upvotes

the pico go extensions are great but I get some syntax errors get annoying


r/MicroPythonDev • • Mar 05 '24

Why wont my Library import correctly?

1 Upvotes

Sorry in advance for this insanely stupid question, but im slowly going insane over this.

Im teaching myself the basics of microPhython with a RaspberryPi Pico W and the VSCode Extension MicroPico.
The first couple of things worked no problem, but for days now ive been trying to control a Servo via the myservo Library.
The problem is as follows:

The "standard" Libraries that came with MicroPico are all in the Pico-W-Stub folder in my workspace and are shown as .pyi files, these import and work just fine.
I have another folder in my workspace filled with "standard" Libraries for Sensors etc. that are shown as .py files.

I have come so far as that using
from myservo import Servo

doesnt cause an error before running, but as soon as i then upload the Programm and run it, it fails
beacause no module named myservo can be found.

So obviously it just cant find the files, the thing that stumps me is that it can seemingly find them in the code as no error is shown before running and when hovering over the text it is clearly recognised as (Module) myservo.

I allready tried adding the path of the Library folder in settings.json via
python.analysis.extraPaths

Which seems to do absolutely nothing.

I also tried just putting the .py Library files into the Pico-W-Stub folder which doesnt cause any errors but also doesnt fix the Problem.

Looking for what .pyi files are exactly and if the solution could just be having to turn the .py files into .pyi files just lead to more confusing stuff.

As someone that comes from c/c++ and is used to weird stuff happening with where the Lib files have to be for the IDE to find them, this kind of baffles me and im sure im just thinking to complex and will leave in shame when someone tells me the solution to this :)


r/MicroPythonDev • • Jul 17 '22

First impression on the new Pico W

4 Upvotes

The new Pico W is awesome. I got mine just a few days ago and immediately strated experimenting with it and it was easier and better as I expected.

Mind you there is an issue with Thonny 3 (which can easily be solved) and the internal led has to be adressed in another way.

But Wifi is what I was looking for all the time. And there is great support for it in MicroPython.

Read my first impression here: http://lucstechblog.blogspot.com/2022/07/pico-w-first-look.html


r/MicroPythonDev • • Dec 28 '23

MicroPython for the ESP32: Our First Programs

Thumbnail
elektormagazine.com
4 Upvotes

r/MicroPythonDev • • Aug 21 '22

MicroPython library for PID speed and position control for N20 motors with encoders

Thumbnail
github.com
5 Upvotes

r/MicroPythonDev • • Sep 15 '23

help my graphical lcd provided code is written in hexadecimal values

1 Upvotes

any help is greatly appreciated!

i am setting up my first lcd on a raspberry pi pico i am using this waveshare lcd. ive figured out how most of the code functions other than two parts

I'm completely stumped on the self wright lines i understand they are screen commands and data but i cant find any link to what the hexadecimal code is actually doing to the screen. im a total noob so i really don't want to try writing a circuitpython program for this lcd until i know what the micropython stuff is doing

ive been scouring the web for anything remotely useful but could only find a post with someone experiencing a similar issue with another waveshatre screen from which the only thing that was mentioned was that using the wright command and data structures are faster in computing time compared to other methods of driving an lcd but still did not give any indication of what the commands are actually doing

TL/DR how do i find out what the self.right lines are actually doing so i can implement the same within circuitpython because micropython doesn't have HID support for the raspberry pi pico

lcd + resource page

https://www.waveshare.com/wiki/Pico-LCD-0.96

direct code download link in micropython

https://files.waveshare.com/upload/2/28/Pico_code.7z


r/MicroPythonDev • • May 05 '24

74hc165n PISO on raspberry pico

2 Upvotes

Hi everyone!

I'm building a raspberry pi pico based drum-machine/sequencer (whis is kinda the same thing xD)

the idea is to have 16 pairs of button/led for the steps, I managed succesfully to use the 595 to drive the led's (for now a single register I will attach a second one later) but I'm struggling a bit with the PISO 165n, by going through documentation and copying from arduino sketches (this one) I've came up with the following code to read from the register:

def in_shift_update(data,clock,clockE,latch):
val = 0
clockE.value(0)
clock.value(0)
latch.value(1)
utime.sleep(0.00005)
clock.value(1)
utime.sleep(0.00005)
latch.value(0)
for i in range(8):
val = val<<data.value()
clockE.value(1)
print(val)

data= pi:9 165:QH, latch= pi:10 165:SHLD,clock= pi:11 165:CLK,clock_e=pi:19 165:CLK INH

I also tried reading 8 times and concatenating into a string but I'm getting either 11111111 or random strings of bits, I think that I'm close to the solution but I'm failing at interpreting the clocking

component schematics here


r/MicroPythonDev • • Jul 02 '23

Micropython limited to ARM CPU?

1 Upvotes

Are there micropython builds for RISC-V, PIC (8-bit or 16-bit), or (formerly) Atmel (ATMega, ATTiny) microcontrollers?


r/MicroPythonDev • • May 04 '23

Pi Pico program times out

1 Upvotes

I have two Pi Picos with basically the same setup: Pi Pico W, BME280, 128x96 OLED display. One of them at home, one at work.

The one at home works great, I get every 10 minutes temp/press/humid values uploaded to Thingspeak.

The one at work doesn't. Every few uploads takes too long, and the watchdogtimer (8000ms) runs out and restarts the device. I tried to have the upload request in a try:/except: loop, but that didn't work either: the upload request by itself takes too long in this work-wifi (it's a special wifi for devices that can't use the landing page that's on the other wifi)

Does someone have an idea how to have this upload command work?

<snip>
# Configure Pico W as Station
wifi=network.WLAN(network.STA_IF)
wifi.active(True)

if not wifi.isconnected(): #Connect to WLAN
    print('connecting to network...')
    
    oled.fill(0)
    oled.text('connecting...',0,0,1)
    oled.show()
    
    wifi.connect(ssid, password)
    wdt.feed()
    
    LedBlink(.1) # turn on the on board Led for .1 seconds and turn it off again.
    time.sleep(.1)
    
    while not wifi.isconnected():
     pass
    
print('network config:', wifi.ifconfig())

setTimeRTC() # Get time and date from NTP and set the RTC on the device

LedBlink(.5) #Blink twice to show we have a wifi
time.sleep(.1)
LedBlink(.5)

oled.fill(0) #Show the received IP address on the display
oled.text('IP Address:',0,0) 
oled.text(str(wifi.ifconfig()[0]),0,16)
oled.text('Gateway:',0,32) 
oled.text(str(wifi.ifconfig()[2]),0,48)
oled.show()

CountDown(3) # show a line getting shorter for 3 seconds

FlashDisp(.1) # blink the full display white for .1 second

starttime = getTime() # get the current timedate and convert it to a string

while (True):
    
    # feed the dog!
    wdt.feed()

    timestamp = getTime()
    
    temp = ReadTemp()
    press = ReadPress()
    hum = ReadHum()
    
    # Show the time on the display
    oled.fill_rect(0,54,79,54,0)
    oled.text(timestamp[-8:],0,54,1)
    oled.show() #Show new info
   
    # 1x per day
    if timestamp[-8:] == '03:00:00': #03:00 in the night
        setTimeRTC() # set the correct time from NTP
        
        time.sleep(.9)
        
    if timestamp[-4:] == '0:00': # every 10 minutes
          
        # Prepare the values for upload
        dht_readings = {'field1':temp, 'field2':press, 'field3':hum, 'status':getTime() + ' - ' + str(number) + ' - ' + temp + 'C/' + press + 'hPa/' + hum + '% - ' + str(wifi.ifconfig()[0]) + ' - start: ' + starttime}
        
        # Upload values
        # here is where the error lies
        request = urequests.post( 'http://api.thingspeak.com/update?api_key=' + THINGSPEAK_WRITE_API_KEY, json = dht_readings, headers = HTTP_HEADERS )  
        request.close()
        
        number += 1
               
        LedBlink(.5)
        
        time.sleep(.1)
        
    if timestamp[-2:] == '00': # Once every minute
<snip>

r/MicroPythonDev • • Apr 29 '24

Animating Bitmap Array

1 Upvotes

I have a RP2040 connected to a TFT LCD display and touch screen. There's a main program loop that waits for specific touch inputs and acts accordingly by either running code for that specific screen or switches to another screen and waits for input again.

When the program loads, I have a splash screen where I would like to display a simple animation until a specific touch input is performed (long press). I have a bitmap array of four frames that needs to step through every half seconds. The problem I have is that adding a call to sleep() blocks input from the touch screen and using a timer to draw the bitmap every half second also seems to conflict with other timers.

Is there a better way to do this in micropython? As I understand it, threading isn't very stable so I haven't gone down that road yet.

EDIT: I ended up using a single timer to update some variables that the main loop references to draw frames/put the device to sleep. This seems to work well for what I need to do.


r/MicroPythonDev • • May 17 '23

Any tutorials?

1 Upvotes

Are there any step by step tutorials on using Bluetooth, I don't know how to install it on windows


r/MicroPythonDev • • Oct 07 '23

Cannot reach Python with a D1 Mini board

Thumbnail self.arduino
1 Upvotes

r/MicroPythonDev • • Dec 07 '23

Input issue

1 Upvotes

Hi I am having issues with input in micropython esp32 that i cant really type anything in

code:
import network

from machine import Pin, SoftI2C

import ssd1306

import time

import socket

i2c = SoftI2C(scl=Pin(22), sda=Pin(21))

oled_width = 128

oled_height = 64

oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)

sta_if = network.WLAN(network.STA_IF)

ap_if = network.WLAN(network.AP_IF)

sta_if.active(True)

sta_if.connect("-", "-")

for i in range(200):

if sta_if.isconnected():

break

time.sleep(0.1)

if not sta_if.isconnected():

raise ValueError

host = "-"

port = -

time.sleep(1)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

s.connect((host, port))

data = s.recv(1024).decode("utf-8")

print("Received: ", data)

s.sendall(data.encode("utf-8"))

inp = input("whatever ")

print(inp)


r/MicroPythonDev • • May 27 '24

[Potential Bug] Esp32s3 fails entirely when using ESPNow

1 Upvotes

I accedently tried to add a ESPNow peer with mac address being an empty string (as shown in image), and after flashing and running the file, my esp32 device immediatly disconnected from the COM port and became not discoverable. So I have to manually re-flash the micropython firmware in flash mode (plug in the computer with boot button down to get the COM port). I tried this exact statement again with the flash rewritten, and the device commited suicide once again. Can anyone try if this is replicatable on other esp devices?

I am using the esp32-s3fh4r2 chip with the latest micropython and esp-idf version. The code I use came from the Micropython Doc, where e is a instance of ESPNow.

I then re-flashed firmware along with the followng code, where a buzzer is attached to on of the pins to see if it works properly after fail - and indeed it is not working properly by producing periodic noise after fail:

from espnow import ESPNow

# sets up buzzer
buz = PWM(Pin(1, Pin.OUT), freq=985)
buz.duty_u16(32767)

# wait for 5 before adding the pair
time.sleep(5)

# code from mpy doc
# A WLAN interface must be active to send()/recv()
sta = network.WLAN(network.STA_IF)  # Or network.AP_IF
sta.active(True)
sta.disconnect()  # For ESP8266
e = ESPNow()
e.active(True)

# fails here:
e.add_peer('')

EDIT: the period buzzer noise and the COM port disconnection came from rapid resets but not about flash problem... Is this resetting behaviour a bug?


r/MicroPythonDev • • Aug 14 '22

Driving a specific oled without i2c on micropython

2 Upvotes

Hi, im wondering how i can drive an ssd1306 64x48 0.66" that has 16 pins and doesnt have sda nor scl with a raspberry pi pico.

I have tried all the videos that say to use d1 and d2 as sda and scl (idk if by this order) but it didnt work, so yeah, i have been searching solutions for a few months now and i havent found any that works, hope someone can redirect me to some useful link or thread, thanks.


r/MicroPythonDev • • Dec 23 '22

pylogix micropython port development

Thumbnail self.plc
4 Upvotes

r/MicroPythonDev • • Aug 16 '22

Espresso IDE for android

1 Upvotes

Does anyone know what happened to the apk or if it was ever legit to begin with? If not, does anyone know of a good ide for android? I don’t have consistent access to a desktop/laptop and my Linux in android doesn’t have enough power to usable (I don’t think)


r/MicroPythonDev • • Jun 29 '22

Thonny freezing while opening a file

2 Upvotes

I had it working well before so must have done something wrong obviously. Whenever I am trying to open .bin firmware file for flashing it freezes Thonny. More so if I am trying to do exactly the same it freezes Mu Editor as well! Weirdly enough I can do anything else in both. Has anyone got a clue what I have done wrong? Last thing I was trying to do before it started to happen was copying nano-gui directory to my ESP32 (which did not happen unfortunately) I am a bit lost as I am not professional but more like a hobbyist in this field.

Anybody could help please?


r/MicroPythonDev • • May 21 '23

unzip a zip file on the raspberry pi pico??

1 Upvotes

i know how to get downloading to work on a raspberry pi pico w, but i want to unzip the file after its downloaded. how do i do this since im making a app downloader for a pico handheld im making?