Bit - Internet WIFI Extension Board for Micro | Bit by Elecfreaks |
Overview
Bit - Internet WIFI Extension Board for Micro | Bit by Elecfreaks |
Overview
Bit is ideal for a wide range of projects, including |
IoT-enabled robots and automation systems
Wearable devices and health monitoring systems
Environmental monitoring and tracking systems
Smart home automation and control systems
Educational projects and STEM learning initiatives
ESP8285
2.4GHz
802.11 b/g/n
115200bps
3.3V
<200mA
50x25mm
Applications
Bit with the IoT | Bit, users can unlock the full potential of IoT and create innovative, connected projects that interact with the world around them. |
IoT:Bit - Internet WIFI Extension Board for Micro:Bit by Elecfreaks
Overview
The IoT:Bit is a WiFi extension board designed for the Micro:Bit, allowing users to connect their Micro:Bit projects to the internet and create IoT-based applications. This board provides a simple and convenient way to add WiFi capabilities to the Micro:Bit, making it ideal for a wide range of projects, from home automation to robotics.
Features
Compatible with Micro:Bit
WiFi connectivity (2.4GHz, 802.11b/g/n)
Supports TCP/IP, UDP, HTTP, and FTP protocols
On-board antennas for improved signal strength
Micro-USB interface for programming and power
Supports both 3.3V and 5V power supply
Code Examples
### Example 1: Connecting to WiFi Network and Sending HTTP Request
This example demonstrates how to connect to a WiFi network using the IoT:Bit and send an HTTP request to a server.
```python
import microbit
from IoTBit import IoTBit
# Initialize IoT:Bit
iot = IoTBit()
# Set WiFi credentials
iot.wifi_set_credentials("your_wifi_ssid", "your_wifi_password")
# Connect to WiFi network
iot.wifi_connect()
# Check if connection is successful
if iot.wifi_is_connected():
print("Connected to WiFi network")
# Send HTTP request
url = "http://example.com/iot_data"
data = "temperature=25&Celsius"
response = iot.http_post(url, data)
print("HTTP response: ", response)
else:
print("Failed to connect to WiFi network")
```
### Example 2: Creating a Simple Web Server
This example demonstrates how to create a simple web server using the IoT:Bit and serve a webpage.
```python
import microbit
from IoTBit import IoTBit
# Initialize IoT:Bit
iot = IoTBit()
# Set WiFi credentials
iot.wifi_set_credentials("your_wifi_ssid", "your_wifi_password")
# Connect to WiFi network
iot.wifi_connect()
# Check if connection is successful
if iot.wifi_is_connected():
print("Connected to WiFi network")
# Create a simple web server
server = iot.http_server(80)
# Define a route for the root URL
@server.route("/")
def index():
html = "<h1>IoT:Bit Web Server</h1><p>Welcome to my IoT project!</p>"
return html
# Start the web server
server.start()
print("Web server started. Accessible at http://iotbit.local/")
else:
print("Failed to connect to WiFi network")
```
### Example 3: Sending Data to MQTT Broker
This example demonstrates how to connect to an MQTT broker using the IoT:Bit and send sensor data.
```python
import microbit
from IoTBit import IoTBit
import random
# Initialize IoT:Bit
iot = IoTBit()
# Set WiFi credentials
iot.wifi_set_credentials("your_wifi_ssid", "your_wifi_password")
# Connect to WiFi network
iot.wifi_connect()
# Check if connection is successful
if iot.wifi_is_connected():
print("Connected to WiFi network")
# Set MQTT broker credentials
broker = "your_mqtt_broker"
port = 1883
topic = "iot_data"
# Connect to MQTT broker
client = iot.mqtt_connect(broker, port)
# Send sensor data to MQTT broker
while True:
temperature = random.randint(20, 30)
data = f"temperature={temperature}&Celsius"
iot.mqtt_publish(client, topic, data)
microbit.sleep(1000)
else:
print("Failed to connect to WiFi network")
```
Note: These examples assume that you have the IoT:Bit library installed and configured correctly. You may need to modify the code to suit your specific project requirements.