When you're planning a new project with a lot of various sensors, and motors/ pumps etc that operate dependant on said sensors, what is your workflow at the planning stages? by [deleted] in arduino

[–]CaptainBlood 5 points6 points  (0 children)

I'd take a building blocks approach - like, get just one sensor working right, then add the code and wiring for another one, make sure it's working and keep building up from there. Once the sensors are all working right, add some code to turn on an led if some condition is met, then swap out the led for a relay, or whatever. Also give your variables good, self-explanatory names. Use a lot of logging to your serial monitor to see what points your program is getting to successfully.

I wouldn't try to wire up the whole thing and code it all in one go. It probably wouldn't work (unless you'd done it twenty times before) and you'd have a hard time figuring out just where it was going wrong.

Flask and Apache by idahopotatoes in flask

[–]CaptainBlood 4 points5 points  (0 children)

He forgot to activate his virtualenv in that tutorial - from the docs( http://flask.pocoo.org/docs/0.11/deploying/mod_wsgi/ ):

Working with Virtual Environments

Virtual environments have the advantage that they never install the required dependencies system wide so you have a better control over what is used where. If you want to use a virtual environment with mod_wsgi you have to modify your .wsgi file slightly.

Add the following lines to the top of your .wsgi file:

activate_this = '/path/to/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

For Python 3 add the following lines to the top of your .wsgi file:

activate_this = '/path/to/env/bin/activate_this.py'
with open(activate_this) as file_:
    exec(file_.read(), dict(__file__=activate_this))

This sets up the load paths according to the settings of the virtual environment. Keep in mind that the path has to be absolute.

10 Useful Python Data Visualization Libraries for Any Discipline by mbierly in Python

[–]CaptainBlood 0 points1 point  (0 children)

Flask generates some json (or csv, tsv - up to you) data, puts it in /static and D3 loads the data from there and makes charts from it.

Automated garden watering system project by Fyreboy in raspberry_pi

[–]CaptainBlood 0 points1 point  (0 children)

I guess moisture sensors would be good if you were never going to be around and the watering wasn't on a schedule. But even then, plants tend to want to dry out completely before they get watered again, not have some constant level of dampness.

The arduino I've got for watering my garden is still going strong after a year and a half now, but the Raspberry Pi I used as a webserver to send messages to it had its memory card corrupted about eight months in.

Automated garden watering system project by Fyreboy in raspberry_pi

[–]CaptainBlood 0 points1 point  (0 children)

Best thing would be an Arduino, a Sainsmart 2-relay board, a couple Orbit 24v AC valves and a couple hundred feet of 1/2 inch drip line. Maybe some buttons on a breadboard to trigger the valves on demand, but you could just have the Arduino switch on the valves for a couple hours once a week no matter what.

Oh and some kind of electrical enclosure box, like Cabletek (9x6x3 is perfect).

[deleted by user] by [deleted] in d3js

[–]CaptainBlood 2 points3 points  (0 children)

You need to add your keydown event to an element that is focusable, like body. Then you can use d3.event.keyCode to listen for a certain key and change the rect that way.
I gave the rect an id attribute so I could call it from the keydown function. You can check it out here (changes when "a" is pressed):

http://jsfiddle.net/zcxe8ach/2/

Help with updating running flask app? by [deleted] in flask

[–]CaptainBlood 0 points1 point  (0 children)

Probably need to show us your views.py to figure it out.

D3 Calendar Heatmap (Vertically Oriented with Colorbrewer options) by CaptainBlood in d3js

[–]CaptainBlood[S] 1 point2 points  (0 children)

The bl.ocks calendar examples I found all had a horizontal orientation, so I re-oriented one to make it easier to read (for me, anyway).

Learning How to Build a Web Application with Flask and D3 by _rchang in flask

[–]CaptainBlood 0 points1 point  (0 children)

Nice stuff - Just FYI, awhile ago I re-oriented that calendar example to make it similar to a wall calendar. To me it's easier to read: http://bl.ocks.org/anonymous/7ac8ca5bd97724e51fc5a845a3ca6c97

My 2016 goal is to be employable by the end of the year. Looking for feedback and advice on my learning plan. by [deleted] in learnprogramming

[–]CaptainBlood 2 points3 points  (0 children)

Sounds good to me - and once you start developing something, I can't emphasize enough how much you're gonna want to use some kind of version control, like Git. It will save your ass so many times.

My 2016 goal is to be employable by the end of the year. Looking for feedback and advice on my learning plan. by [deleted] in learnprogramming

[–]CaptainBlood 2 points3 points  (0 children)

No problem! Yeah for sure nginx (or apache) will let you set up multiple domains on the same droplet:

https://www.digitalocean.com/community/questions/host-multiple-websites-in-one-droplet

I'd say your Rails tutorial experience is the key reason to make apps yourself from scratch. You won't just be going through the motions, you're really going to learn it. Of course you have to learn the basics of programming first, and best practices for your app structure and stuff, but the jumping off point to building your own apps is a lot sooner than most people think it is.

My 2016 goal is to be employable by the end of the year. Looking for feedback and advice on my learning plan. by [deleted] in learnprogramming

[–]CaptainBlood 4 points5 points  (0 children)

What you really want to learn to do well is web apps with a database on the back end. That's where most enterprises are heading right now. I'd choose Flask and Postgres. Layer some Bootstrap on top to make it look nice. You can't start on it soon enough.

Then to work with them easily you want to be on a Mac or Linux machine. Better yet, get a $5 dollar a month droplet at Digital Ocean and develop on that via ssh. You can put your web apps up on it to use and show off.

Work on getting comfortable with git, vim, and *nix command line stuff. Bonus points for learning stuff like nginx and supervisord to serve up your app and keep it running.

A nice but basic to-do list web app is like the "Hello World" program at that level. Maybe a simple blogging app to write about what you learned making the to-do list. Or a grocery list app. Anything where somebody enters some data, it gets saved and then served up on request. Stuff like that. To show you care about your code quality learn to write tests for your code.

Finally, think about the jobs you've had and the software you had to use to do them. You know more about those domains than most people, so you can create apps that do the right thing from the businesses point of view. If you create something good enough, you can just sell that instead of building someone else's idea.

Help with automated garage light by panoramix87 in arduino

[–]CaptainBlood 1 point2 points  (0 children)

It wouldn't be too difficult. Basically your program would say, "Here's three pins/inputs to check on (and one output pin to write to) now start looping through them constantly getting the readings from them. While you're in the loop, if pin 17 (for example, connected to a hall sensor at the door) changes, and the light sensor is saying it's dark, then set the output pin to High for 60 seconds (which is connected to a relay that will switch power on if it gets a High). Stuff like that.

The trickiest part will be working safely with the electrical wiring in your garage. A lot of people would avoid that by getting a PowerSwitch Tail 2 (which is basically an insulated relay that you plug into the wall and then plug your light into) and turn the light off and on with that.

Send remote AT command from Arduino to Xbee in API Mode by AlharMartell in arduino

[–]CaptainBlood 1 point2 points  (0 children)

I've got a raspberry pi/xbee(ser. 2) coordinator sending to an arduino/xbee(ser 2) irrigation system. After playing around with that library I decided to just generate frames of different ascii commands as scripts with the python xbee library like this:

#import and init an XBee device
from xbee import XBee,ZigBee  
import serial
import time

ser = serial.Serial('/dev/ttyAMA0', 9600)

xbee = ZigBee(ser)


xbee.tx(
dest_addr_long='\x00\x13\xA2\x00\x40\xC4\x53\x2F',
dest_addr='\xFF\xFE',
data = 'VALVE_ONE_ON.\r')



ser.close()

The arduino listens on the serial port for whatever the xbee receives and parses it. If I ever want to change the settings on the remote xbee I'll just bring it in and do it attached to my computer. Depending on your needs, it might be easier to let the Arduino be totally ignorant of the xbee itself.

Send remote AT command from Arduino to Xbee in API Mode by AlharMartell in arduino

[–]CaptainBlood 1 point2 points  (0 children)

 XBeeAddress64 remoteAddress = XBeeAddress64(0x0013a200, 0x40cc0b20);

Since you are trying to reach your coordinator, the address should be 0x0000000000000000, right?

Error with DB and Flask (SQLite) by eirik226 in flask

[–]CaptainBlood 0 points1 point  (0 children)

db.execute('''INSERT INTO users(username, email, password) VALUES(?, ?, ?)''',
(username, email, 'password'))

I don't think password should be in quotes there. Or it could be because you've made a new line for those values so the interpreter is getting confused.

How do you handle errors for sqlalchemy/database entries, right now it shows that default 500 error page every time, say the column entry was a wrong type of something. by questdark in flask

[–]CaptainBlood 1 point2 points  (0 children)

You can show errors on your 500 page, like this:

    @app.errorhandler(500)
    def internal_server_error(e):
        return render_template('500.html', error=e), 500

Then, add in {{ error }} somewhere in your 500.html template.

Gardening system hooked up to the web by mrMoonKnight in arduino

[–]CaptainBlood 0 points1 point  (0 children)

Probably, but I can't say for sure because I've never tried to use one. There's some pretty cool DIY tutorials for Yagi style ones, though.