Send data to the channel asynchronously / as bulk | Raspberry Pi | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Send data to the channel asynchronously / as bulk
No permission to create posts
August 23, 2018
7:12 am
Avatar
larimow
New Member
Members
Forum Posts: 1
Member Since:
August 23, 2018
sp_UserOfflineSmall Offline

Hi all,

I'm pretty new to this Topic but I have searched the Forum and the web but have not yet found a solution.

I am a hobby wine maker and just recently upgraded my production room with a temperature and humidity control System, using a raspberry pi and a DHT22. The data get's uploaded with the following code (slightly altered, as this is taken from a tutorial) to ThingSpeak:

________________________________________________________________________________________________________________
import thingspeak
import time
import Adafruit_DHT

channel_id = 206897 # PUT CHANNEL ID HERE
write_key = '24GJQV17H7H4XGJ5' # PUT YOUR WRITE KEY HERE
read_key = '9EZ7E0918UVVAGAY' # PUT YOUR READ KEY HERE
pin = 4
sensor = Adafruit_DHT.DHT22

def measure(channel):
try:
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
# write
response = channel.update({'field1': temperature, 'field2': humidity})

# read
read = channel.get({})
print("Read:", read)

except:
print("connection failed")

if __name__ == "__main__":
channel = thingspeak.Channel(id=channel_id, write_key=write_key, api_key=read_key)
while True:
measure(channel)
# free account has an api limit of 15sec
time.sleep(15)
________________________________________________________________________________________________________________

The transmission itself and displaying of the data works without any complications.

Unfortunately, the router has some major issues and shuts down more or less every day. I will tackle that problem as well but for the moment I'd like to create a workaround.

Hence the question: is it possible to locally log the data (in a round robin data base for instance) as soon as the wifi shuts down AND transmit all the logged data as a bulk to ThingSpeak as soon as the connection is up again? This would help me to consistently monitor and analyze the necesseary information for the fermentation process online.

If I just missed the right tutorial to do just that, a link might suffice to solve my problem. I'm eager to read and learn to solve my problems on my own but as of yet, I don't see a starting point.

Thank you in advance.

Cheers,
Larimow

August 30, 2018
10:28 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 410
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

I think I have the tutorial you ordered:
https://www.mathworks.com/help/thingspeak/continuously-collect-data-and-bulk-update-a-thingspeak-channel-using-a-raspberry-pi-board.html
Please let us know how it works, and when there are open tastings!

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: ziplock9000
28 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

EnigmBioge, debbiepe18, MatthewmUb, cathrynww1, Slark, inads11

Administrators: Hans: 387, lee: 457