Skip to content

Latest commit

 

History

History
104 lines (76 loc) · 6.97 KB

README.md

File metadata and controls

104 lines (76 loc) · 6.97 KB

WiPee

Run code on a WiPy and with two cables connected to port 11 and 12 the WiPy will notice connection and trigger an email using AWS services.

Dependencies

Configuring WiPy

###################################################################################################
# CONFIG NETWORK
###################################################################################################

ip = 'EDIT_ME'              # IP to set for wipy.
subnet = '255.255.255.0'    # Subnet, most likely leave as is.
router = 'EDIT_ME'          # Router of network, usually x.x.x.1
dns = '8.8.8.8'             # IP of dns to use, 8.8.8.8 is a google dns.
wlanName = 'EDIT_ME'        # Name of WLAN to connect to.
wlanPass = 'EDIT_ME'        # Pass of WLAN to connect to.
wlanType = WLAN.WPA2        # Type of network security.
wlanAntType = WLAN.EXT_ANT # Specify ext or int antenna of the wipy. WLAN.INT_ANT

and

###################################################################################################
# CONFIG AWS IOT
###################################################################################################

awsPort = 8883                                    # Port of AWS IoT endpoint.
awsHost = 'EDIT_ME'                     # Your x.iot.eu-west-1.amazonaws.com
awsRootCA = '/flash/cert/ca.pem'                  # Root CA file.
awsClientCert = '/flash/cert/certificate.pem.crt' # Certificate.
awsPrivateKey = '/flash/cert/private.pem.key'     # Private key.

clientID = 'EDIT_ME'            # ID used when sending messages to AWS IoT.
topic = 'EDIT_ME'               # Name of the topic to send messages to.

and optionally

###################################################################################################
# CONFIG WATER MONITORING
###################################################################################################

# Setup pins used for water detection.
pinCricital = Pin('P12', mode=Pin.IN, pull=Pin.PULL_UP)
pinWarning = Pin('P11', mode=Pin.IN, pull=Pin.PULL_UP)

# Every .5 sec cNormal, cWarning or cCritical goes up 1, when reaching 10 water level confirmed.
monitorTick = 0.5

# How long in ms device should sleep between meassure runs.
deepSleepTime = 300000 # 300000 = 5 min
  • Upload/Sync main.py and boot.py to the WiPy. All done!

If we assume you have the certificates for AWS and done all the above, then after resetting the device, it will begin monitoring.

If we assume you have IoT and Lambda configured, then in a few seconds a mail should come letting you know WiPee is up and running.

If we assume you have connected two cables, one to pin 11 and ground and one to pin 12 and ground, then dipping them in water, will send you a new mail at the next monitoring run.

Configuring AWS

There is too much to write about the AWS bits so I'll link relevant and useful tutorials/documentation for each bit. If completely new to AWS, check out https://aws.amazon.com/ and prepared to be confused, there is a ton of stuff. A good place to start for quick peeks at what you can do, and how to do it, is https://aws.amazon.com/getting-started/tutorials/.

If you have an AWS account or have a new one created (most, maybe even all, will be free tier) then here are the general things needed to be done:

My rule in IoT is "SELECT mailType, timeString, timeStringCritical FROM 'wipeeMail' WHERE mailType < 10" where wipeeMail is the topic I publish messages to. From the add action option, you can select "Invoke a Lambda function passing the message data". There you select the lambda function you created earlier. After doing this, if you go back to Lambda you should see a graphic showing input from IoT to the Lambda function. If you tested and verified that each part works, and updated the main.py with the IoT url and topic, then restarting the WiPy should publish the "I'm up and running" message to your inbox.

Configuring Hardware

How it is connected and when both cables are "in water". breadboard

From left to right:

  • Blue ground connected to WiPy ground.
  • White VIN connected to (THIS IS ERROR, BRAIN FREEZE) 3v3, should have been VIN which is the first pin to the left of the blue ground. Sorry about this. If using 3v3 make sure source is 3v3!
  • Yellow is pin 11, connected with ground (blue) and this means water level is elevated.
  • White is pin 12, connected with ground (blue) and this means water level is critical.

Add power source and by breaking/making connection for pin 11 and 12 you can simulate the WiPee monitoring changes in water level.

The final device

Half the stuff I had home and half the stuff (box, antenna) I bought for the project.

box

inside