-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented payouts and sensor data page
- Loading branch information
Showing
40 changed files
with
535 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,13 @@ | ||
from algosdk.constants import address_len, note_max_length | ||
from flask_wtf import FlaskForm | ||
from wtforms import DecimalField, StringField, SubmitField | ||
from wtforms.validators import InputRequired, Optional, Length, NumberRange | ||
|
||
|
||
class EnrolForm(FlaskForm): | ||
"""Policy enrollment form""" | ||
signature = StringField( | ||
'Signature', | ||
validators=[InputRequired(), Length(min=5)], | ||
render_kw={"placeholder": "Signature"} | ||
) | ||
submit = SubmitField('Join') | ||
|
||
|
||
class PayForm(FlaskForm): | ||
"""Payment form""" | ||
amount = DecimalField( | ||
'Amount', | ||
validators=[InputRequired(), NumberRange(min=0)], | ||
render_kw={"placeholder": "Premium Amount"} | ||
) | ||
receiver = StringField( | ||
'Receiver', | ||
validators=[InputRequired(), Length(min=address_len, max=address_len)], | ||
render_kw={"placeholder": "Receiver Address"} | ||
) | ||
note = StringField( | ||
'Note', | ||
validators=[Optional(), Length(max=note_max_length)], | ||
render_kw={"placeholder": "Note"}) | ||
submit = SubmitField('Pay') | ||
from wtforms import StringField, SubmitField | ||
from wtforms.validators import InputRequired | ||
|
||
|
||
class LoginForm(FlaskForm): | ||
"""Login form""" | ||
passphrase = StringField('25-word Passphrase', | ||
validators=[InputRequired()], | ||
render_kw={"placeholder": "Enter your 25-word Passphrase"} | ||
) | ||
passphrase = StringField( | ||
'25-word Passphrase', | ||
validators=[InputRequired()], | ||
render_kw={"placeholder": "Enter your 25-word Passphrase"} | ||
) | ||
submit = SubmitField('Login') |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from machine import Pin | ||
import dht | ||
|
||
|
||
def get_temp_hum(): | ||
sensor = dht.DHT11(Pin(5)) | ||
try: | ||
sensor.measure() | ||
t = sensor.temperature() | ||
h = sensor.humidity() | ||
print('Temperature: %3.1f C' % t) | ||
print('Humidity: %3.1f %%' % h) | ||
return t, h | ||
except OSError as e: | ||
print('Sensor Reading Failed') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import network | ||
import time | ||
import creds | ||
import urequests | ||
import dht11 | ||
import soil_moisture | ||
import ujson | ||
|
||
|
||
def connect_wifi(): | ||
wifi = network.WLAN(network.STA_IF) | ||
wifi.active(True) | ||
wifi.connect(creds.ssid, creds.pwd) | ||
|
||
timeout = 6 | ||
delay = 0 | ||
if not wifi.isconnected(): | ||
print('connecting ..') | ||
while not wifi.isconnected() and delay < timeout: | ||
print(timeout - delay) | ||
delay = delay + 1 | ||
time.sleep(1) | ||
|
||
if wifi.isconnected(): | ||
print('Connected') | ||
else: | ||
print('Timed Out') | ||
|
||
return wifi | ||
|
||
|
||
def get_data(): | ||
temperature, humidity = dht11.get_temp_hum() | ||
#soil_m = soil_moisture.get_soil_moisture() | ||
|
||
post_data = ujson.dumps({'temperature': temperature, 'humidity': humidity, 'soil_moisture': 50 , 'farm': 'Puma Farm', 'crop': 'Maize'}) | ||
request_url = creds.endpoint + '/weather' | ||
print(request_url) | ||
try: | ||
res = urequests.post(request_url, headers={'content-type': 'application/json'}, data=post_data) | ||
print(res.json) | ||
except Exception as e: | ||
print(e) | ||
|
||
|
||
def main(): | ||
wifi = connect_wifi() | ||
if wifi.isconnected(): | ||
while True: | ||
get_data() | ||
time.sleep(20) | ||
|
||
|
||
main() |
Oops, something went wrong.