Git Product home page Git Product logo

microbit-lib's People

Contributors

ivandavidov avatar shaoziyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

microbit-lib's Issues

Max recursion reached

When I call the getAltitude function I get a runtime error for maximum recursion.

Any help greatly appreciated
capture

Microbit with BM280

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

Help for ds18b20 temperature sensor

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.

Need a MicroPython/ESP32 version of this DS1302 driver.

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.

Need for pullup resistors on SDA and SCL pins

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.

Better demo program

`'''
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

'''

The following function translates the 'day of week' code

(an integer value between 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)

'''

Setup date/time one time only... then comment out following line.

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...

`

help needed generating image for the SnowFlake Extension

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

New demo -- cleaned up to display properly on Github.com

'''
    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...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.