djacobow / pipowermeter Goto Github PK
View Code? Open in Web Editor NEWsensor / server code for electric power meter based on raspberry pi + atm90e26
sensor / server code for electric power meter based on raspberry pi + atm90e26
I am using Rpi 3b+ to communicate with ATM90e26 using SPI mode. However it doesn't seem to be working. This is how im implementing the code.
# to communicate with the ic
# RW is 1 / 0 for read or write operation
# address as the name suggests points to a specific register
# val is the value to be written during write operation
def comm_atm90(self,RW,address,val):
#switch MSB and LSB of value
buf = bytearray(2)
#Set read write flag
address|=RW<<7
self.spi.open(0,0)
self.spi.max_speed_hz = 200000
self.spi.mode = 0b11
self.spi.lsbfirst = False
self.spi.bits_per_word = 8
time.sleep(0.000010)
self.spi.writebytes([address])
''' Must wait 4 us for data to become valid '''
time.sleep(0.000004)
#Read data
#Do for each byte in transfer
if(RW):
buf = self.spi.readbytes(2)
else:
self.spi.writebytes([val]) # write all the bytes
self.spi.close()
return int.from_bytes(buf,'big')
i am using spidev
module as
import spidev
spi = spidev.SpiDev()
# lets say after the init functions i call the checksum 1 register
print(hex(self.comm_atm90(True,CSOne,0x0000)))
The output i get is0x0
everytime. A similar implementation using ESP32
on micropython works just fine!!! Is there something wrong that i might be doing.
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.