Friday, March 18, 2016

Raspberry Pi - 81 DS18B20 Sensors on Multiple GPIO



Video Explanation


Two ways to get multiple GPIO working.

Bitbanging your gpio or using a modified kernel w1-therm module which requires editing some source files and recompiling the kernel.  I will cover the kernel mod later because of how extensive it is.  So this post will be on using the BitBangingDS18B20 program found here on github

My Temperature Grid Source is found here.  The grid is a websocket/web server in Python and runs the DS18B20Scan program and sends the data through the websocket on temperature change.  In order to get it to do it at the same time you will have to run each Bus/Pin on it's own thread.  I used the twisted
Here's the Basic code of how I brought the BitBangingDS18B20 code into my python project:

def DS18B20_Bus(pin,data):
        pins = [4,17,27,5,6,13,19,26,21]
        pins.reverse()
        pin = pins[int(pin)-1]
        busdata = []
        position = 0
        args = 'sudo ./DS18B20Scan -gpio {} -t {} -F'.format(pin,30).split(' ')
        process = Popen(args, stdout=PIPE)
        (results, err) = process.communicate()
        exit_code = process.wait()
        probes = re.findall('(\d{2}-\w{12} ):\s+(\d{0,2}).bits\s Temperature:\s(\d{1,3}.\d{1,4})', results)
        bus = pins.index(pin)+1
        #print probes
        for probe in probes:
            try:
               # print data[probe[0].replace(" ",'')]
                if data.has_key(probe[0].replace(" ",'')):
                    position=data[probe[0].replace(" ",'')]["Pos"]
                else:
                    position +=1
                    print probe, bus

                temperatureInfo = {"ID":probe[0].replace(" ",''),"Pos":position,"Bus":
                    bus,"Temperature": round(float(probe[2]),3)} #,'Time': time.time()
                if probe[2] !="185.0000":
                    busdata.append(temperatureInfo)
            except:
                pass
        return busdata



Benchmarked

How does this compare to the 1-wire modules, Kernel Module??




Hope this helps
-Ninja Nate
Wednesday, March 16, 2016

Pi Day 2016 - Raspberry Pi Calculating Pi and Streaming It Via Websockets Update

As some of you may have visited on pi day the site pi.raspi-ninja.com is still live.. I ran into an issue 26hrs into the calculation (dang power adapter was loose). But the raspberry pi calculation is running again and has backup power hooked up to it just in case :-).  I have put my src code on.  https://github.com/raspi-ninja/PiWebSocket.



To breakdown how it all worked I released it on my  youtube channel.

Might restart the web-socket echo server several times as it is modified to maybe post automagically significant numbers or daily.

See the details behind it and watch it hit the 1,000,000th digit:

More awesome pi-ninja videos coming soon.  So please subscribe :-) !!

-Ninja Nate

Sunday, March 13, 2016

Pi-Day - Streaming Pi Realtime to the Web Using A Raspberry PI 3!


Check out my Streaming Pi Page to see it realtime.  Will begin at 12:00AM GMT (20 minutes from when I posted this).

Not sure if anyone has really ever streamed pi realtime to the web.. Especially on Pi day.

See it Here:

http://pi.raspi-ninja.com

Happy Pi Day!!!

-Ninja Nate


Details on how it was done will come soon :-).
Monday, February 22, 2016

Pi Day is Pi Weeks Away

Take Pi multiply it by weeks and you get Pi day.  Monday, February 22, 2016 + 3.142 weeks
http://www.wolframalpha.com/input/?i=pi+weeks+from+feb+22
I'm a fan of Pi day.. Not only because It's Einstein's birthday but it's my wife's too :-).

This year is a bit different.. if you take Pi to the 4th digit 3.1415<--- you are suppose to round that 5 up.... making it a "6".  So this year is 3.14.16.  Which still makes it a pi year.

I will be doing something awesome this day and for approx pi days long.  I will have 3 Raspberry Pis doing pi calculations and broadcasting the results as it's calculated realtime on to the web.  Stay tuned for the link.  

Keeping it Extreme
Ninja-Nate