circuitpython | Python implementation
kandi X-RAY | circuitpython Summary
kandi X-RAY | circuitpython Summary
CircuitPython - a Python implementation for teaching coding with microcontrollers
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of circuitpython
circuitpython Key Features
circuitpython Examples and Code Snippets
Community Discussions
Trending Discussions on circuitpython
QUESTION
I am using Circuitpython for my microcontroller. I am posting datas from microcontroller to api. If there is no internet connection, I am saving datas to text file then sending datas when internet connected.
I am writing whatever my microcontroller do. text file like this:
...ANSWER
Answered 2022-Mar-21 at 13:19if you control the way .txt
file is created, I would change the formatting of it to JSON. With JSON you can easily load your .txt
file into a list of dict, and then you can use standard list/dict voodoo to easily do what you want, without any custom data processsing.
QUESTION
I have a Raspberry Pi Pico running CircuitPython. Is it possible for the python code on this board to detect if a modifier key is pressed on the host computer's keyboard when the board is connected to the host over USB?
My knowledge of USB protocols is limited but it feels like the Pico would need to be listening to data explicitly sent over USB. I don't think that key presses would be sent that way.
I'd be happy to be proven wrong.
...ANSWER
Answered 2022-Mar-01 at 14:53I don't think you can do this without installing something on the host computer side to detect when the Pico was connected, check what keys were pressed and communicate with the Pico accordingly.
If the host computer is Windows then a quick search finds this which uses Windows Management Instrumentation to run Python code when a USB device changes.
Alternatively, you could attach a hardware button to the Pico and check that button when the Pico detects that it has been connected to a USB host - you appear to have already figured this out.
QUESTION
I have looked but cannot find these referenced currently - I have also asked on the cytron.io web site.
I eventually found these (as well as the github reply) in the Datasheet at https://docs.google.com/document/d/1DJASwxgbattM37V4AIlJVR4pxukq0up25LppA8-z_AY/edit
USB VID & PID (CircuitPython & Arduino Core)
...ANSWER
Answered 2021-Dec-14 at 17:46So I wrote a little Python (PySerial) script and printed out the VID and PID, which are:
VID = 0x2E8A # 11914 decimal PID = 0x1000 # 4096 decimal
I'm hoping these are fixed values...
QUESTION
I'm working with circuitpython, and need access to the micropython uctypes module. I've downloaded the micropython files from github, but can't seem to find the module. Can anyone help?
...ANSWER
Answered 2021-Nov-23 at 08:14See this CircuitPython issue: this is a known thing, and it looks like none of the ports actually have the uctypes module enabled: for that, the MICROPY_PY_UCTYPES
preprocessor definition must be non-zero when building and this is normally set in the port's mpconfigport.h but that is not the case here.
So either you'll have to build yourself (see e.g. https://learn.adafruit.com/building-circuitpython/) and either add said definition into mpconfigport.h or pass it on the commandline, or find an alternative solution (same link mentions the struct
module could be used instead, which it might indeed depending on the exact usecase).
QUESTION
I'd like to control a servo by a given angle.
I am using a RaspberryPi 4 Model B which is running Raspian. The servos are connected to a Adafruit PCA9685 16-Channel Servo Driver. The servo driver is connected to the RaspberryPi via i2c.
Python version 3.7.
I used the following tutorial: https://learn.adafruit.com/16-channel-pwm-servo-driver/python-circuitpython
I am able to properly control a LED (just like in the above tutorial) with the setup.
The LED is connected to the servo driver on channel 8, whereas the servo is connected at channel 2.
So here's my code (controlling the LED also included):
...ANSWER
Answered 2021-Oct-25 at 17:00I solved the problem myself. Here's what I did:
I was confused by the difference between circuitpython and regular python. As far as I understand this, circuitpython is a whole programming language with its environment. If that is even possible to install on the RaspberryPi, I am not sure. I checked on circuitpython's official website and it does not seem to be supported, check the download's page. In case you have circuitpython installed, you can refer to this Github page: https://github.com/adafruit/Adafruit_CircuitPython_PCA9685
Anyway, what I am looking for is Adafruit's library for "regular" python. This can be pulled from here: https://github.com/adafruit/Adafruit_Python_PCA9685 Check out the readme.md for setup instructions. With this, it worked for me. Controlling servos is now fairly easy.
QUESTION
I am working with CircuitPython Libraries on MicroPython using the Raspberry Pi Pico. I am using Wiznett 5500 (ethernet module) and Esp01 (wifi module). When I tried jsonplaceholder's api, Wiznett can get request in 4,5 seconds and ESP01 can get request in 1.6 second. When I tried my real api Wiznett 5500 can get request in 1 minute and Esp01 can get in 1.6 second. My api is really fast like microsecond, I don't understand why is wiznett getting data in 1 minute.
...ANSWER
Answered 2021-Oct-21 at 11:29You need to get more data not only {"exampleexa":888.8}. Add like 3 more lines.
QUESTION
I'm writing Python code on one of the new TI-84 Python edition calculators. These use a version of CircuitPython with limited support for some quite basic features.
This includes missing dictionary methods such as items()
and values()
.
My original version of Dijkstra's Algorithm is below, followed by a nearly complete version in TI-Python. I'm having trouble converting the final two items()
instances with working alternatives.
ANSWER
Answered 2021-Sep-21 at 13:44Whilst .items()
is very useful, it is equivalent to iterating the keys and then looking up the value.
QUESTION
I'm trying to install the library above on a Raspberry Pi 4 running Raspbian Buster / RetroPi .
Setup collects packages, and then fails on setup.py
stating:
ANSWER
Answered 2021-Apr-26 at 16:14SuperStormer suggested sudo apt install python3-dev
- which worked!
I have no idea why this works, as This post suggests that it's usage is for Python extensions, not regular libraries.
It apparently contains the Python C headers, so maybe the library needed those for some reason.
QUESTION
I am trying to measure the LED lighting flickering rate through an Adafruit sensor: TCS34725 on Raspberry Pi4. I am either reading the internally calculated lux value or raw data(RGB).
According to the TCS34725 library documentation, the minimum sampling rate for the sensor is 2.4ms (~400Hz). The sensor itself has a clock frequency of 400kHz. Python TCS34725 library
However, when I run a test script, the time cycles for each sampling are at ~0.0155769 seconds (~60 Hz), for both raw values or calculated lux value.
...ANSWER
Answered 2021-Apr-15 at 09:06If you peek into the library's code at what happens when you access .lux
,
you'll find that all of this code gets executed.
It involves (at least)
- one I2C write+read for
ATIME
- one I2C write+read for
.gain
- four I2C write+reads for the raw color
- all that calculation
If you need to squeeze out more performance, I would recommend accessing those manually, then doing the computations later "offline" once you've captured your data.
QUESTION
I am trying to interface a micropython board with python on my computer using serial read and write, however I can't find a way to read usb serial data in micropython that is non-blocking.
Basicly I want to call the input function without requiring an input to move on. (something like https://github.com/adafruit/circuitpython/pull/1186 but for usb)
I have tried using tasko, uselect (it failed to import the library and I can't find a download), and await functions. I'm not sure it there is a way to do this, but any help would be appreciated.
...ANSWER
Answered 2021-Jan-15 at 12:45For CircuitPython there's supervisor.runtime.serial_bytes_available which may provide the building block for what you want to do.
This is discussed on Adafruit Forums: Receive commands from the computer via USB.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install circuitpython
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page