shaoziyang / microbit-lib Goto Github PK
View Code? Open in Web Editor NEWall kinds of microbit python drives, libs, examples, etc.
License: MIT License
all kinds of microbit python drives, libs, examples, etc.
License: MIT License
When I copy your text.py on the Mu, it shows invalid syntax for the "1.puts(XXX)". How to correct it....
Hi,
Thanks for your work. I really appreciate your librarys for microbit and Python
I've got an error with BMP280 sensor and microbit:
File "bmp280.py", line 51, in _g2r
OSError: I2C write error -1010
Could you help me to solve it?
G.B
Hello,
I'm looking for a python library for the ds18b20 temperature sensor that would work with a micro:bit V2.
Do you know if it exists?
Thank you in advance for your help.
G.B.
The ESP32 has its own RTC but it is not backed-up with a battery, so it constantly looses track of the date/time making it pretty useless. My solution was to use a DS1302 module with a CR2032 3V lithium battery. Unfortunately there are some differences between MicroPython for Microbit and MicroPython for ESP32 when it comes down to doing digital reads and writes, etc. And these differences are stumping me (i.e. I have not figured out how to fix). For instance, instead of: "self.clk.write_digital(1)" and "self.clk.write_digital(0)" to toggle the CLK line, the ESP32 seems to want "self.clk.onl()" and "self.clk.offl()". These changes are pretty straight forward, but it get complicated when you have to do this: "self.dio.write_digital((dat >> i) & 1)" within a "for" loop to convert a byte value into a serial bit stream. If you have some time, I'd appreciate your help. You can contact me at [email protected] to discuss in more detail. To me, ESP32 looks like the successor product to recommend to students that find the Microbit too resource limited. Unfortunately, it seems there are not as many device drivers as Microbit, so I have to try to port them on my own and I'm not really a software engineer. Thank you for all your work in supporting MicroPython device drivers for Microbit.
Last year I had no problem making an I2C_1602_LCD display work with your MicroPython driver. But when I tried it again just yesterday, I found that the software no longer worked. I kept getting an error message like "Line 25 OSError I2C write error -1010". Looking at your code, I decided it must be the wrong I2C address, so I found a couple of I2C_1602_LCD displays with known IC2 Addresses (0x27 and 0x3f) which I then tried to make work with the software changing the line which read "LCD_I2C_ADDR=63" to the appropriate decimal value (63 for 0x3F boards and 39 for 0x27 boards) and still could not make the software work. Anyways, I started over from scratch, with all new hardware, and still no luck. Then I remembered I had another Micro:bit breakout board (a Chinese made ElecFreaks Micro:bit Breakout board called "OCTOPUS Bit v 1.6". When I replaced the SparkFun Micro:bit breakout board with the ElecFreaks board, your MicroPython I2C_1602_LCD driver magically worked. So, I guess last year I was using the ElecFreaks Micro:bit breakout board.
So, then I wondered what the difference might be. After a bit more research on the Internet, I came across an article that says a pull-up resistor of from 5K ohms to 20K ohms is sometimes needed, especially when multiple I2C devices are attached to the same bus. So, I tried two 12K ohm pull-up resistors on the SDA and SCL pins of the SparkFun Micro:bit breakout board, and found it would now work with your I2C_1602_LCD driver. I first tried pulling it up to +3V and later tried pulling the 2 pins up to +5V. In both cases, that was enough pull-up to make the 1602_LCD work.
So, if you have other folks having problems running your MicroPython I2C_1602_LCD drivers on their
Micro-bit board, advise them to try a pull-up resistor between SDA and +5V and SCL and +5V. Anything in the range of 5K ohm and 20K ohm should work.
`'''
DS1302 Demo #2 (v3)
Author: R_Moore
Date: 9/2/2018
Uses ShaoZiYang's DS1302 Driver from this URL:
https://github.com/shaoziyang/microbit-lib/tree/master/misc/DS1302
http://www.micropython.org.cn
Improved demo/test program to be more Micro:bit user friendly...
'''
from microbit import *
import time
import DS1302
'''
'''
def xlateDayCode(day):
if day == 0:
return 'Sunday'
elif day == 1:
return 'Monday'
elif day == 2:
return 'Tuesday'
elif day == 3:
return 'Wednesday'
elif day == 4:
return 'Thursday'
elif day == 5:
return 'Friday'
elif day == 6:
return 'Saturday'
else:
return 'Error'
'''
'''
ds = DS1302.DS1302(clk=pin13, dio=pin14, cs=pin15)
'''
'''
while True:
'''
# Display day of week...
'''
display.scroll('Today is ' + xlateDayCode(ds.Weekday()) + ', ')
'''
# Display current date in 'mm/dd/yyyy' format...
'''
display.scroll(str(ds.Month()) + '/' + str(ds.Day()) + '/' + str(ds.Year()))
time.sleep_ms(1000)
'''
# Display current time in 'hh:mm:ss' format...
'''
display.scroll(str(ds.Hour()) + ':' + str(ds.Minute()) + ':' + str(ds.Second()))
time.sleep_ms(10000) # Wait 10 seconds & repeat...
`
Hi
Just discovered your wonderful SnowFlake extension.
Assuming i understand correctly first i import t a picture into this utility , click the big green play button. Then i copy the list of hex numbers generated into the ITEM string in makecode?
However whatever picture i import & then copy my display bears no resemblance to the original file. However if use the demo.bmp file from your microbit-lib/neopixel/neo_16x16_img/ it works.
What am i doing wrong - my guess is that the original picture needs to be formatted in a specific way?
Any help & example code would be really gratefully received - i want to show how to do this to a friend in USA who runs coding club for children - i am sure they would love to be able to create & display their own pictures
'''
DS1302 Demo #2 (v3)
Author: R_Moore
Date: 9/3/2018
Uses ShaoZiYang's DS1302 Driver from this URL:
https://github.com/shaoziyang/microbit-lib/tree/master/misc/DS1302
http://www.micropython.org.cn
Improved demo/test program to be more Micro:bit user friendly...
'''
from microbit import *
import time
import DS1302
# The following function translates the 'day of week' code
# (an integer value btw 0 & 6, inclusive) into the
# equivalent English name for the day.
def xlateDayCode(day):
if day == 0:
return 'Sunday'
elif day == 1:
return 'Monday'
elif day == 2:
return 'Tuesday'
elif day == 3:
return 'Wednesday'
elif day == 4:
return 'Thursday'
elif day == 5:
return 'Friday'
elif day == 6:
return 'Saturday'
else:
return 'Error'
# Create an instance of a DS1302 class and call it 'ds'.
ds = DS1302.DS1302(clk=pin13, dio=pin14, cs=pin15)
# Use next line of code just one time to set the date/time of RTC module (un-comment it to use)
# ds.DateTime([2018, 3, 9, 4, 23, 0, 1]) # March 3, 2018 at 11:00:01 pm.
while True:
# Display day of week...
display.scroll('Today is ' + xlateDayCode(ds.Weekday()) + ', ')
# Display current date in 'mm/dd/yyyy' format...
display.scroll(str(ds.Month()) + '/' + str(ds.Day()) + '/' + str(ds.Year()))
time.sleep_ms(1000)
# Display current time in 'hh:mm:ss' format...
display.scroll(str(ds.Hour()) + ':' + str(ds.Minute()) + ':' + str(ds.Second()))
time.sleep_ms(10000) # Wait 10 seconds & repeat...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.