Monday, December 28, 2015

20+ Things to plug into your ADC input


A list of analog sensor for your projects by category.


Power Monitoring

  1. AC/DC Current $4
  2. AC Single Phase Voltage Sensor $6 





Outdoor Environmental

Weather

  1. Wind Speed $70-$100
  2. Temperature
  3. Humidity
  4. Wind Direction $70-$100
  5. UV Light $5.99
  6. Light $3.95
  7. Lux Sensor $10

Garden

  1. Liquid Level Sensor 1Meter @ $80
  2. Soil Temperature $31
  3. Capacitive Soil Moisture Probe $31
  4. Water Pressure $20

Indoor Environmental

Air Quality

  1. Gas Sensor - Hydrogen $8
  2. Gas Sensor - Carbon Monoxide $12
  3. Gas Sensor - Alcohol $7.50
  4. Gas Sensor - CO2 $42
  5. Gas Sensor - LGP $8
  6. Flame Sensor $5



Presence 

  1. Sound Sensor $4.46
  2. Vibration Sensor $5.99
  3. IR Distance Sensors $11.25

Converters

Sunday, December 27, 2015

Raspberry Pi - A List of ADC Raspberry Pi Hats / Add-on Modules.

A list of ADC Raspberry pi Hats / add-on modules.  I will be doing another list of modules that are not hats but can be connected to the pi.

First a breakdown of what resolution and/or sample size mean.  If you see 8 bit, 10 bit, 12 bit etc you can find out the amount of samples by 2^(bits).  so 8 bit would be 2^8 = 256 samples.  So if you have 0 - 4.096v inputs and you are reading and you are reading wind speed 0-100kph.
4.096v = 20 m/s and
0 = 0 m/s (even if the threshold on making the anemometer spin is 0.5m/s)
so if the wind is blowing at 10m/s you would have an analog value of 128
you can take this equation  ((20-0)*125/256)+0.

Here's a break down of the conversion:

MaxR = max wind speed
MinR = min wind speed
ADCin = analog input from anemometer
ADCm = max sample/ resolution size of your ADC



Scaled analog = ((MaxR - MinR) * ADCin/ ADCm)+MinR

  • 8 Bit   has      256 samples
  • 10 bit  has   1,024 samples
  • 12 bit  has   4,096 samples
  • 14 bit  has 16,348 samples
  • 16 bit  has 65,536 samples 
  • 18 bit  has 262,144 samples 
  • and on and on..
Keep in mind that higher might be better but not always.  It depends on noise, sensor quality and other factors.  



Sadly the list below yields nothing less than $10 for an add-on module.. If you wanted to use the PiZero and a module it wouldn't be cost efficient.  Maybe a reader can help kickstart some simple cheap one purpose pi-zero hats such as an ADC for iot.  This left me to try other options possible a esp8266 (has a single 10bit analog input) or a Photon (~$20 and has 8 Analog inputs 12 bit).  There are some none add on modules that are i2c/spi connectable if you don't care to engineer your own enclosure/setup.

Here's an example $3/module and tiny for pi-zero happiness :-) 

Raspberry Pi Data Acquisition and Controller Pi-Plate 

$32



  • 8 Analog 10bit inputs
  • 2 Analog 10bit outputs
  • 7 open collector outputs @350mA
  • 8 digit inputs

Puuli ADS1256 DAC8552 Expansion Board 

$27

  • 8 Analog 24bit inputs
  • 2 Analog 16bit outputs


Analog to Digital Shield for Raspberry Pi

$22

  • 4 Analog 10bit
  • I/O Breakout for Raspi pins (setup link)

ADC Pi

£14.39
  • 8 Analog 17bit  inputs 0-5v
  • Up to 4 Stackable 


ADC Pi Plus

£16.99

  • 8 Analog 17bit inputs 0-5v
  • Up to 4 Stackable 


ADC-DAC Pi

£11.49

Abio model A

€27.96

  • 8 Analog 12bit inputs 0-4.096v
  • 16ch 8 bit PWM output

AD/DA Expansion Board

$10.95

  • 4 Analog 8bit inputs or outputs (pin setting)


Thursday, December 24, 2015

New S7-1200 & Snap7 Walkthrough Video Uploaded


I'm going to try and start a series of videos on python snap7 tutorial using my Raspberry Pi.
Here's the setup walkthrough :-)
Youtube link: https://youtu.be/yJNEsI5KJxs

Subscribe to my channel to keep up to date  Channel Link

Let me know what kind of things you'd like to see in the series :-)

Enjoy!


Sunday, November 29, 2015

Quick List of Raspberry Pi Cyber Monday Sales 2015

List of Online Stores That Have Sales For Cyber Monday! 


Pololu
Raspberry Pi Model B+ Sale price: $22.95
Regular price: $29.95.   Coupon code: BF15P2752 (limit 3)

Raspberry Pi Expansion Boards Sale discount: 30% off
code: BF15C188 (limit 5 per item)


Farnell (UK)
15% OFF online orders over £200
Add voucher code CYBERW15 to your basket
Raspberry Pi A+ Media Streaming Kit only £22
Raspberry Pi A+ Night Vision Camera Kit for only £47
Raspberry Pi A+ Multi Room Audio Player from only £38.50


BC-Robotics


PiSupply




Black Friday: 15% off Sitewide (some restrictions apply). code BLACKFRIDAY15


Sensors


SainSmart
 Cyber Monday Deals storewide 15%OFF Coupon code: "CBM15%" Over $150 will be upgraded to Express Shipping from Standard Shipping for FREE.

Solarbotics
Various good deals :-)

Friday, November 27, 2015

Raspberry Pi - Computing Pi and Outputing Results Realtime w/ Python




Since I'm in the United States I was able to celebrate Thanksgiving.  One of my favorite parts of this day is eating pie.  Over the last couple weeks I've been comparing streaming algorithms that output Pi(the number) as it's calculated.  One handy python library I found was the PiDigits Library.  I was amazed at how well it did.  I also (through a lot of googling) found a couple more variations of those pi algorithms.  Of course I wanted to find the fastest.  I hopefully try to optimize it with the gmpy python library which handles very large numbers better.

  1. One I found here: https://github.com/DaveMDS/pigreco Gosper? algorithm? 
  2. And another here https://github.com/spmacdonald/pi_spigot 
  3. And another here https://github.com/CSC-IT-Center-for-Science/scalable-python/blob/master/Demo/scripts/pi.py Lambert


All of which I compared to the Pidigits python library and found a close winner between the

found the 3rd to be the quickest but really close to the first 1st.. I wrapped much of the equation with mpz functions (which handles large integers).

import gmpy

def pi_decimal_generator(): #gosper        
        global j
        q, r, t, j = mpz(1), mpz(180), mpz(60), 2        
        while 1:
            u, y = mpz(3*(3*j+1)*(3*j+2)), mpz((q*(27*j-12)+5*r)/(5*t))
            q, r, t, j = mpz((20*j**2-10*j)*q), mpz(10*u*(q*(5*j-2)+r-y*t)), mpz(t*u), j+1            
            yield int(y)

def pi_lambert_mpz(): 
    #lambert    
    k, a, b, a1, b1 = 2, mpz(4), mpz(1), mpz(12), mpz(4)
    while 1:
        p, q, k = mpz(k**2), mpz(2*k+1), (k+1)
        a, b, a1, b1 = mpz(a1), mpz(b1), mpz(p*a+q*a1), mpz(p*b+q*b1)
        d, d1 = mpz(a/b), mpz(a1/b1)
        while d == d1:
            yield int(d)
            a, a1 = mpz(10*(a%b)), mpz(10*(a1%b1))
            d, d1 = mpz(a/b), mpz(a1/b1)


Graph of 20,000 digits of before mpz and after (on a non overclocked Raspberry Pi 2):




You can see that adding mpz (from the gmpy python library) increased digit output by over double.

Lamberts and Gospers seemed really close so I did a calc to 100,000 digits normal CPU speed and overclocked to 1ghz.


Looks better right :-)


I then looked at my CPU and noticed it was only using one of the 4 Cores that the Pi 2 has :-(.

I doing my research on seeing if this can be split into multiple processes. But so far my attempts have been unsuccessful.  Maybe a reader(much smarter then myself) can help enlighten me on this quest.  Please comment and share.

Happy Thanksgiving weekend..


Sunday, November 15, 2015

Raspberry Pi - Tools to Program on a Headless Raspberry Pi Remotely in Python!



I've found some very useful tools to help me program on my Raspberry Pis.  Most all of which are not connected to screens, unless you count the Picture Frame Pi which is on the wall and would be impractical to connect a mouse and keyboard to and start coding.  Here are the tools I use for Mac and PC operating systems.

IDE

PyCharm Community Edition


PyCharm is Available for Linux,Mac, and Windows environments.  With the next tool you can mount your Raspberry Pi's as a network volume using sshfs or winscp (Window's)



Mounting your Pi on Mac

Here there are a couple of options. Installing and setting up a samba share or use the currently built in features of ssh and scp.  I decided to go the ssh route and used the following tools for that on my Mac
First you need to install Macfusion. Macfusion allows you to mount various filesystems on your Mac including network filesystems with a couple plug-ins.  Without installing samba on your raspberry pi you can mount your filesystem using the sshfs plugin. Notice in the link to install the dependencies before installing Macfusion.

Mounting your Pi on Windows

There's also a couple options but again if you don't have samba setup and don't want to go through the hassle you can do the sshfs or scp mount in windows as well with a couple tools:
  • A great post for mounting is found here: SSHFS For Windows. This makes the sshfs share appear as a mounted network drive.  
  • Another way is to use WINSCP. You are able to browse through your Pi's filesystem and modify, copy, move, and delete files.  If you go to your settings within winSCP you can modify the editors for each filetype.  You will want to choose PyCharm for your .py extension filetype.  When you edit a file from winSCP it creates a temporary file in a temporary directory within windows.  It then checks for file changes and syncs it back to the pi  (or whichever ssh file system you mounted).   

Mounting your Pi on Ubuntu/Debian

Since Ubuntu and Debian are similar you can follow the basic procedure here.  You can mount using the "Connect to Server" tool for mounting the SSHFS.  

Opening your project


After mounting you can open a current python project folder or create a new one.  Since I'm on my Mac you'll see the open dialog screen similar to that.  


Debugging your Project

PyCharm is an awesome tool with debugging. I found this article( which I couldn't have explained it better) on how to debug remotely http://www.codeproject.com/Tips/987276/Remote-Programming-of-RaspberryPi-using-PyCharm 


Hope this has been helpful.. If you don't like writing in nano and running.  Or opening up a VNC viewer and running the PyCharm IDE on the Pi..

Please Share if you found this helpful!!