Go back to Product Documents Navigation
Go back to Future Board Documents Navigation
Import FutureBoard Library
Import the Library to make use of its functions.
| from future import * |
07: WiFi & IoT
1. Connect to WiFi
| wifi.connect('router','password') |
FutureBoard can only connect to wireless networks with 2.4GHz frequency.
2. Get the Connection Status
| wifi.sta.isconnected() |
Returns 1 if FutureBoard is connected to the network, 0 if not.
3. Get the Connection Configuration
| wifi.sta.ifconfig() |
Returns a list with the configuration including IP Address, Subnet Mask, Gateway, Domain.
4. Get the MAC Address
|
import machine |
Returns the physical address of the FutureBoard.
Sample Program 1~4
|
#/bin/python |
Import MQTT Library
| import mqttsimple |
MQTT operations require the mqttsimple library.
5. Set up an MQTT object
| myMQTT = mqttsimple.MQTTClient(server,client_id,port=0,user=None,password=None,keepalive=0,ssl=False,ssl_params={}) |
Creates an object with the connection to the MQTT Broker.
For most brokers, insert the host address into server and the client id into client_id.
For some brokers, please refer to the broker’s documentations for the details required to connect to the server.
6. Connect to the MQTT Server
| myMQTT.connect() |
7. Disconnect the MQTT Server
| myMQTT.disconnect() |
8. Subscribe to a MQTT Topic
| myMQTT.subscribe(topic=) |
Fill in the topic name according to the documentation of the MQTT Broker.
9. Publish a Message to a MQTT Topic
| myMQTT.publish(topic,msg) |
Fill in the message and topic name according to the documentation of the MQTT Broker.
10. Read the Message from the MQTT Topic
| myMQTT.mqttRead(topic) |
Fill in the topic name according to the documentation of the MQTT Broker.
11. Read the Last Message of the MQTT Topic
| myMQTT.check_msg() |
12. Wait until a MQTT Message is Published
| myMQTT.wait_msg() |
13. Define MQTT Event Trigger Function
|
def myFunction(topic,msg): |
Sample Program 1
|
import mqttsimple |
Sample Program 2
|
import mqttsimple |
If you have any question, please feel free to contact us at Discord, we will always be there to help.
KittenBot Team

