update data to thingspeak
update data to thingspeak
Hello,
Is someone has working with Thingspeak for sending datas ?
I try to use urllib from Lucien2K (https://github.com/lucien2k/wipy-urllib) without success.
Can someone helping ?
Best regards
Jiemde
Is someone has working with Thingspeak for sending datas ?
I try to use urllib from Lucien2K (https://github.com/lucien2k/wipy-urllib) without success.
Can someone helping ?
Best regards
Jiemde
Re: update data to thingspeak
Hello, I'm a little bit dissapointed about the no response about my question.
Wipy seem to be a good candidate for Iot world, but if this board cannot communicate with a server on internet it's not an Iot!
I've ordered an Lopy board and I expect that this one can communicate in Lora ! or in Wifi !
I think that the documentation is very poor and not many examples or tutorial are available.
Is there a way to obtain some help when you facing a problem specially for new user ?
Waiting an answer.
Best regards
Jiemde
Wipy seem to be a good candidate for Iot world, but if this board cannot communicate with a server on internet it's not an Iot!
I've ordered an Lopy board and I expect that this one can communicate in Lora ! or in Wifi !
I think that the documentation is very poor and not many examples or tutorial are available.
Is there a way to obtain some help when you facing a problem specially for new user ?
Waiting an answer.
Best regards
Jiemde
Re: update data to thingspeak
You asked about thingspeak. My guess is the fact that nobody answered is because nobody else (on this forum) is using it.
There are many servers on the internet with many different protocols (dozens if not hundreds). I suspect that the WiPy is perfectly capable of talking to thingspeak, but that doesn't mean that it works "out of the box", and since nobody has used it, nobody knows if there are any gotchas or other wrinkles that you might run into.
There are many servers on the internet with many different protocols (dozens if not hundreds). I suspect that the WiPy is perfectly capable of talking to thingspeak, but that doesn't mean that it works "out of the box", and since nobody has used it, nobody knows if there are any gotchas or other wrinkles that you might run into.
Re: update data to thingspeak
Thanks Dave,
I understand! but is it possible to have some "models", because I've try a lot of libraries for Upython but without success!
Question: can I use "normal" libraries from Python 3 with the Wipy ? or is it necessary to use µpython one ?
Best regards
Jiemde
I understand! but is it possible to have some "models", because I've try a lot of libraries for Upython but without success!
Question: can I use "normal" libraries from Python 3 with the Wipy ? or is it necessary to use µpython one ?
Best regards
Jiemde
Re: update data to thingspeak
Some python libraries will run without modiication. Many though, will require modification because they would require many megabytes of memory which the WiPy just doesn't have.
The upython modules are written with "micro" in mind. The regular python libraries are not, and happily assume that there are many megabytes of memory available.
The upython modules are written with "micro" in mind. The regular python libraries are not, and happily assume that there are many megabytes of memory available.
Re: update data to thingspeak
Hi,
I have a question: what to choose between Urequests library ?
https://github.com/lucien2k/wipy-urllib ... equests.py or
https://github.com/micropython/micropyt ... equests.py ?
Is there some "examples" using these libraries ?
Best regards
Jiemde
I have a question: what to choose between Urequests library ?
https://github.com/lucien2k/wipy-urllib ... equests.py or
https://github.com/micropython/micropyt ... equests.py ?
Is there some "examples" using these libraries ?
Best regards
Jiemde
-
- Posts: 14
- Joined: Wed Jul 20, 2016 4:53 am
Re: update data to thingspeak
After a quick look it seems like you could use MQTT? I've been testing the umqtt.simple for displaying messages on a feather huzzah with oled thru mosquitto on a RPi3 and it's working quite well. I can't say for sure on thingspeak because I do see something about mqspeak and it's a little unclear whether you need a broker to act as a bridge to thingspeak or can you send MQTT directly?
-
- Posts: 15
- Joined: Thu Aug 04, 2016 3:04 pm
Re: update data to thingspeak
Here is some code I wrote to update a feed on ThingSpeak. I hope it is useful to someone. I apologize that the BBCode formatting tags do not seem to be working.
[code]
from network import WLAN
import socket
import ssl
# Edit these to suit your particular situation
api_key = 'XXXXXXXXXXXXXXX'
field_name = 'field1'
field_value = 75
ssid = 'your-ssid'
auth = (WLAN.WPA2, 'your-key')
wlan = WLAN(mode=WLAN.STA)
wlan.connect(ssid=ssid, auth=auth)
print(wlan.ifconfig())
host = 'api.thingspeak.com'
path = '/update?api_key=' + api_key + '&' + field_name + '=' + str(field_value)
addr = socket.getaddrinfo(host, 443)[0][-1]
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_SEC)
ss = ssl.wrap_socket(s)
ss.connect(addr)
msg = 'GET /' + path + ' HTTP/1.0\r\n\r\n'
ss.send(bytes(msg, 'utf8'))
[/code]
[code]
from network import WLAN
import socket
import ssl
# Edit these to suit your particular situation
api_key = 'XXXXXXXXXXXXXXX'
field_name = 'field1'
field_value = 75
ssid = 'your-ssid'
auth = (WLAN.WPA2, 'your-key')
wlan = WLAN(mode=WLAN.STA)
wlan.connect(ssid=ssid, auth=auth)
print(wlan.ifconfig())
host = 'api.thingspeak.com'
path = '/update?api_key=' + api_key + '&' + field_name + '=' + str(field_value)
addr = socket.getaddrinfo(host, 443)[0][-1]
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_SEC)
ss = ssl.wrap_socket(s)
ss.connect(addr)
msg = 'GET /' + path + ' HTTP/1.0\r\n\r\n'
ss.send(bytes(msg, 'utf8'))
[/code]
Re: update data to thingspeak
@quantalume
Many thanks. I've been posting to ThingSpeak using urequests.py and urequest.py, but haven't got these to work with HTTPS.
If I try to do a second 'ss.send' after a delay, I'm getting OSError 1 ("operation not permitted") - any ideas please?
Update: of course it works if I recreate the socket...
Jim
Many thanks. I've been posting to ThingSpeak using urequests.py and urequest.py, but haven't got these to work with HTTPS.
If I try to do a second 'ss.send' after a delay, I'm getting OSError 1 ("operation not permitted") - any ideas please?
Update: of course it works if I recreate the socket...
Jim
-
- Posts: 15
- Joined: Thu Aug 04, 2016 3:04 pm
Re: update data to thingspeak
[quote="jgmdavies"]
If I try to do a second 'ss.send' after a delay, I'm getting OSError 1 ("operation not permitted") - any ideas please?
Update: of course it works if I recreate the socket...[/quote]
I've only been updating my feeds once every 15 minutes, so I close and reopen the socket each time. It would be interesting to know if the WiPy or ThingSpeak are killing sockets after a preset time.
If I try to do a second 'ss.send' after a delay, I'm getting OSError 1 ("operation not permitted") - any ideas please?
Update: of course it works if I recreate the socket...[/quote]
I've only been updating my feeds once every 15 minutes, so I close and reopen the socket each time. It would be interesting to know if the WiPy or ThingSpeak are killing sockets after a preset time.