Förbereder Raspberry Pi Pico W för programmering i MicroPython
Ladda upp firmware för MicroPython
Sätta upp utvecklingsmiljön Thonny
Att välja rätt mikrokontroller och port
Testar installationen
Integrera Pico W i WLAN-nätverket
adress som används
Seriell enhet i bruk
Leverans av en webbplats
Styrning av lysdioder via hemsidan
Pinout des Raspberry Pi Pico
konstruktion av kretsen
anslutningsplan
Källkod - styr lysdioder via hemsidan
Upprätta anslutningen till Wi-Fi-nätverket
Levererar hemsidan med knapparna
"Reagera" på en knapptryckning
aktivera/avaktivera en lysdiod
Det färdiga programmet
Förbereder Raspberry Pi Pico W för programmering i MicroPython
Först ville jag använda den välkända Mu Editor för programmering. Han erbjöd mig också att installera en motsvarande firmware för MicroPython. Detta är dock inte kompatibelt med Pico W och jag upptäckte att den fasta programvaran som är länkad i ovanstående dokument (https://datasheets.raspberrypi.com/soft/micropython-firmware-pico-w-290622.uf2) är obligatoriskt för mikrokontrollern.
När du har laddat in den nästan 1,3 MB stora UF2-filen måste du starta din mikrokontroller i lämpligt läge.För att göra detta, håll ner "BOOTSEL"-knappen och anslut USB-kontakten till uttaget. En enhet "RPI-RP2" ska då visas i Utforskaren.
Vi kopierar nu den här filen till den här enheten. Efter lyckad kopiering startar mikrokontrollern om och ingen enhet visas!
Sätta upp utvecklingsmiljön Thonny
För utveckling använder vi utvecklingsmiljön Thonny som du kan ladda ner gratis påhttps://thonny.org/för Microsoft Windows, macOS och Linux.
I mitt fall använder jag versionen för Microsoft Windows.
Om filen på nästan 17,5 MB har laddats ner och installerats (inga speciella inställningar behöver göras under installationen). Kan detta startas och utvecklingen startas?
Jag har redan använt Thonny IDE i olika inlägg på min blogg och skulle vilja gå in i detalj här om hur du programmerar din Raspberry Pi Pico W så att du kan integrera den i ditt nätverk.
Att välja rätt mikrokontroller och port
När Thonny IDE startas måste vi välja rätt mikrokontroller och port. För att göra detta klickar vi på texten "Python 3.7.9" i det nedre högra hörnet och väljer posten "Konfigurera interpeter..." från snabbmenyn.
(Video) Pico W Wi-Fi Doorbell - With HTTP Requests and IFTTT
I den nya dialogrutan "Thonny Extras" ska fliken "Tolk" väljas och öppnas. Vi måste sedan välja posten "MicroPython (Raspberry Pi Pico)" och porten från urvalslistan.
Om du har flera enheter anslutna till din dator (detta är inte ovanligt) kan du även visa alla seriella enheter i Windows Enhetshanteraren (Windows-tangenten + X, Enhetshanteraren) under "Portar (COM & LPT)".
Strängen "Hello World!" ska nu matas ut varje sekund.
Integrera Pico W i WLAN-nätverket
I dokumentet https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf hittar du ett enkelt exempel på hur du ansluter till WLAN.
import networkimport timessid = '*****'lösenord = '*******'wlan = nätverk.WLAN(nätverk.STA_IF)wlan.active(True)wlan.connect(ssid, lösenord)print("Väntar för att ansluta:")while not wlan.isconnected() och wlan.status() >= 0: print(".", end="") time.sleep(1)print("")print(wlan.ifconfig( ))
Om vi startar skriptet med "Play Button", så matas teckensträngen "Waiting to connect:" ut på konsolen och under loopen är det alltid en periodutgång och en väntan på en sekund.
MicroPython v1.19.1-88-g74e33e714 den 2022-06-30; Raspberry Pi Pico W med RP2040 Skriv "help()" för mer information.>>> %Kör -c $EDITOR_CONTENTWartar på att ansluta:.......('192.168.178.70', '255.255.255.0', '192.168. 178.1', '192.168.178.1')>>>
När anslutningen har upprättats matas Picos IP-adress ut. Men eftersom vi inte distribuerar en webbplats finns det inget att se när vi skriver in IP-adressen i webbläsaren.
Fel vid återanslutning och laddning av kod
adress som används
Under utvecklingen kan det hända att du vill ladda upp ny kod till Pi Pico W och IP-adressen som redan har tilldelats släpps inte eller kan återanvändas.
Detta bekräftas med följande felmeddelande:
Spårning (senaste samtalet senast): Fil "", rad 56, i OSError: [Errnr 98] EADDRINUSE
Lösningen på detta är ganska enkel, koppla bara ur USB-kabeln från datorn, vänta några sekunder och koppla in den igen.
I Thonny IDE måste du också trycka på "Stopp"-knappen (eller Ctrl+F2) från verktygsfältet och sedan kan du trycka på "Kör"-knappen (eller F5).
(Video) Raspberry Pi - Video Adapter
Seriell enhet i bruk
Om du får följande felmeddelande är det enda som brukar hjälpa att starta om datorn.
Det gick inte att ansluta till COM32: kunde inte öppna porten 'COM32': PermissionError(13, 'Zugriff verweigert', None, 5) Om du har seriell anslutning till enheten från ett annat program, koppla sedan bort den där först. Backend avslutad eller frånkopplad. Använd 'Stopp/Starta om' för att starta om.
Leverans av en webbplats
Efter att ha anslutit till det lokala Wi-Fi-nätverket, låt oss servera en liten webbsida. Först ska bara en enkel teckensträng "Hello World!" visas.
I mitt fall lägger jag in texten i en rubrik, HTML-tagg H1.
importera nätverksimportsocketimporttid från maskinimport Pinssid = '*****'lösenord = '********'wlan = nätverk.WLAN(nätverk.STA_IF)wlan.active(True)wlan.connect(ssid, lösenord)html = """ Raspberry Pi Pico W
När skriptet körs visas mikrokontrollerns IP-adress på kommandoraden efter att anslutningen har upprättats. Vi väljer dessa och kopierar dem till urklipp. Denna IP-adress infogas i webbläsaren (t.ex. Microsoft Edge) och bekräftas med Enter.
Styrning av lysdioder via hemsidan
I nästa steg vill vi nu styra några lysdioder som vi har kopplat till Pico.
Som nämnts ovan använder jag den officiella Raspberry Foundation-handledningen som grund för detta inlägg. Jag skulle dock vilja avvika lite och ta en annan väg.
I den nämnda posten tänds eller släcks lysdioden när en adress tas fram. Jag skulle vilja lägga till en knapp för varje lysdiod och aktivera den via Ajax-förfrågan.
För att ställa in kretsen ska jag ge dig pinouten för Raspberry Pi Pico här.
(Video) Pi Pico W with the Arduino IDE | Using WiFi
konstruktion av kretsen
Jag har redan visat dig hur du styr en lysdiod på Raspberry Pi Pico med MicroPython i artikelnRaspberry PI Pico #2 – Styr lysdiodervisad.
I mitt fall kopplade jag fyra lysdioder och detta gav mig följande krets:
anslutningsplan
komponent
Raspberry Pi Pico W
LED – grön
GPIO 14
LED – ruttna
GPIO 15
LED - blå
GPIO 13
LED - gul
GPIO 12
GND
GND, stift 38
Källkod - styr lysdioder via hemsidan
Här är källkoden hur du kan styra lysdioderna med knappar (ON/OFF).
Raspberry Pi Pico W - styr lysdioder via en webbplatsLadda ner
Upprätta anslutningen till Wi-Fi-nätverket
Först upprättar vi nätverksanslutningen och matar ut IP-adressen på kommandoraden.
import nätverk import socketfrom tid import sleepssid = '******'lösenord = '******'wlan = nätverk.WLAN(nätverk.STA_IF)wlan.active(True)wlan.connect(ssid, lösenord) max_wait = 10print('Väntar på anslutning')medan max_wait > 10: if wlan.status() < 0 eller wlan.status() >= 3: break max_wait -= 1 sleep(1)status = Noneif wlan.status() ! = 3: raise RuntimeError('Det gick inte att upprätta anslutning!')else: status = wlan.ifconfig() print('Anslutning till', ssid,'etablerades framgångsrikt!', sep=' ') print('IP-adress: ' + status[0])ipAddress = status[0]addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]s = socket.socket()s.bind(addr)s.listen ( 1)
Levererar hemsidan med knapparna
Webbsidan som levereras innehåller en knapp märkt "toogle" för varje lysdiod.
Genom att klicka på den här knappen aktiveras/avaktiveras denna lysdiod. Förfrågan skickas som en Ajax-förfrågan, vilket har fördelen att vi inte behöver ladda om sidan.
Raspberry Pi Pico W
kontrollerade lysdioder
(Video) What is VGA and How to Use it With a Raspberry Pi Pico
import nätverk import socketfrom time import sleepssid = '******'lösenord = '********'webbplats = """ Raspberry Pi Pico W
kontrollerade lysdioder
"Reagera" på en knapptryckning
Om vi trycker på en knapp kommer adressen http:///led/ fram. Vi kan fråga detta i koden och om "hitta"-funktionen i förfrågningsobjektet returnerar resultatet 6 har denna sida anropats.
Om adressen http:///led/yellow anropades är värdet i fältet "req_state_led_yellow" sant.
Nu måste vi kontrollera om den senaste statusen för lysdioden också är sann (dvs lysdioden är aktiverad). Därefter sätts motsvarande fält till False och lysdioden avaktiveras.
req_state_led_gelb = request.find('/led/gelb') == 6 if req_state_led_gelb och state_led_gelb: state_led_gelb = Falskt led_gelb.value(0) elif not req_state_led_gelb och state_led_gelb: state_led_gelb =._value state led_gelb =._value state led_gelb(_value state led_gelb) _led_gelb : state_led_gelb = True led_gelb.value(1)
Så att vi behöver kunna aktivera/avaktivera en lysdiod
importera nätverk import socket från tid import sömn från maskin import Pinled_gelb = Pin(12, Pin.OUT)led_blau = Pin(13, Pin.OUT)led_gruen = Pin(14, Pin.OUT)led_rot = Pin(15, Pin.OUT)state_led_gelb = Falsestate_led_blau = Falsestate_led_gruen = Falsestate_led_rot = False......medan det är sant: prova: cl, addr = s.accept() print('Verbindung vom Client ', addr, "angenommen!") request = cl.recv(1024) request = str(request) req_state_led_gelb = request.find('/led/gelb') == 6 req_state_led_blau = request.find('/led/blau') == 6 req_state_led_gruen = request.find('/led/gruen' ) == 6 req_state_led_rot = request.find('/led/rot') == 6 if req_state_led_gelb och state_led_gelb: state_led_gelb = False led_gelb.value(0) elif not req_state_led_gelb och state_led_gelb: True_led_gelb: True_led_gelb. req_state_led_gelb och inte state_led_gelb: state_led_gelb = Sant led_gelb.value(1) if req_state_led_blau och state_led_blau: state_led_blau = Falskt led_blau.value(0) elif not req_state_led_blau och state_led_blau. _state_led_blau och inte state_led_blau: state_led_blau = Sant led_blau.value(1) if req_state_led_rot och state_led_rot: state_led_rot = Falskt led_rot.value(0) elif not req_state_led_rot och state_led_rot: state_led_rot = Sant led_rot.value(1) elif req_state_led_rot: True_state_led_rot: True_state_led_rot: 1) if req_state_led_gruen och state_led_gruen: state_led_gruen = Falskt led_gruen.value(0) elif not req_state_led_gruen och state_led_gruen: state_led_gruen = Sant led_gruen.value(1) elif req_state_led_led_gruen_gruen_state_led_gruen. ) html = webbplats cl .send('HTTP/1.0 200 OK\r\nInnehållstyp: text/html\r\n\r\n') cl.send(html) cl.close() förutom OSError som e: cl.close() print('anslutning stängd')
Det färdiga programmet
Här är det färdiga programmet:
importera nätverk import socket från tid import sömn från maskin import Pinled_gelb = Pin(12, Pin.OUT)led_blau = Pin(13, Pin.OUT)led_gruen = Pin(14, Pin.OUT)led_rot = Pin(15, Pin.OUT)state_led_gelb = Falsestate_led_blau = Falsestate_led_gruen = Falsestate_led_rot = Falsessid = '********'lösenord = '*****'webbplats = """ Raspberry Pi Pico W title>
kontrollerade lysdioder
LED - GELB
LED - BLÅ
LED - ROT
LED - GRUEN html>"""wlan = nätverk.WLAN(nätverk.STA_IF)wlan.active(True)wlan.connect(ssid, lösenord) max_wait = 10print('Warte auf Verbindung')while max_wait > 10: if wlan.status() < 0 eller wlan.status() >= 3: break max_wait -= 1 sleep(1)status = Ingen om wlan.status() != 3: raise RuntimeError('Aufbau der Verbindung fehlgeschlagen!')else: status = wlan. ifconfig() print('Verbindung zu', ssid,'erfolgreich aufgebaut!', sep=' ') print('IP-adress: ' + status[0])ipAddress = status[0]addr = socket.getaddrinfo(' 0.0.0.0', 80)[0][-1]s = socket.socket()s.bind(addr)s.listen(1)while True: try: cl, addr = s.accept() print(' Verbindung vom Client ', addr, "angenommen!") request = cl.recv(1024) request = str(request) req_state_led_gelb = request.find('/led/gelb') == 6 req_state_led_blau = request.find('/ led/blau') == 6 req_state_led_gruen = request.find('/led/gruen') == 6 req_state_led_rot = request.find('/led/rot') == 6 if req_state_led_gelb och state_led_gelb: state_led_gelb = Falsk led_gelb. värde(0) elif not req_state_led_gelb och state_led_gelb: state_led_gelb = True led_gelb.value(1) elif req_state_led_gelb och inte state_led_gelb: state_led_gelb = True led_gelb.value(1) if req_state_led_value(1) om req_state_led_value. 0) elif icke req_state_led_blau och state_led_blau: state_led_blau = True led_blau.value(1) elif req_state_led_blau och inte state_led_blau: state_led_blau = True led_blau.value(1) if req_state_led_rot och state_led_rot_value False_led_rot_valu led_rot och state_led_rot: state_led_rot = True led_rot.value(1) elif req_state_led_rot och inte state_led_rot: state_led_rot = True led_rot.value(1) if req_state_led_gruen och state_led_gruen: state_led_gruen = Falskt led_gruen.value(0) elif not req_state_gruen_gruen_gruen = True_state_gruen. värde(1 ) elif req_state_led_gruen och inte state_led_gruen: state_led_gruen = True led_gruen.value(1) html = webbplats cl.send('HTTP/1.0 200 OK\r\nInnehållstyp: text/html\r\n\r\n') cl .send(html) cl.close() förutom OSError som e: cl.close() print('anslutning stängd')
(Video) How to Make a Binary Clock Using a Raspberry Pi Pico W
GurgleApps Raspberry Pi Pico Web Server Gives You Control From Any Device. The GurgleApps team is back with another cool Raspberry Pi Pico W project: a Pico W-based web server. But this project does more than serve web pages — it can also run your Python code on the Pico W via a web interface.
Unlike the Raspberry Pi microcomputers, the Raspberry Pi Pico will only take three languages by default: C or C++ and MicroPython. This means that if you have learned Python, you will be able to transition into writing MicroPython, since the syntax is the same.
To further test that we can successfully program the Raspberry Pi Pico, we shall write the “Hello World” equivalent for hardware projects, flashing an LED. This quick test ensures that our hardware is working, and it will introduce the MicroPython language and syntax in the simplest form.
There are lots of things we can use a Raspberry Pi for. We can build home automation servers, remote-controlled robots, network-attached storage (NAS) devices, mini web servers, media centers, music boxes, retro gaming consoles, Raspberry cluster servers, VPN servers, and much more.
No - the Raspberry Pi Pico doesn't run a full desktop operating system like the Raspberry Pi 4, it runs code directly without a desktop interface (similar to how an Arduino board works).
If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply. Safe operating voltages are between 1.8V and 5.5V.
Today we're introducing a simple solution to install everything you need to develop for Raspberry Pi Pico, and for other RP2040-based boards, using C or C++ on Windows.
The Raspberry Pi lifespan is said to be around 7-10 years. The usual reason for major damage is due to a user's lack of care with the device. Users don't protect the device from power breakdowns and SD card failures, or it is kept in a rough environment.
Connect the USB cable to your PC, plugging the micro-USB into the Pi's USB, (not the PWR_IN). If the Zero is alive, your Windows PC will go ding for the presence of new hardware & you should see "BCM2708 Boot" in Device Manager. Or on linux, run sudo lsusb or run dmesg and look for a ID 0a5c:2763 Broadcom Corp message.
The Raspberry Pi Pico requires a power supply capable of delivering a minimum of 1.8 volts and a maximum of 5.5V. A battery pack with a USB to micro-USB cable can also power a Raspberry Pi Pico. This battery pack provides up to 2.1A of current at 5V.
However, if you are intending to develop for Pico on a Raspberry Pi, then you can set up the C/C++ toolchain quickly by running our setup script from the command line. You should make sure the OS on your Raspberry Pi is up to date before running the setup script.
You can develop Python scripts that will be directly executed on a Raspberry Pi Pico board or an ESP32. To do this, we install MicroPython on the board and then use software (Thonny IDE, for example) to write the Python script and send it to the board.
In terms of hardware capabilities, the Raspberry Pi Pico clearly has an edge over the standard Arduino Nano, with a faster processor, more flash memory, more GPIO pins, and extensive control over PWM signals.
Chromium is the default browser on Raspberry Pi OS, optimized for a Pi's smaller memory. It's an open-source, reduced version of Chrome that maintains support for most of Google's services.
Connect the Raspberry Pi to a power source, and via an Ethernet cable, to the router. To connect to your Raspberry Pi, you need to know its IP address, Open a browser on a machine that's on the same local network, and navigate to your router's admin page. You can usually do this by typing 192.168.
"For IT professionals, you can do a lot of coding and development with the Raspberry Pi, making it a great tool for when you want to make something and don't know where to start.
The best general-purpose Raspberry Pi for the money is the Raspberry Pi 4 B (2GB). It is powerful enough for almost any project you throw at it and even for some light web surfing. However, if you can spare an extra $20, you can't go wrong by getting the 4GB unit.
A Raspberry Pi Minecraft server is a cost-effective way to have your very own private server with your friends or just for stuffing around on. I have had mine running for quite some time now and haven't come across too many problems. It is very important to know that this server will not be able to hold many people.
Even though the Raspberry Pi Pico is a very powerful board, its main disadvantage over its competitors like ESP8266 or ESP32 is the lack of wireless connectivity.
The Pi Pico datasheet recommends a maximum power draw on the 3V3 pin (pin 36) of 300mA. However, the RT6154B datasheet indicates that up to 3A can be drawn when Vin > 3.6V, which is the case when powering the Pico from the USB connector with a 5V/3A power supply.
This DC motor driver has been designed specifically for the Raspberry Pi Pico and can PWM control up to 4 DC motors at a constant current of 1.2A (3.2A peak).
A Raspberry Pi can enable a drone to have significant computing power on board, allowing drones access to vastly complicated yet exciting technologies such as AI. This extra capability can allow you to interface with the drone using Python while the UAV is flying.
Processing Power. The ESP32 has a slightly more powerful processor, with a clock speed of up to 240 MHz, compared to the Raspberry Pi Pico's maximum clock speed of 133 MHz. The ESP32 has a faster instruction rate than the RP2040 chip in the Pico.
The shortage in stock is due to supply chain issues which affected any components which used semiconductors. The Raspberry Pi range was not alone in this: graphics cards, along with other PC components, also saw stock shortages and high demand.
Unfortunately, practically everything out there has a write-heavy component with the exception of simple scheduled scripts, so you'd expect to replace the SD card on your Raspberry Pi, on average, every 12 months. This, however, does not mean that your Raspberry Pis are doomed.
A reported issue with Raspberry Pi can be overheating, with a resulting loss of performance, when the board is exposed to high temperatures. All electrical devices are qualified to a specific operating temperature range at which the device will work effectively.
Your first instinct is probably to pull the power cord, but this is highly not recommended. There are many reasons why pulling the power cord while your operating system is still running is not a good idea. Firstly, by pulling the power cord out early, you heighten the risk of your SD card becoming corrupt.
While active cooling isn't always necessary, it's a good safety measure to help ensure that your Pi continues to work properly. If you overclock your Pi without a fan, the Pi could get too hot, and you might notice that performance suffers. For this reason, we recommend using a fan if you plan to overclock.
A Raspberry Pi Pico has GPIO pins, much like a Raspberry Pi computer, which means it can be used to control and receive input from a variety of electronic devices.
No - the Raspberry Pi Pico doesn't run a full desktop operating system like the Raspberry Pi 4, it runs code directly without a desktop interface (similar to how an Arduino board works).
Introduction: My name is The Hon. Margery Christiansen, I am a bright, adorable, precious, inexpensive, gorgeous, comfortable, happy person who loves writing and wants to share my knowledge and understanding with you.
We notice you're using an ad blocker
Without advertising income, we can't keep making this site awesome for you.