uLibrary

A collection of useful programs

I2C

iic_u.py  20 Jan 2018 This is written on the ESP8266 running micropython

Universal access to i2c functions via one function, this makes it easier to port i2c devices access platforms as all i2c goes through this function it is just a question of re-writing this function for another platform.

i2c = IIC(sclpin=5,sdapin=4,timeout=1000 )
i2c.i2c(<adr>,[byets to send],bytes to return,<option see text>)

Example

i2c.i2c(62,[1,2,3],2) # writes 1,2,3 to device at address 62 and the device returns 2 bytes

General call: Some device will respond to a general call. When a general call is issued (normally address 0) all devices will respond. The general call address follows the return bytes, for example if all of the device on the bus responded to a general call reset the command would be.

u2c.i2c(62,[0x10],0,0)

The 62 is not important in this case but can be used if the general call to the device expects to receive data from the device.

Network

net.py 20 Jan 2018 for ESP8266 running micropython

This will automatically set the network ssid and password AND the IP address if required from a text file called mynet.txt.

{'ssid':'myssid',
'pass':'mypass',
'ip':'192.168.11.81'}

This is the mynet.txt. Set ip:'' to get an ip address from the router.