**1. Introduction**

In this demo, I will make a simple Machine Learning - Artificial neural network system using Arduino ESP32. Certainly, I will not use ESP32 for training process; instead, i will use Python + numpy for training process. After training, I will use the result weights will be used by ESP32 for output calculation based on input.

Artificial neural network (ANN) systems are inspired by the biological neural networks. These systems can learn to do tasks by considering examples, without task-specific programming.

**One of most famous methods for ANN training is Backpropagation. You can refer here.**

In this demo: ESP32 with 2 buttons (B1 and B2) with possible states: pressed (0) or released (1) and there is 1 LED output with possible state state on (1) or off (0). The LED output can be set based on the state of input.

B1 | B2 | LED |
---|---|---|

pressed | pressed | off |

pressed | released | on |

released | pressed | on |

released | released | off |

**Figure: state of LED based on state of buttons**

**Figure: ANN structure of demo**

**2. Hardware**

Here we set input pins as INPUT_PULLUP so the schematic is simple and we can re-use the schematic in Demo 21.

**Figure: hardware connections**

[ESP32 GIO12 - BUTTON 1 - GND]

[ESP32 GIO13 - BUTTON 2 - GND]

[ESP32 GIO14 - LED - GND]

**3. Software**

**3.1 ANN is implemented by Python + numpy**

I used the code here.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import numpy as np epochs = 10000 # Number of iterations inputLayerSize, hiddenLayerSize, outputLayerSize = 2, 3, 1 L = 0.1 # learning rate X = np.array([[0,0], [0,1], [1,0], [1,1]]) # Buttons states array Y = np.array([ [0], [1], [1], [0]]) # LED states array def sigmoid (x): return 1/(1 + np.exp(-x)) # activation function # weights on layer inputs Wh = np.random.uniform(size=(inputLayerSize, hiddenLayerSize)) Wz = np.random.uniform(size=(hiddenLayerSize,outputLayerSize)) for i in range(epochs): H = sigmoid(np.dot(X, Wh)) # calculate forward part Z = np.dot(H,Wz) # E = Y - Z # calculate error dZ = E * L # delta Z Wz += H.T.dot(dZ) # calculate backpropagation part dH = dZ.dot(Wz.T) * sigmoid_deriv(H) # Wh += X.T.dot(dH) # update hidden layer weights print("**************** error ****************") print(E) print("***************** output **************") print(Z) print("*************** weights ***************") print("input to hidden layer weights: ") print(Wh) print("hidden to output layer weights: ") print(Wz) |

**Figure: training process and weights output**

**3.2 Arduino ESP32**

The Arduino code just do the forward part to calculate the output when getting the inputs.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #include <math.h> #define B1 12 #define B2 13 #define LED 14 int X[1][2] = {{1,0}}; /*these matrices was calculated by python */ float W1[2][3] = {{0.74000854, 4.47769531, -0.98692059}, {0.83034991, 4.48772758, -0.55733578}}; float W2[3][1] = {{-6.17234487}, {4.8835918}, {1.28875386}}; float Wo1[1][3]; float sum = 0; float Y = 0; /*sigmoid function*/ float sigmoid (float x) { return 1/(1 + exp(-x)); } void setup() { Serial.begin(115200); pinMode(B1, INPUT_PULLUP); pinMode(B2, INPUT_PULLUP); pinMode(LED, OUTPUT); digitalWrite(LED, LOW); } void loop() { X[0][0] = digitalRead(B1); X[0][1] = digitalRead(B2); printf("B1 = %d, B2 = %d\n", X[0][0], X[0][1]); /* calculate forward part based on weights */ //hidden layer for(int i=0; i<1; i++) { for(int j=0;j <3; j++) { for(int k=0; k<2; k++) { sum += X[i][k]*W1[k][j]; } Wo1[i][j] = sigmoid(sum); sum = 0; } } //output layer for(int i=0; i<1; i++) { for(int j=0;j <1; j++) { for(int k=0; k<3; k++) { Y += Wo1[i][k]*W2[k][j]; } } } printf("Y = %f\n", (Y)); Y = round(Y); digitalWrite(LED, int(Y)); Y = 0; delay(1000); } |

**4. Result**

## 157 Comments

def sigmoid_deriv(x):

f = sigmoid(x)

return f * (1 - f)

source : https://stackoverflow.com/questions/10626134/derivative-of-sigmoid

Great post.

Very helpfull to start experiments.

Lot of your other posts are also well done.

Thx.

this is feed forward part so you will not see derivative.

I am wrtting new blog about machine learning.

It is http://www.fossreview.com/

Hope you like it :)

Regards

ccna Training in Chennai

ccna Training institute in Chennai

Python Training in Chennai

Python Classes in Chennai

Angularjs Training in Chennai

ccna Training in Velachery

ccna Training in Tambaram

Unix Training in Chennai

Unix shell scripting Training in Chennai

Tableau Training in Chennai

Excel Training in Chennai

Corporate Training in Chennai

Oracle Training in Chennai

Power BI Training in Chennai

Unix Training in Chennai

Unix shell scripting Training in Chennai

ExcelR data analytics course in Pune | business analytics course | data scientist course in Pune

data scientist course in mumbai

ExcelR data science

Data Science course in Hyderabad

ExcelR data science training

ExcelR PMP Certification

ExcelR data analytics courses

Data Mining Projects

Python Training in Chennai

Project Centers in Chennai

Python Training in Chennai

Data Science Course

Data Science Course in Marathahalli

Business Analytics CourseData Science Interview QuestionsData science Interview Questions

Data Science Course

wonderful blog,These type of blog keeps the users interest in

the website, i am impressed. thank you.

machine learning course in hyderabad

Best Data Science training in Mumbai

Data Science training in Mumbai

data analytics course in Bangalore

Artificial Intelligence Coursedata analytics course in Bangalore

SAP training in Mumbai

Best SAP training in Mumbai

SAP training institute Mumbai

SAP training in Kolkata

Best SAP training in Kolkata

SAP training institute in Kolkata

Correlation vs Covariance

Correlation vs Covariance

Simple linear regression

SAP training in Kolkata

SAP training Kolkata

Best SAP training in Kolkata

SAP course in Kolkata

SAP training institute Kolkata

Data Science In Banglore With Placements

Data Science Course In Bangalore

Data Science Training In Bangalore

Best Data Science Courses In Bangalore

Data Science Institute In Bangalore

Thank you..

data science course in coimbatore

Correlation vs Covariance

Simple linear regression

Correlation vs Covariance

Simple linear regression

data science interview questions

Projects assist you with improving your applied ML skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include projects into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Final Year Project Centers in Chennai even arrange a more significant compensation.

Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account.

Correlation vs Covariance

Simple linear regression

data science interview questions

Robotic Process Automation (RPA) Training in Chennai | Robotic Process Automation (RPA) Training in anna nagar | Robotic Process Automation (RPA) Training in omr | Robotic Process Automation (RPA) Training in porur | Robotic Process Automation (RPA) Training in tambaram | Robotic Process Automation (RPA) Training in velachery

Data Science Course in Hyderabad

Correlation vs Covariance

Simple linear regression

data science interview questions

Data Analyst Course

Course in Data AnalyticsData Analyst CourseSimple Linear Regression

Correlation vs covariance

data science interview questions

KNN Algorithm

Simple Linear Regression

Correlation vs covariance

data science interview questions

KNN Algorithm

Logistic Regression explained

The-interface is the perfect solution for SAP training. Interface is one of best SAP training in Kolkata, India. We are providing very prompt and world-class SAP training, SAP training in Kolkata. It is also a renowned SAP training institute in Kolkata.

The Interface is a unique SAP institute in Kolkata, and a SAP training center in Kolkata. It also gives best guidance on SAP through online training and thus,

it is considered as the Best SAP training in Kolkata.You can here directly contact the institute for SAP training in Kolkata and for any information. So keep visiting our websites to get update on regular basis.

Data Science training in Mumbai

Data Science course in Mumbai

SAP training in Mumbai

Simple Linear Regression

Correlation vs covariance

data science interview questions

KNN Algorithm

Logistic Regression explained

<a href="https://www.excelr.com/business-analytics-training-in-pune/”> Courses in Business Analytics </a>

I am always searching online for articles that can help me. There is obviously a lot to know about this. I think you made some good points in Features also. Keep working, great job !

Its as if you had a great grasp on the subject matter, but you forgot to include your readers. Perhaps you should think about this from more than one angle.

data science course

Correlation vs Covariance

Simple Linear Regression

data science interview questions

KNN Algorithm

Logistic Regression explained

Data Science Training BangaloreBusiness Analytics CourseSimple Linear Regression

Correlation vs covariance

data science interview questions

KNN Algorithm

Logistic Regression explained

Logistic Regression explained

Correlation vs Covariance

Simple Linear Regression

data science interview questions

KNN Algorithm

graphic design courses in tambaram

graphic design courses in Porur

Artificial Intelligence Course in Tambaram

Artificial Intelligence Course in Velachery

Artificial Intelligence Course in porur

how to convert list to string in python

data structures using python

polymorphism in oops

numpy in python

python interview questions and answers for testers

convert string to list python

common seo mistakes

artificial intelligence future scope

angularjs charts

benefits of automation testing

benefits of automation

angularjs interview questions and answers pdf

artificial intelligence advantages

application of asp net

definition of hadoop

devops tools java

selenium interview questions and answers pdf

selenium webdriver interview questions and answers

Join 360digiTMG for the best courses

data science training in Pune

thanks for giving that type of information. I am really happy to visit your blog.Leading Solar company in Andhra Pradesh

how to improve testing skills

about banking process

languages for data science

what is php used for in web development

digital marketing interview questions and answers for freshers

hadoop interview questions and answers pdf

Nice Blog. Thanks for Sharing this useful information...

Data science training in chennai

Data science course in chennai

Data Science Course in Raipur

Data science course in Faridabadvé máy bay vietjet từ hàn quốc về việt nam

vé máy bay hà nội sài gòn tháng 4

mua vé máy bay đi hà nội giá rẻ

giá vé máy bay đi cam ranh

gia ve may bay di my

Data Analytics Courses in Bangalore

Data Science Course in Pune

data scientist course in Bangalore

Data Science Course in India

data science institute in bangalore

https://socialprachar.com/

Artificial Intelligence Training and Course in Hyderabad

data scientist training and placement

data scientist course in hyderabad

Visit us @

Data Science Training in Pune

Python Classes in Pune

Data Science Course in Varanasi

ai training in hyderabad

Data Science Training in Bhilai

Data Science Course in Bhilai

data analytics courses in hyderabad

Psg grant Singapore

Peppol Invoicenow Singapore

Sage UBS accounting singapore

sattamatka

satta matka

data science training in faridabad

AI Patasala Data Science Training

data science training institute in hyderabad

data science course in trivandrum

Continue posting. A debt of gratitude is in order for sharing.

data science course in kolhapur

data analytics course in jamshedpur

data science training in delhi

An obligation of appreciation is all together for sharing.data analytics course in gwalior

Continue posting. A debt of gratitude is in order for sharing.

data scientist course in warangal

data science training in faridabad

data science training in pondicherry

data science training in gorakhpur

business analytics course in lucknow

data science course in lucknow

data science course in borivali

data analytics course in borivali

Data Science Course in Bangalore

Data Science in Bangalore

Data Science Course in Bangalore with Placement

Best Data Science Training institute in Bangalore

data science training in lucknow

Data Science Course in Delhi

Data Scientist Course in Delhi

data science training in lucknow

<a href="https://360digitmg.com/india/data-analytics-certification-training-course-in-patna>data analytics course in patna</a>

Data Science Course in Bangalore with Placement

Data Science Course in Jaipur

Business Analytics Course in Jodhpur

Spousal Support Calculator

Spousal Support Virginia