This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <Numer_detection_inferencing.h> | |
#include "ei_classifier_porting.h" | |
#include "pico/stdlib.h" | |
#include "ei_run_classifier.h" | |
#include "hardware/gpio.h" | |
#include "hardware/adc.h" | |
/* Private variables ------------------------------------------------------- */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import array | |
import micropython | |
import utime | |
from machine import Pin | |
from micropython import const | |
class InvalidChecksum(Exception): | |
pass | |
class InvalidPulseCount(Exception): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Python program to read temp and humidity data from serial port | |
#and to send them to a webpage | |
#DHT11 sensor is used | |
#Version 1.0.4 | |
import serial | |
import time | |
file_name = "index.html" | |
ser = serial.Serial('COM5', 112500, timeout=1) | |
print("Reading data from serial port....."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Python script to read serial port data and send them to UBIDOTS cloud | |
import time | |
import requests | |
import math | |
import random | |
import serial | |
TOKEN = "BBFF-ofWonfD405MScpxOFPtRVbQkhVSscz" # Put your TOKEN here | |
DEVICE_LABEL = "My_PC" # Put your device label here | |
VARIABLE_LABEL_1 = "temperature" # Put your first variable label here | |
VARIABLE_LABEL_2 = "humidity" # Put your second variable label here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Micropython implementation of Multi-layer Perceptron (MLP) | |
##Artificial Neural network-Fully connected Dense layer | |
##Trained hyperparameters are collected from tensorflow-keras | |
# and fed to our Neural network for testing and prediction | |
##Version:1.0.1 | |
##Date 14/06/2022 | |
def zeros1d(x): # 1d zero matrix | |
z = [0 for i in range(len(x))] | |
return z |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
from tensorflow import keras | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
pima = pd.read_csv("diabetes.csv") | |
pima.head() | |
#split dataset in features and target variable | |
feature_cols = ['Pregnancies', 'Glucose', 'BloodPressure', 'SkinThickness','Insulin','BMI','DiabetesPedigreeFunction', 'Age'] | |
Xraw = pima[feature_cols] # Features |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pylab import logistic_regression as lm | |
def csvread(file_name): # function for reading csv file | |
f = open(file_name, 'r') | |
w = [] | |
tmp = [] | |
for each in f: | |
w.append(each) | |
# print (each) | |
# print(w) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
col_names = ['pregnant', 'glucose', 'bp', 'skin', 'insulin', 'bmi', 'pedigree', 'age', 'label'] | |
# load dataset | |
pima = pd.read_csv("diabetes.csv") | |
pima.head() | |
#split dataset in features and target variable | |
feature_cols = ['Pregnancies', 'Glucose', 'BloodPressure', 'SkinThickness','Insulin','BMI','DiabetesPedigreeFunction', 'Age'] | |
Xraw = pima[feature_cols] # Features |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Logistic Regression in Raspberry Pi Pico-RP-2040 using Micropython | |
##Use small file size to avoid memory error | |
##Tested using only 100 row in the diabetes.csv file, check file name, make sure | |
#that 1st row (column header of csv file) is removed (string not supported) | |
from pylab import logistic_regression as lm | |
def csvread(file_name): # function for reading csv file | |
f = open(file_name, 'r') | |
w = [] | |
tmp = [] | |
for each in f: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# scratch code for logistic regression in Micropython | |
# Numpy-like matrix library from scratch | |
# Created on 7/6/2022 | |
# Note that, matrix must be two-dimensional | |
#Rev01: 7/6/22 | |
#Rev02:11/6/22 | |
def zeros(rows, cols): | |
""" | |
Creates a matrix filled with zeros. | |
:param rows: the number of rows the matrix should have |
NewerOlder