À l'aide de Python et Arduino MKR1000 pour Sécuriser l'Ido

Getting started with Python and Arduino MKR1000 for secure IoT projects.

Using Python and Arduino MKR1000 for Secure IoT

Things used in this project

Hardware components

Arduino MKR1000
Arduino MKR1000
×1

Software apps and online services

Zerynth Studio
Zerynth Studio

Story

Schematics

arduino_mkr1000_python_-_pinmap_64bsfgwRAj

Code

Code snippet #1

Python

pinMode(LED0, OUTPUT)
 
# loop forever
while True:
    digitalWrite(LED0, HIGH)  # turn the LED ON by setting the voltage HIGH
    sleep(1000)               # wait for a second
    digitalWrite(LED0, LOW)   # turn the LED OFF by setting the voltage LOW
    sleep(1000)               # wait for a second

Code snippet #2

Python

###############################################################################
# Zerynth Secure Sockets
################################################################################
 
 
# import streams & socket
import streams
import socket
 
# import json parser, will be needed later
import json
 
# import the wifi interface
à partir de wireless import wifi
 
# import the http module
import requests
 
# the wifi module needs a networking driver to be loaded
# in order to control the board hardware.
# FOR THIS EXAMPLE TO WORK, A NETWORK DRIVER MUST BE SELECTED BELOW
 
# uncomment the following line to use the CC3000 driver (Particle Core or CC3000 Wifi shields)
# from texas.cc3000 import cc3000 as wifi_driver
 
# uncomment the following line to use the BCM43362 driver (Particle Photon)
# from broadcom.bcm43362 import bcm43362 as wifi_driver
 
# uncomment the following line to use the WINC1500 driver (MKR1000)
à partir de microchip.winc1500 import winc1500 comme wifi_driver
 
 
streams.serial()
 
# init the wifi driver!
# The driver automatically registers itself to the wifi interface
# with the correct configuration for the selected board
wifi_driver.auto_init()
 
 
# use the wifi interface to link to the Access Point
# change network name, security and password as needed
print("Establishing Link...")
try:
    # FOR THIS EXAMPLE TO WORK, "Network-Name" AND "Wifi-Password" MUST BE SET
    # TO MATCH YOUR ACTUAL NETWORK CONFIGURATION
    wifi.link("Network-Name",wifi.WIFI_WPA2,"Wifi-Password")
except Exception comme e:
    print("ooops, something wrong while linking :(", e)
    while True:
        sleep(1000)
 
# let's try to connect to https://www.howsmyssl.com/a/check to get some info
# on the SSL/TLS connection
 
        
pour i dans range(3):
    try:
        print("Trying to connect...")
        url="https://www.howsmyssl.com/a/check"
        # url resolution and http protocol handling are hidden inside the requests module
        user_agent = {"User-Agent": "curl/7.53.1", "Accept": "*/*" }
        response = requests.get(url,headers=user_agent)
        # if we get here, there has been no exception, exit the loop
        break
    except Exception comme e:
        print(e)
 
 
try:
    # check status and print the result
    if response.status==200:
        print("Success!!")
        print("-------------")
        # it's time to parse the json response
        js = json.loads(response.content)
        # super easy!
        pour k,v dans js.items():
            print(k,v)
        print("-------------")
except Exception comme e:
    print("ooops, something very wrong! :(",e)


A Propos De L'Auteur

Ibrar Ayyub

Je suis expérimenté, rédacteur technique, titulaire d'une Maîtrise en informatique de BZU Multan, Pakistan à l'Université. Avec un arrière-plan couvrant diverses industries, notamment en matière de domotique et de l'ingénierie, j'ai perfectionné mes compétences dans la rédaction claire et concise du contenu. Compétent en tirant parti de l'infographie et des diagrammes, je m'efforce de simplifier des concepts complexes pour les lecteurs. Ma force réside dans une recherche approfondie et de présenter l'information de façon structurée et logique format.

Suivez-Nous:
LinkedinTwitter

Laisser un Commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

fr_FRFrench
Faire défiler vers le Haut