Introduction: Raspberry Pi 2 Water Alarm With T Cobbler Plus
This is our first try with the raspberry pi 2
We wanted to create an headless water alarm
- Raspberry Pi 2
- Funduino water sensor
- 1k resistor
- Red Led
- Adafruit T-cobbler Plus
- Large breadboard (too large ;-p)
Step 1: Setup of the PI 2
We only had one screen for 6 people. This meant we needed to create an terminal session to the Pi.
We used putty and filezilla.
The installation could only be performed using a screen. We used an old computer monitor with a hdmi to vga converter. That only partially worked we could start the installation of the OS but once the first reboot occured the screen didn't work anymore.
Luckilly we could connect using putty to the PI 2 and run the python code on the board.
It took a while to figure out how this worked. We by accident installed an old version of RPI.GPIO this meant we had to reinstall the OS.
After this we got the hello world of electronics to work "Blink".
Step 2: After Lunch
For us as NOOBS it took 3 hours to get to this step it meant getting lunch.
Next step was to find a sensor which would work with the PI it needed to work with 3v and should be digital. We started with an endswitch as proof of concept.
This didn't impress us very much so we made this impressive water alarm.
Step 3: End Result
The final result was that the led would indicate the sensor was submerged.
The simple code below was what was needed to get things running.
import time<br>import RPi.GPIO as io io.setmode(io.BCM) moist_pin = 17 led_pin = 18 io.setup(moist_pin, io.IN) # activate input io.setup(led_pin, io.OUT) # activate output while True: if io.input(moist_pin): print 'high' io.output(led_pin, io.HIGH) else: print 'low' io.output(led_pin, io.LOW) io.cleanup()
To run the code type "sudo python wet.py" on the command line
We had a go to get the WebIOPi to work. But regretfully it didn't get up and running on the PI 2
Step 4: Adafruit T-cobbler Plus
After having soldered the cobbler we looked up how the Pi and the cobbler should be connected. At first we found the wrong way to connect on google but finally at adafruit noticed the cable should be turned arround.