Skip to Content

Introducing to Sigfox:

Sigfox is a global (Low Power Wide Area) provider. The Sigfox network operate in the 100 kHz of publicly available band to exchange radio messages over air. Each message is 100 Hz wide and transferred at 100 or 600 bits per second a data rate, depending on the region. Hence, long distances can be achieved while being very robust against the noise. (source: Sigfox).

An important point is here also that an Sigfox message has an small 12-bytes payload.

Futheromre Sigfox has the follwong restrictions (pls check also this):

  • 140 messages in uplink with a payload up to 12 bytes
  • 4 messages in downlink with a payload of 8 bytes

If we check the IoT service release notes we can see that with version 4.8.0 SAP provide now an “Gateway EDGE” component for the “Sigfox” network and by the way its clear that i want to check out this variant to get measures from a device/sensor.

The Hardware

  • PKCELL LiPo Akku 1100mAh JST-PH Connector
  • Pycom Pysense Sensor Shield
  • Pycom LoRa / Sigfox Antenna Kit
  • Pycom SiPy Espressif ESP32 Sigfox/WiFi/BLE Dev. Board

 

Upgrading the Firmware

The first thing what we need to do is to upgrade the firmware as described here.

Based on the fact that i dont have the pycom expansion board where u can wire as described simple, i´am using here two (in German: Krokodilklemmen):

Now i starting the “Pycom Upgrade” Tool.

Note: For me it works only if th “High speed transfer” box is unchecked:

Finally we get the info that our device is successfully updated and the two values which are needed to resgister our device on the “Sigfox” side:

This can also be achived by opening putty and connect via the serial interface to the board and entering the following lines:

from network import Sigfox
import binascii

# initalise Sigfox for RCZ1 (You may need a different RCZ Region)
sigfox = Sigfox(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ1)

# print Sigfox Device ID
print(binascii.hexlify(sigfox.id()))

# print Sigfox PAC number
print(binascii.hexlify(sigfox.pac()))

As result u get also the “ID” and the “PAC”!

Register your device at Sigfox

Whit the information on the step before we can now register us and the device on the “Sigfox” website:

Futhermore some Details from you and your Conpany are required, and finally you get the confirmation of the registration:

Some coding

Now we are allowed to send messages to the “Sigfox Backend” we need a little tiny program to collect some data.

The used pycom board supports “Microphyton” as programming language so lets build up some lines:

import time
import pycom
from network import Sigfox
import socket
from pysense import Pysense
from SI7006A20 import SI7006A20
from MPL3115A2 import MPL3115A2,ALTITUDE,PRESSURE

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)

#pysense
py = Pysense()
si = SI7006A20(py)
mp = MPL3115A2(py,mode=ALTITUDE)

def getAltitude():
    altitude=mp.altitude()
    print("Altitude raw data")
    print(altitude)
    print(".......")
    return int(altitude)

def getHumidity():
    humidity=si.humidity()
    print("Humidity raw data")
    print(humidity)
    print(".......")
    return int(humidity)

def getTemp():
    temperature=si.temperature()
    print("Temp raw data")
    print(temperature)
    print(".......")
    return int(temperature)

while True:
    print("Start...")
    temperature= getTemp()
    humidity=getHumidity()
    altitude=getAltitude()
    s.send(bytes([temperature, humidity, altitude,]))
    print("Successfully send data to Sigfox...")
    # wait 10 min to send next message
    time.sleep(600)

As u can see we send messages onyl every 10 minutes, this i based on the restriction of 140 messages per day by the Sigfx network.

To copy this program to our “SiPy” board i´am using here the “Atom” editor with the “Pymakr” plugin

After we sync our local program we can now see on the serial console the program works:

If we now check on the Sigfox side whats happen, we can see our device is now availble…great ;o):

And futhermore we can of course see our message as “HEX” representation and some additional infos like the quality of the signal:

If u click on the small “location” icon, we can also identify in what area is our device:

In the next blog i will give u an overview how we get these “Sigfox” messages in SAP Cloud Platform IoT service and also some improvements like the new UI ;o) :

 

cheers,

fabian

 

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Witalij Rudnicki

    Hi Fabian. Thanks for sharing. I tried Pycom in the past, but it was failing on working with Atom, so I gave up. Seems like I would need to give it a second chance.

    Btw, what is def sendSigfox(datafor? It does not seem to be used elsewhere in the code.

    (0) 
  2. Fabian Lehmann Post author

    Hi Witalij,

     

    ups my mistake, you´re right function not used, i just change this.

    And always for me the Atom was a little challenge to work with “Pymakr” plugin. The solution was to switch to an older version (1.21.1) this works now ;o)

    cheers,

    fabian

    (0) 

Leave a Reply