Skip to content

Instantly share code, notes, and snippets.

@nicolsc
Last active November 16, 2019 23:33
Show Gist options
  • Save nicolsc/07dd353e986fefb65a3687533cedd143 to your computer and use it in GitHub Desktop.
Save nicolsc/07dd353e986fefb65a3687533cedd143 to your computer and use it in GitHub Desktop.
Pycom+Sigfox test : send two values together
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)
@nicolsc
Copy link
Author

nicolsc commented Nov 16, 2019 via email

@jmxt3
Copy link

jmxt3 commented Nov 16, 2019

Please find attached the time of reception + payload + signal:

Time of reception: 2019-11-15 16:48:52
Payload: 210404a00381
Signal Quality: Good

Screen Shot 2019-11-16 at 20 31 32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment