###### tags: `TA Stuff 2021` `Pycom` `ESP32` # Sigfox First of all, check if you got coverage using the sigfox [map](https://www.sigfox.com/en/coverage). Follow [this tutorial](https://hackmd.io/VzC0xWY5SLWNmKY20FgWNw#Connect-the-antenna) on how to connect your antenna. ### Device registration To register your device follow this [tutorial](https://docs.pycom.io/gettingstarted/registration/sigfox/) (Sigfox will ask you for a company name. You can put anything there). **After you've registered** you will receive an email where you can set your Sigfox ID password. **Then you will** need to login to [Sigfox backend](https://backend.sigfox.com/auth/login), there you should see your device under the device section. ### Send data to Sigfox To send data to Sigfox, you can run the following script in `main.py`: ```python= from network import Sigfox import socket # init Sigfox for RCZ1 (Europe) sigfox = Sigfox(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ1) # create a Sigfox socket s = socket.socket(socket.AF_SIGFOX, socket.SOCK_RAW) # make the socket blocking s.setblocking(True) # configure it as uplink only s.setsockopt(socket.SOL_SIGFOX, socket.SO_RX, False) # send some bytes s.send(bytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])) ``` **Now on Sigfox** backend you can click on the device id and navigate to Messages to see your message as the picture below: ![](https://i.imgur.com/SqPcDfb.png) Observe the message in Data/Decoding. It's the same bytes 1, 2 3, etc that you sent, but in hexadecimal. You can send up to 12 bytes per message, this means you can send your sensor data, GPS coordinates, and even short text messages. ### Visualize the data on Pybytes So now when you can send data to Sigfox, how can we visualize the data? Follow [**this guide**](https://docs.pycom.io/pybytes/networks/sigfox/) to add your device to Pybytes. **After you've logged** in with your API Keys to Pybytes, go to your device configuration and change to Sigfox (and remove Wi-Fi if you've got that already). ![](https://i.imgur.com/k9Hk8et.png) **Run the Device Firmware updater** again to export all your settings to your device. (and remember to select "Force update pybytes registration" in the updater.) You should now see `Connected using Sigfox. Only upload stream is supported` when starting the device and it's connected to your port. **After you've done** that, and go to your device manager on Pybytes then "Provisioning" and look for this: ![](https://i.imgur.com/eVomep6.png) **Press "Check Sigfox Status"** to let Pycom add a callback automatically. Now everything should be green. **Now you can** run this script in `main.py`: ```python= import time while True: #Select a value to send, #perhaps before this you've read from a sensor value = 5 #Send the value pybytes.send_signal(1, value) print("sending: {}".format(value)) #Sending data once every 11 minutes time.sleep(60 * 11) ``` The value can be anything you want; perhaps a sensor value you're continously reading from a sensor. There's a maximum of 12 bytes per message (you will be warned if you exceed this and there's no danger in trying). **EU regulations state** that we can only occupy the public bandwith 1% of the time. This limits us to 140 messages per day according to Sigfox, or once per 10.3 minutes. If you're continously sending data, limit yourself to once every 11 minutes. This is plenty for continous reading of things like temperature, humidity etc.