piBeacon: 5- connect sonsors to the rPi

Posted on
Sun Jan 31, 2016 11:13 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

piBeacon: 5- connect sonsors to the rPi

Supported sensors and output channels:
  • Wire18B20-Temp DS18b20
  • Temp+Hum-DHT22 Temperature & Humidity. ** Use V3.3,GND,GPIO1; Most need a 4.7kOhm resistor V3.3-Pin1
  • Temp+Hum-DHT11 Temperature & Humidity. less accurate; ** Use V3.3,GND,GPIO17; Most need a 4.7kOhm resistor V3.3-Pin1
  • Temp-i2cTMP102 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • Temp-i2cMCP9808 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • Temp+Press-i2cT5403 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • Temp+Press-i2cBMPxx ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • Temp-Ambient+Infrared-mlx90614 Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • Temp+Press+Hum-i2cBMExx ** best sensor temp/press/humidity ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • Temp+Hum-i2cSHT21 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • Temp+Hum-i2cAM2320 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • Temp-i2cLM75A-35 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • Lux+RGB-i2cTCS34725 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • IR-Visible-UV -1145 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • visible Light -OPT3001 - not ready
  • Ambient-White-i2cVEML6030 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • RGB-White-i2cVEML6040 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • UV-i2cVEML6070 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • UVA-UVB-i2cVEML6075 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • Lux-i2cTSL2561 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • current and voltage i2c INA 209 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • XYZ-gyroscope l3g4000/l3gd20h ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • 3 degree sensor mag3110 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • 3 degree sensor hmc5883L ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • 9 degree sensor BNO055 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • 9 degree sensor mpu9255 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • 6 degree sensor mpu6050 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • 6 degree sensor lsm303 - not ready
  • Analog-1x16bit-i2cADS1x15 - one channel ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • Analog-4x16bit-i2cADS1x15 - 4 channels ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • Analog-4x8bit-one-channel-i2cPCF8591 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • Analog-4x8bit-i2cPCF8591 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • Analog-8x10bit-spiMCP3008 - 8 channels 10 bit 0-3.3 analog input channels ** use SPI connection
  • Analog-8x10bit-one-channel-spiMCP3008 1 channels 10 bit 0-3.3 analog input channels
  • pulse- sensor ** use any valid GPIO pin can detect > 50Hz frequency, pulse needs to be > 50uSecs , sets count and frequency state in indigo,. A microwave movement sensor (red - +5V, black -GND, green through diode[cathode to sensor, anode to RPI] to any GPIO pin): ~ $11
    Screen Shot 2017-06-02 at 11.50.21.png
    Screen Shot 2017-06-02 at 11.50.21.png (152.3 KiB) Viewed 9047 times
  • TOUCH- 1 touchPad active ** supports 3 different sensors 2 with i2c and one with 2 general GPIO pins. (TTP226-xxx 16 Serial/8direct, TTP 226LSF 16 i2c channels; MPR121 i2c 12 channel)
  • TOUCH- 4 touchPads active ** supports 3 different sensors 2 with i2c and one with 2 general GPIO pins. (TTP226-xxx 16 Serial/8direct, TTP 226LSF 16 i2c channels; MPR121 i2c 12 channel)
  • TOUCH- 12 touchPads active ** supports 3 different sensors 2 with i2c and one with 2 general GPIO pins. (TTP226-xxx 16 Serial/8direct, TTP 226LSF 16 i2c channels; MPR121 i2c 12 channel)
  • TOUCH- 16 touchPads active ** supports 3 different sensors 2 with i2c and one with 2 general GPIO pins. (TTP226-xxx 16 Serial/8direct, TTP 226LSF 16 i2c channels; MPR121 i2c 12 channel) note the jumpers on the TTP226-LSF-i2c 8pads +slider board ( KEYSEL) and the 16 pad TTP (P1-3)
    Screen Shot 2017-06-02 at 11.38.22.png
    Screen Shot 2017-06-02 at 11.38.22.png (171.22 KiB) Viewed 9047 times
  • GPIO-max-1-PINs ** digital GPIO pin input
  • GPIO-max-4-PINs ** digital GPIO pin input
  • GPIO-max-10-PINs ** digital GPIO pin input
  • GPIO-max-26-PINs ** digital GPIO pin input
  • distance-ultrasound ** use 2 general GPIO pins for echo and trigger
  • distance-TOF-vl503l0x ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • distance-TOF+Lux-vcnl4010 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • distance-TOF+Lux-vl6180 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • proximity-apds9960 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • my sensors.py ** program you can define your own sensor or any other function with this on the RPI
  • myprogram.py ** program you can define your own sensor or any other function with this on the RPI, differnet version
  • - out - GPIO-1-ON/off ** use any general GPIO pin to create a digital output device
  • - out - GPIO-1-Dimmer ** use any general GPIO pin to create a digital output device with PWM (pulse width modulation), its a dimmer device in indigo, you can drive LEDs with this
  • - out - GPIO-max-4-PINs ** use up to 4 general GPIO pin to create a digital output device with 4 output channels
  • - out - GPIO-max-10-PINs ** use up to 10 general GPIO pin to create a digital output device with 10 output channels
  • - out - GPIO-max-26-PINs ** use up to 26 general GPIO pin to create a digital output device with 26 output channels
  • - out - FM-radio-setTEA5767 -- a neat little digital FM tuner ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • - out - Analog-1x12bit-i2cMCP4725 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • - out - Analog-1x8bit-i2cPCF8591 ** Use V3.3,GND,SLA(GPIO3),SLC(GPIO3) pins
  • - out - Display avriaous display modules supported, see device defs
  • - out - Neopixel device output for RGB LED chains ** Use V5,GND,GPIO18 pins and a level shifter
  • - out - Neopixel-Dimmer device output for RGB LED chains ** Use V5,GND,GPIO18 pins and a level shifter, it is a indigo dimmer device
  • - out - myoutput.py program on rPi. You can supply your own program to receive text commands from the plugin to do any action on the rPi you like to do.

A good description can be found here :http://www.reuk.co.uk/DS18B20-Temperature-Sensor-with-Raspberry-Pi.htm

This image shows how to connect a simple 1 wire DS18b20 (not the P version!!) to the rPi.:
Screen Shot 2016-01-31 at 11.01.55 AM.png
Screen Shot 2016-01-31 at 11.01.55 AM.png (153.07 KiB) Viewed 10763 times
I use pins pins 1,7,9

The plugin does all the software configuration on the rPi


To create a SENSOR deviceFIRST connect the device to the rPi. Then in Indigo add device: select piBeacon/ sensor model. Then select the rPi the sensor is connected to, select the State column display and save.
After correct setup you should set in 1-2 minutes the sates being populated

Temperature/Pressure can be changed in config menu/configuration (celsius, fahrenheit, kelvin / ...)


Sensor Connection pins:
OneWire D18B20 sensor will be connected:
  • Pin1=3.3V --> VCC,
  • Pin7=GPIO4-->Signal
  • Pin9=Ground--> ground
( make sure one wire protocol is enabled on the RPI in sudo raspi-config / interface ... and in RPI device edit "add new onewire sensors" is enabled)

DHT sensor will be connected:
  • Pin1=3.3V --> VCC,
  • Pin11=GPIO17-->Signal or Pin 7=GPIO4 (selectable in device edit), both together should work, but then no ONEwire device on pin 7
  • Pin9=Ground--> ground

i2c sensors will be connected to pins
  • Pin1=3.3V --> VCC
  • Pin3=GPIO2-->SDA
  • Pin5=GPIO3-->SDC
  • Pin9=Ground--> ground
you need to configure the i2c address of the device: most connect the i2c address pin to either GND or V+. The plugin show all available options in the i2c address config field.
there are 127 possibilities. if you connect 2 they must have a different address. you can see the address of a connected i2c device with:
sudo i2cdetect -y 1
it will show you a matrix of HEX numbers and the one number of the connected device

SPI sensors will be connected to pins
  • Pin1 =3.3V --> VCC
  • Pin19=GPIO10-->MOSI
  • Pin21=GPIO9--> MISO
  • Pin23=GPIO11-> SCKL
  • Pin24=GPIO8 =CE-0 either for channel selector
  • Pin26=GPIO7 =CE-1 or for channel selector
  • Pin25=Ground--> ground
you need to select the SPI address of the device:by using either CE-0 or CE-1 Then in the plugin select the right SPI address accordingly


INPUT GPIO PINS
any PIN that is not used for i2c pins and -- not Onewire or DHT if active - can be used as input pin

OUTPUT GPIO PINS are
(use PIN and ground to drive an external device, max current= 33mA):
any PIN that is not used for i2c pins and -- not Onewire or DHT if active - can be used as output pin

and below the complete pin layout
Karl
Attachments
Screen Shot 2016-03-10 at 5.21.56 PM.png
Screen Shot 2016-03-10 at 5.21.56 PM.png (861.28 KiB) Viewed 10297 times

Posted on
Sat Feb 06, 2016 4:14 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: connect sonsors to the rPi

Connecting sensors continued:

1. connect the hardware:
setup a connector for DHT22(pins 1+,9=GNG,11=GPIO17,input) and D18B20(pins1=+,7=GPIO4,input,9=GND) oneWire and add 1 resistor between +3.3V and input
onewir dht22.png
onewir dht22.png (1.01 MiB) Viewed 10686 times

connect a DHT22 to the rPi
DHT22 to rpi.png
DHT22 to rpi.png (651.56 KiB) Viewed 10686 times

connect a i2c sensor to the rPi
i2c.png
i2c.png (314.29 KiB) Viewed 10686 times


setup a sensor in Indigo:
first select the model and type:
sensor types.png
sensor types.png (107.51 KiB) Viewed 9979 times

second select the rPi the sensor is connected t, the state that should be shown in the State column and any other parameter i.e. i2c address if required
seti2c and config.png
seti2c and config.png (41.33 KiB) Viewed 10546 times

Then you should see something like this in indigo:
Screen Shot 2016-02-12 at 11.46.03 AM.png
Screen Shot 2016-02-12 at 11.46.03 AM.png (15.37 KiB) Viewed 10624 times


For INPUT
same as for regular sensors, you will have states INPUT0..5 that are either 1 or 0 or a count of pulses
to reset the count either use the menu "Reset counter of GPIO pin on rPi.." or use the equivalent action or the following script:
Code: Select all
plug.executeAction("resetGPIOCount" ,
plug. props ={
   "inputDev": "1576434476"
   ,"INPUT_0": True
   ,"INPUT_3": True 
     }
   )




For GPIO OUTPUT:
1.create a piBeacon device and select GPIO OUTPUT
Screen Shot 2016-05-15 at 6.12.49 PM.png
Screen Shot 2016-05-15 at 6.12.49 PM.png (58.06 KiB) Viewed 9979 times

2. select the proper GPIO pin
select GPIO pin.png
select GPIO pin.png (73.16 KiB) Viewed 9979 times

3. to set a pin High/Low/ pulse : Configure the GPIO output function in the Plugin Menu or in an action:
gpio pulses.png
gpio pulses.png (43.54 KiB) Viewed 10546 times

You should then see GPIO # 13 go up for 2 seconds and down for 4 seconds for 555 periods
and the indigo screen should show:
Screen Shot 2016-02-12 at 11.53.55 AM.png
Screen Shot 2016-02-12 at 11.53.55 AM.png (8.56 KiB) Viewed 10624 times


or use the following code in an action:
Code: Select all
## first get plugin
plug = indigo.server.getPlugin("com.karlwachs.piBeacon")
if not plug.isEnabled(): return   #### piBeacon  must be enabled, otherwise nothing here works

## execute actions to set pins to "analogVoltage" (PWM mode)
plug.executeAction("setPins" ,
   props ={
  ,"outputDev": "12345678"  ##indigo device id or name
   ,"GPIOpin" :"5"         ## 
  , "cmd":"pulseDown"      ##  opions:         up   down   pulseUp  pulseDown  continuousUpDown  analogValue disable
   ,"pulseUp":"1.5"        ##  # of secs up     only for: pulseUp    and continuousUpDown
   ,"pulseDown":"2.3"      ##  # of secs down   only for: pulseDown  and continuousUpDown
   ,"nPulses":"1"          ##  # of pulses      only for: continuousUpDown
   ,"analogValue":    "0"  ##  analog out voltage:  0 --3.3
   ,"delayStart":    3         ## delay action by 3 seconds on the rPi ( can be set to any number e.g. 3600 = 1 hour ..
   ,"restoreAfterBoot": "1"  # if you want to have the value set after reboot to 1.5V
     }
    )
## simple on or off:
plug.executeAction("setPins" ,
   props ={
  ,"outputDev": "12345678"  ##indigo device id or name
   ,"GPIOpin" :"5"         ## 
  , "cmd":"up"     # or "down"
   ,"delayStart":    3         ## delay action by 3 seconds on the rPi ( can be set to any number e.g. 3600 = 1 hour ..
   ,"restoreAfterBoot": "1"  # if you want to have the value set after reboot to ON
     }
    )   


For MCP4725 analog Volt OUTPUT:
1.create a piBeacon device and select MCP4725 OUTPUT as type, set the i2C address
2. to set a value :
- Configure the GPIO output function in the Plugin Menu "Set output voltage of DAC to.. "
set analog out value.png
set analog out value.png (27.23 KiB) Viewed 10546 times
or in the equivalent action
- Or use the following code in an action:
Code: Select all
## first get plugin
plug = indigo.server.getPlugin("com.karlwachs.piBeacon")
if not plug.isEnabled(): return   #### piBeacon  must be enabled, otherwise nothing here works

## execute actions to set analogValue for i2cMCP4725 output device
plug.executeAction("setMCP4725" ,
   props ={
    "outputDev": 504661256  ##   or "devicename" in "" of DAC MCP4725
    ,"i2cAddress":  98
    ,"analogValue":    "1.5"  ##  analog out voltage:  0 --3.3
   ,"delayStart":    3
  ,"restoreAfterBoot": "1"  # if you want to have the value set after reboot to 1.5V
      }
   )



playSoundFile
Code: Select all
## first get plugin
plug = indigo.server.getPlugin("com.karlwachs.piBeacon")
if not plug.isEnabled(): return   #### piBeacon  must be enabled, otherwise nothing here works

##
plug.executeAction("playSoundFile" ,
   props ={
    "piServerNumber": 0,## 0-9
    ,"cmd":   " omxplayer"  # or play
    ,"soundFile":    "nameOfSoundfile "  ##  in the soundfile directory. you need to fist push the sound filest to the rPi in the menu
      }
   )




Karl

Posted on
Sat Feb 27, 2016 10:56 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: connect sonsors to the rPi

https://www.dropbox.com/s/6vb01utxmpil3kx/DAC%20-%20nscope.mov?dl=1
movie on setting output voltage through an action / menu on the piBeacon with DAC MCP46725 attached, shown on an attached NScope

https://www.dropbox.com/s/u3haf3qs5c210p4/GPIO%20puls.mov?dl=1
movie on setting GPIO pins (plus up and down) through an action / menu on the piBeacon shown on an attached NScope


as you can see the reactions are almost instantaneous

Karl

Posted on
Mon Feb 29, 2016 8:50 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: connect sonsors to the rPi- measure Ohm

How to connect / measure a resistor value e.g. thermistor, light sensor, pressure, bend, moisture sensor etc:
Screen Shot 2016-02-29 at 8.37.16 PM.png
Screen Shot 2016-02-29 at 8.37.16 PM.png (44.49 KiB) Viewed 10528 times

you use either an ADS15x15 i2c or the MCP3008 spi chip. connect the chip to rPi (either 4 cables for i2c or 5 for spi) then connect a resistor-R2 between V+ and the sensor-R1. That point connects directly to one of the analog in pins. The other end of the sensor-R1 goes to ground. Th value of the "feed" resistor -R2 (the top one) depends on the range of the resistance change of the sensor-R1. For my light sensor that goes between ~400kOhm down to 150Ohm I am using 39kOhm. The proper value should be in the middle not half but if your sensor has a range of e.g. 100, use 10x lower value. so for a range of 1kOhm to 100kOhm use 10kOhm ; for 100Ohm..100kOhm use 3.3kOhm (factor 1000; middle is factor 33: 100Ohm+33=3.3kOhm). That gives you probably the best resolution across the whole spectrum.

Then in the plugin you set the feed voltage to 3300 (mV) and the feed resistor to 39000 (Ohm) in this example. And the unit to " [Ohm]". The format to %5d
then the output would look like:
Screen Shot 2016-02-29 at 8.22.41 PM.png
Screen Shot 2016-02-29 at 8.22.41 PM.png (56.87 KiB) Viewed 10528 times

If you want to get the status in kOhm, use multiplier = 0.001 and unit =" [kOhm]"

Karl

attached the physical setup:
Screen Shot 2016-02-29 at 8.42.50 PM.png
Screen Shot 2016-02-29 at 8.42.50 PM.png (1.24 MiB) Viewed 10528 times

on rPi:
Pin#1 V+ 3.3V
pin# 3 GPIO2/SDA
pin# 5 GPIO3 / SDL
pin# 9 GND
to ADS board
Screen Shot 2016-02-29 at 8.52.42 PM.png
Screen Shot 2016-02-29 at 8.52.42 PM.png (87.94 KiB) Viewed 10526 times

connect address pin to either GND or V+ that sets the i2c address, set the same address in the devices edit in the i2c address field

then connect the feed resistor and the sensor as shown and you should be in business.

Posted on
Wed Mar 02, 2016 8:45 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: connect sonsors to the rPi- flame sensor

Connecting a mini flame sensor 595391 ($5 at amazon)http://www.amazon.com/gp/product/B00AFSEC2Y?psc=1&redirect=true&ref_=oh_aui_detailpage_o04_s00 to the rPi

With this sensor you can detect heat/ flames. It is sensitive in the infrared spectrum

connect:
GND to GND,
VCC to +V3.3
DOUT to any GPIO input pin eg GPIO 20

create indigo device name=fire, type piBeacon, model= INPUT-gpio (select the right rPi)

then the GPIO pin 20 = INPUT_5 will show 0 if no flames, 1 if flames.
the device has a sensitivity potentiometer. you need to tune to off when no flames, just below that threshold. and you have a fire detector
trigger on state INPUT_5 changes to 1 ==> action whatever when you detect fire

Karl
Attachments
412KjgiO3rL.jpg
412KjgiO3rL.jpg (22.72 KiB) Viewed 10478 times

Posted on
Wed Mar 02, 2016 8:53 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: connect sonsors to the rPi-PIR detetcor

Connecting a PIR (pyroelectric motion sensor) detector rHC-SR501 ($6 for 5 at amazon)http://www.amazon.com/gp/product/B00FDPO9B8?psc=1&redirect=true&ref_=oh_aui_detailpage_o04_s01 to the rPi

With this sensor you can detect Movements. It is sensitive in the infrared spectrum

connect:
GND to GND,
VCC to +V5 not 3.3 V. it has a V 5->3.3 regulator on board
OUT to any GPIO input pin eg GPIO 20/16/12/25/24/23
(the point are marked, you can look at the label when you lift the plastic cup

create indigo device name=motion, type piBeacon, model= INPUT-gpio (select the right rPi)

then the GPIO pin 20 = INPUT_5 will show 0 if no movement , 1 if movement.
the device has 2 sensitivity potentiometers, sensitivity and time before next trigger and a jumper to allow multiple triggers. you need to play with the settings.
trigger on state INPUT_5 changes to 1 ==> action whatever when you detect movement

Karl
Attachments
61b57fouHEL._SL1001_.jpg
61b57fouHEL._SL1001_.jpg (68.94 KiB) Viewed 10476 times
71jn7LxapUL._SL1001_.jpg
71jn7LxapUL._SL1001_.jpg (144.51 KiB) Viewed 10476 times

Posted on
Wed Mar 02, 2016 9:11 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: connect sonsors to the rPi- resistance as trig

Connecting a variable resistor (light, moisture, bend, ...) and use as trigger

connect the mid point between resistor and potentiometer to any GPIO-input pin e.g. GPIO-20
(and naturally GND to GND, 3.3V to V3.3 on the rPi NOT 5Volt!!
Screen Shot 2016-03-02 at 8.59.21 PM.png
Screen Shot 2016-03-02 at 8.59.21 PM.png (14.99 KiB) Viewed 10466 times

You need to understand the resistor range and at what value you would like to trigger, e.g. if resistor goes from 1kOhm to 100 kOhm and you like to trigger at 10kOhm you should use a potentiometer of ~10kOhm and then fine tune (that would allow to change the range from 0.3v-3.3V). I believe the 0-1 change is at ~ 2.5 Volts

create indigo device name=Vari, type piBeacon, model= INPUT-gpio (select the right rPi) and set GPIO-20 to mode "open"

then the GPIO pin 20 = INPUT_5 will show 0 if resistance of variable resistor is below threshold, 1 if above.
trigger on state INPUT_5 changes to 1 ==> action ... or the other way around

Karl

Posted on
Sun Mar 06, 2016 7:37 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

piBeacon: connect sonsors to the rPi

with the sharp proximity sensor GP2Y0A21YK $14 you can build a trivial short range proximity sensor to e.g. switch things on/off

connect red cable to +V5 (pin#2)
connect black cable to GND (pin# 6)
connect white cable (signal) to GPIO 23 (pin#16) (INPUT-0)

setup INPUT-GPIO sensor on the plugin: input open GPIO 23
waving your hand ~ 20 CM away from the sensor will trigger 1/0 in the plugin as shown on the attached movie
https://www.dropbox.com/s/fhlmxpeig9x6874/proximity%20sensor.mov?dl=1
(you need to click on the movie to see the 0/1/0/1/0/1 on the top of the screen)


It can get any simpler

Karl

and a pic of the sensor:
Attachments
Screen Shot 2016-03-06 at 7.29.32 PM.png
Screen Shot 2016-03-06 at 7.29.32 PM.png (207.14 KiB) Viewed 10360 times

Posted on
Thu Mar 10, 2016 5:05 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: connect sonsors to the rPi

connecting a Gikfun MQ-7 Carbon Monoxide CO Gas Sensor Module ($7) to the rPi

connect cable VCC (bottom of pic) to +V5 (pin#2)
connect cable GND(top of pic) to GND (pin# 6)
connect cable D-out(second from bottom in pic) to GPIO 23 (pin#16 =INPUT-0 or any other INPUT_x )

then turn the potentiometer until the blue sensor active light turn off: Calibrated.

create device model/type= pibeacon/INPUT gpio and chose the right rPi
You will then see in state INPUT_0 (or which ever input_x you used)
0= no CO
1= CO detected


I did not actually test with any CO source, but blowing at it heavily and close triggered it.

Karl

they offer similar sensors for other gases, but I have not tested them. They seem to work the same way - same form factor, just different gas sensor

amazon link:http://www.amazon.com/gp/product/B00WJL0TKY?psc=1&redirect=true&ref_=oh_aui_detailpage_o08_s00
and a pic of the sensor:
Attachments
Screen Shot 2016-03-10 at 4.59.43 PM.png
Screen Shot 2016-03-10 at 4.59.43 PM.png (286.82 KiB) Viewed 10305 times

Posted on
Fri Jun 17, 2016 4:21 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 5- connect sonsors to the rPi

BYTW: how to read the value of a GPIO pin in a bash shell: open terminal
Code: Select all
ssh pi@x.x.x.x enter password
if you want to read GPIO21 = pin40:
Code: Select all
cd /sys/class/gpio
echo 21 > export
echo in > gpio21/direction
cat gpio21/value
returns the digital value of GPIO21 either 0 or 1,
in the plugin define device,set the GPIO to input pull high
then connect a cable from ground pin 39 --> pin 40 (GPIO21)
type
Code: Select all
cat gpio21/value
==> 0
remove cable
Code: Select all
cat gpio21/value
==> 1

NEVER CONNECT A GPIO TO +5V

karl

Posted on
Sat Jul 09, 2016 7:04 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

piBeacon: 5- connect sonsors to the rPi

connect many OneWire Temp sensors 18B20 to the rPi. The theoretical limit is 2**64, tested with 10.

-You need one resistor 4.7KOhm between pin1 and pin7 and connect to each of the signal wires ;
-connect V+ to pin1(+3.3)
-connect ground to any ground pin eg pin 11

to setup in indigo:
- create a new ONE 18B20 sensor as before.
- connect eg 5 18B20 devices to the rPi and you will get 4 extra indigo devices created. Their name will be the same as device1 + serial number of the 18B20. You will need to figure out which one is which. The serial number of the 18B20 is also a state, see attached screen shot.

To find out which is which hold one sensor into ice water or warm it, then check the change in temperature. -- it can take 2 minutes to change, depending on the sensor refresh setting in the rPi device edit.


Karl

SlaveOf value is indigoDeviceId indigoDeviceName
Attachments
Screen Shot 2016-07-09 at 19.53.40.png
Screen Shot 2016-07-09 at 19.53.40.png (55.7 KiB) Viewed 9629 times

Posted on
Tue Sep 13, 2016 9:26 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 5- connect sonsors to the rPi

Board to connect a MCP 3008 ANALOG to Digital; 8 channel; 10 bit resolution to the RPI:
Screen Shot 2016-09-13 at 22.16.44.png
Screen Shot 2016-09-13 at 22.16.44.png (512.81 KiB) Viewed 9433 times

see also:
https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/mcp3008

Parts:
1. MCP chip ~ $4
2. test board $ 2
3. row of 8 pins
4. six cables with female plug to connect to the api

Karl

Posted on
Sun Sep 18, 2016 5:36 am
srkinard offline
Posts: 320
Joined: Apr 10, 2016
Location: Austin, Texas

Re: piBeacon: connect sonsors to the rPi-PIR detetcor

Since Karl's wicked plugin makes this so easy to do now... :lol:

Here's a link to a nice article on the HC-SR501 Motion Sensor, detailing what each of the adjustments do and some of the caveats of using them.

http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-hc-sr501-motion-sensor-tutorial/

Here's how I set mine up while testing earlier...
Basically using a TRUE or FALSE variable to define an ARMED state for it.
Then set up 2 triggers and one action group.
1st trigger is when the sensor reports a change to ON, then a CONDITION checks to see if it is ARMED. If it is, it proceeds to restart a 150 second countdown timer, then performs whatever device actions. In my test case, it turns on the office lights. I have the Time Delay set about 135 seconds, so there's about a 15 second window where the device starts looking for motion again but the timer has not completed.

If the timer completes before any more motion is detected, the office lights get turned back off. If the sensor detects motion before the timer completes then it calls the original actions...that is why I used RESTART vs START in the action. If the countdown has a few seconds left on it and you call a normal START it will not reset and the 2nd trigger called when the TIMER ENDS will happen within this time. RESTART means back to 2m 30s before the check/end happens.

Works pretty well unless you are really still or out of the sensor's detection area.

Just thought I'd share what insomnia and technology came up with last night...I'm sure I will refine it and if anyone has any ideas I'm always grateful for feedback.

Thanks
Ross

Posted on
Tue Mar 07, 2017 3:40 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

piBeacon: 5- connect sonsors to the rPi

PCF8591 AD/DA 8 bit analog in/ out sensor converter
Screen Shot 2017-03-07 at 15.21.01.png
Screen Shot 2017-03-07 at 15.21.01.png (189.95 KiB) Viewed 9106 times

the setup is simple: connect V+ to +3.3, and gnd to ground and SDA and SLC to the i2c pins on the RPI

Then setup for input a device in indigo, select device type/ model
"INPUT-i2cPCF8591-Analog-4x8bit" or
"INPUT-i2cPCF8591-Analog-4x8bit- one channel"
That will give you either 4 states or one state with the analog input voltage(s). Like with the other ADC sensor models you can also add offset / muliplicator for the status display and use the resistor model for the voltage (e.g. ground -light sensor - 1 kOhm to V+) that will give you a the conversion from voltage to resistance of the light sensor. You can also show the result in log scale and apply some formatting .

Most of the PCF8591 come with
- a light sensor ==> A1 connected to ** (V+- resistor(1KOhm)-- ** lightsensor - ground) ( R5 on the board)
- a thermistor ==> A2 connected to ** (V+- resistor(1KOhm)--**thermistor - ground) (R6 on the board)
- a potentiometer ==> A0.. you can set an analog voltage 0-3.3V.. e.g. for testing (the EDI thing on the board)
Screen Shot 2017-03-07 at 22.39.16.png
Screen Shot 2017-03-07 at 22.39.16.png (47.74 KiB) Viewed 9106 times

You can select to connect them to the input pins through jumpers (three black ones on the left) or leave the input pins open to be used for external measurements. Use the "resistor option in the device edit to convert the measured voltage to the resistor value of the light sensor / thermistor, which then gives you a direct measurement of the light intensity and the temperature.
If you don't use an input pin connect it to ground, that reduces noise for the other input channels.


For the output define a device model
"OUTPUT-i2cPCF8591-Analog-1x8bit"
And then send 0-3.3 V to the device through a menu option or an action you can setup in indigo.


The cheapest price I found was $2.50 at amazon https://www.amazon.com/TOOGOO-PCF8591-Converter-Digital-Conversion/dp/B00TK0TIEU/ref=sr_1_3?s=industrial&ie=UTF8&qid=1488921517&sr=1-3&keywords=PCF8591with free shipping (don't know how they make money)


Karl

Posted on
Sun Apr 02, 2017 7:43 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 5- connect sonsors to the rPi

VL53L0X TOF distance sensor.
https://www.amazon.com/Industry-Park-VL53L0X-Flight-Distance/dp/B01M4L5WHV/ref=sr_1_1?ie=UTF8&qid=1491176440&sr=8-1&keywords=VL53L0X
It goes for ~ $15.

This sensor measures distance with a laser and time of flight (TOF) of light pulse from sensor to object and back to sensor.

As it is a laser the beam is very focussed.
The resolution is < 0.5 cm in best accuracy mode.
In best distance mode it goes to more than 2 meters.

You connect 4 cables : V+ 3.3V/ Ground / two i2c cables SLA and SLC. The pins for Interrupt (out) and start(in) are not used.

The py program on the RPI can directly feed one of the supported display connected to the RPI.

All needed libraries etc are installed by the plugin.

You can define 3 local actions: short, medium, long distance event. If the measured distance goes between any of the distance ranges one of the events gets triggers and the action you select in the device edit is executed.


You can setup plugin update rate in seconds or in delta distance(%) if you have e.g. 20sec and 5% it will update if either is true: last update > 20sec OR the distance measured changes by more than 5%.

The attached screen shot shows an example config with one local action and local display enabled.
Screen Shot 2017-04-02 at 20.37.31.png
Screen Shot 2017-04-02 at 20.37.31.png (133.22 KiB) Viewed 9066 times



Karl
Attachments
Screen Shot 2017-04-02 at 20.42.51.png
Screen Shot 2017-04-02 at 20.42.51.png (74.98 KiB) Viewed 9066 times

Who is online

Users browsing this forum: No registered users and 4 guests