Last active
November 16, 2019 23:33
-
-
Save nicolsc/07dd353e986fefb65a3687533cedd143 to your computer and use it in GitHub Desktop.
Pycom+Sigfox test : send two values together
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
from network import Sigfox | |
import socket | |
import struct | |
import binascii | |
#Sigfox config | |
sigfox = Sigfox(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ1) | |
s = socket.socket(socket.AF_SIGFOX, socket.SOCK_RAW) | |
print('I am device ', binascii.hexlify(sigfox.id()) ) | |
# make the socket blocking | |
s.setblocking(True) | |
# configure it as uplink only | |
s.setsockopt(socket.SOL_SIGFOX, socket.SO_RX, False) | |
##My data | |
temperature = 34.25 | |
humidity = 67 | |
output = bytearray(5) | |
struct.pack_into("<f",output,0,temperature) | |
struct.pack_into("<B",output,4,humidity) | |
print("output=",output) | |
print('Sending data to SigFox Cloud Service...') | |
s.send(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please find attached the time of reception + payload + signal:
Time of reception: 2019-11-15 16:48:52
Payload: 210404a00381
Signal Quality: Good