Skip to content

Script - Separating bytes from ir4 during i2c reads #20181

Answered by letshin
letshin asked this question in Q&A
Discussion options

You must be logged in to vote

Sorted it for both sensors (without slowing down i2c speed, keeping stock values whatever they are) as :

>D
found=0
status=0
val0=0
val1=0
topic="test"
hum=0
temp=0

>B
; check device
found=ia(0x1a)

>S
;update TVOC every 3s
if upsecs%3==0 {
 val1=ir4(0x00)
 status=val1>>24
}
if found>0 {
 if val1>(status<<24) {
  val0=val1-(status<<24)
  ;print %val0%
 }
}

>T
temp=SHT4X#Temperature
hum=SHT4X#Humidity
=>Publish tele/%topic%/SENSOR {"Sensor":{"TVOC":%val0%,"Temperature":%temp%,"Humidity":%hum%}}

Replies: 1 comment 13 replies

Comment options

You must be logged in to vote
13 replies
@sfromis
Comment options

@letshin
Comment options

@sfromis
Comment options

@letshin
Comment options

Answer selected by letshin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants