By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,275 Members | 1,924 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,275 IT Pros & Developers. It's quick & easy.

Can I make a list of printed values, average them, and tweet/email the result?

P: 2
I'm building a Raspberry Pi soil moisture monitor and I've gotten to a point where I know what I want it to do, but I don't know where to go from where I am. I've built the hardware, and have simple code to poll the sensor at whatever interval I desire, and it prints a value. What I would like is to be able to poll the sensor every hour, average those values, and tweet or email that daily average at a specified time, but I don't know how to do this. Here's what I have so far.

Expand|Select|Wrap|Line Numbers
  1. import time
  2.  
  3.     from board import SCL, SDA
  4.     import busio
  5.  
  6.     from adafruit_seesaw.seesaw import Seesaw
  7.  
  8.     i2c_bus = busio.I2C(SCL, SDA)
  9.  
  10.     ss = Seesaw(i2c_bus, addr=0x36)
  11.  
  12.     while True:
  13.         # read moisture level through capacitive touch pad
  14.         touch = ss.moisture_read()
  15.  
  16.         # read temperature from the temperature sensor
  17.         temp = ss.get_temp()
  18.  
  19.         print("  moisture: " + str(touch))
  20.         time.sleep(3600)
  21.  
Any help would be greatly appreciated. Like I said, I'm brand new to coding in general, and I know I have a lot to learn, but I don't know where to go to learn it so I thought I'd start here. Sorry if this is the wrong place or something.
Jan 19 '20 #1

✓ answered by dwblas

What I would like is to be able to poll the sensor every hour, average those values
Store the results in a list of lists or dictionary, and average from the start and end time of your choice.

Share this Question
Share on Google+
2 Replies


Expert 100+
P: 626
What I would like is to be able to poll the sensor every hour, average those values
Store the results in a list of lists or dictionary, and average from the start and end time of your choice.
Jan 20 '20 #2

P: 2
@dwblas
This is a great start, thank you very much! At least I know what to look for. I'm off to learn how to do those things now!
Jan 21 '20 #3

Post your reply

Sign in to post your reply or Sign up for a free account.