pibeacon: 20 - NEO pixel thermometer

Posted on
Mon Oct 07, 2019 5:17 pm
kw123 offline
User avatar
Posts: 6583
Joined: May 12, 2013
Location: Dallas, TX

pibeacon: 20 - NEO pixel thermometer

1. create an output device neopixel with n LEDs (here 150)
Screen Shot 2019-10-07 at 18.45.54.png
Screen Shot 2019-10-07 at 18.45.54.png (73.4 KiB) Viewed 103 times


2. create an action that is triggered when temperature changes:
Code: Select all
##=======use this as a python script in an action group action :=====
import json

il = float(indigo.devices[393522233].states["illuminance"])
lightFactor = max( min(il/ 100., 1), 2./255. )

tO = (float(indigo.devices[1336842918].states["Temperature"]))

tRange = [-20,50] # -20C .. +50C

#  tscale is 0..140
termLen = 140

tOScale  = int( termLen*(tO -tRange[0])  /float(tRange[1]  -tRange[0])  )

# the elements in thermometer are:[ [col=0, led1, R G,B],  [col=0, led2, R,G,B],  [col=0, led3, R,G,B]...]
thermometer = []
for ii in range(termLen+3):# 142 pixels,  tscale is 0..140
   thermometer.append([0,ii+1,0,0,0])
   if tOScale > ii:
      thermometer[ii][2] = int(2)
   if tOScale == ii:
      thermometer[ii][2] = int(255* lightFactor)
   if ii%10 == 0:
      thermometer[ii][2] = 0
      thermometer[ii][3] = 0
      thermometer[ii][4] = 2
   if ii%20 == 0:
      thermometer[ii][0] = 0
      thermometer[ii][3] = 5
      thermometer[ii][4] = 5

plug = indigo.server.getPlugin("com.karlwachs.piBeacon")
plug.executeAction("Neopixel" , props ={
     "outputDev":"246403135"
    ,"device":"OUTPUT-neopixel"
    ,"restoreAfterBoot":"false"
    ,"intensity":100
    ,"repeat":1
    ,"resetInitial":"[0, 0, 0]"
    ,"command":json.dumps([     { "type": "points"
   , "position": thermometer
    }])
    })

3. connect the neopixel strip through a level shifter to pin# 18=digital PWN out, +5V GND -- and on the neopixel side GND,+5V, Di
The neo pixel strip is mounted on a plane long piece of wood
Screen Shot 2019-10-07 at 18.15.53.png
Screen Shot 2019-10-07 at 18.15.53.png (152.79 KiB) Viewed 115 times


Karl

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests