🍏

WEEK 14 - Interface and application programming

  • write an application that interfaces a user with an input &/or output device that you made.

👉 Group assignment:

  • compare as many tool options as possible.

👉🏼 Click here for group assignment page




Interface and Application ?

Interface is a point of interaction between two different systems, such as a user interface that allows a person to interact with a computer program, or an application programming interface (API) that allows one software program to interact with another. This week, we plan to create an application interface that will establish communication with one of our hardware boards, facilitating the exchange of data and interactions between the two systems.

Plan for this week !

During one of my previous IoT projects, I had attempted to explore Node-RED, but was unable to fully complete my exploration. However, for this assignment, I have decided to use Node-RED as my tool of choice.

I plan to establish an interface between a microcontroller and Node-RED, enabling the utilization of dashboard tools and widgets while also promoting ease of use and exploration.

Raspberry pi !

🔖
Raspberry Pi is a small, single-board computer designed to promote teaching of basic computer science in schools and developing countries. It was developed by the Raspberry Pi Foundation, a UK-based charity, and released in 2012. The computer is about the size of a credit card and includes all the basic components of a desktop computer, including a processor, RAM, graphics processing unit (GPU), and input/output ports. Raspberry Pi can run a variety of operating systems, including Linux, and is capable of performing many tasks, from basic word processing and web browsing to programming and multimedia processing. Due to its affordability and versatility, Raspberry Pi has become a popular tool for makers, hobbyists, and professionals in a wide range of fields, including robotics, home automation, and Internet of Things (IoT) applications.
Teach, learn, and make with the Raspberry Pi Foundation
We are a charity with the mission to enable young people to realise their full potential through the power of computing and digital technologies.
https://www.raspberrypi.org/

Hardware!

I had a Raspberry Pi Zero lying idle for some time, so I decided to repurpose it as a host for my Node-RED platform.

🔖
Raspberry Pi Zero is a small, affordable single-board computer developed by the Raspberry Pi Foundation. It was released in November 2015 and was designed to be the smallest and most affordable Raspberry Pi computer available at the time. The Raspberry Pi Zero has a Broadcom BCM2835 system-on-chip (SoC) with a single-core ARM11 processor clocked at 1 GHz, 512 MB of RAM, a microSD card slot for storage, a mini-HDMI port for video output, two micro-USB ports (one for power, one for data), and a 40-pin GPIO header. Due to its compact size and affordability, the Raspberry Pi Zero has become popular for a wide range of projects, from portable devices to Internet of Things (IoT) applications.

follow the link to learn more about raspberry pi .

Buy a Raspberry Pi Zero W – Raspberry Pi
The Raspberry Pi Zero W extends the Pi Zero family and comes with added wireless LAN and Bluetooth connectivity.
https://www.raspberrypi.com/products/raspberry-pi-zero-w/

Raspbian OS ? 😲

Raspbian is a free and open-source operating system (OS) designed specifically for the Raspberry Pi single-board computer. It is based on the popular Debian GNU/Linux operating system and is optimized for the ARM architecture used by the Raspberry Pi's processor.

We need to install Raspbian on our pi to make it possible to install node-red.

Follow the documentation to install Raspbian on any raspberry pi devices.

Raspberry Pi Documentation - Getting started
The official documentation for Raspberry Pi computers and microcontrollers
https://www.raspberrypi.com/documentation/computers/getting-started.html

Installing Rasbian on raspberry pi !

To install Raspbian OS, you will need to prepare an SD card and an SD card reader.

Follow the below link to download the raspberry pi imager software

Introducing Raspberry Pi Imager, our new imaging utility - Raspberry Pi
Flash Raspbian to your SD card with the Raspberry Pi Imager, our brand new imaging utility. Download it free today!
https://www.raspberrypi.com/news/raspberry-pi-imager-imaging-utility/
🔖
Raspberry Pi Imager is a free software tool designed to simplify the process of installing operating systems on a Raspberry Pi computer. It was developed by the Raspberry Pi Foundation and released in 2020.

Displayed below is the Raspberry Pi Imager interface running on a Windows computer. I have selected the 32-bit Raspberry Pi OS, which is the operating system I intend to install on my Raspberry Pi Zero.

To configure location and WiFi settings, click on the settings icon located towards the bottom of the screen. From there, you can set your preferred location and WiFi network. Additionally, I recommend ticking the SSH option for future remote use.

Click on the write image button to start writing the OS to the SD card .

writing OS image to the SD card

After successfully writing the image and verifying it, proceed to install the SD card on the Raspberry Pi zero, as shown in the picture.

No plug in a USB adapter with USB micro pin on the PWR IN connector of the pi as shown in the picture .

wait at least 2 minutes for the pi to boot

plugging the usb power

now pi should be connected to the network that was given while writing the OS .

Conform Connection

To Find whether pi is connected to the network we need to scan the network . I am using Fing on android to find the pi IP

🔖
What is fing? 🤔

"Fing" is a mobile app available on the Google Play Store and Apple App Store that allows users to scan and analyze their local network to discover connected devices and troubleshoot network issues

raspberry pi is listed on the network as “Raspberry” below that you can find the IP of the device .

If pi is not listed on the list refresh the list using refresh button on top right corner .

Signing in to raspberry pi on SSH

Download and install PuTTy software on your PC.

🔖
PuTTY is a free and open-source terminal emulator and network file transfer application for Windows. It supports several network protocols, including SSH, Telnet, rlogin, and SCP, allowing users to securely connect to and control remote systems over a network.

To download putty follow this link

Download PuTTY - a free SSH and telnet client for Windows
https://www.putty.org/

Type in the raspberry pi IP address Host name on putty with port 22 click OPEN .

If a security prompt is displayed click yes to continue

Next, you will be prompted to enter the user ID, which in this case is "pi". After entering the user ID, you will then be prompted to enter the associated password. After typing password press enter

If you see the above screen, it means you have successfully logged in to the Raspberry Pi using the command line interface (CLI).

Ok now time to set up the node red on pi.

Preparing raspberry pi

Type in the following code and press enter to update and upgrade raspberry pi to the lastest version.

sudo apt-get update && sudo apt-get upgrade -y

🔖
The sudo command allows a user to execute commands with administrative privileges. apt-get is a package manager for Debian-based systems that allows users to install, update, and remove software packages. The update command updates the local package index, which is a list of available packages and their versions.
🔖
The upgrade command then upgrades the installed packages to their latest versions, based on the updated package index. By running these two commands together, you can ensure that your Raspberry Pi is running the latest versions of the installed packages and is up to date with the latest security patches.

What is node red ?

🔖
Node-RED is an open-source visual programming tool designed for IoT (Internet of Things) applications. Node-RED allows users to easily connect hardware devices, APIs, and online services by creating "flows" using a web-based drag-and-drop interface. Each flow consists of a series of nodes that perform specific functions, such as sending or receiving data, processing data, or interacting with other services. Node-RED supports a wide range of hardware platforms, including Raspberry Pi, Arduino, and other microcontrollers.
Documentation : Node-RED
https://nodered.org/docs/

Installing and Configuring Node-RED on raspberry pi

Follow the below link to find documentation on how to install node red on raspberry pi.

Running on Raspberry Pi : Node-RED
https://nodered.org/docs/getting-started/raspberrypi

I combined all the command to form a single line command.

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install -y git && sudo git --version && yes | head -n 1 | bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

Copy paste the above code to install and configure node red .

👇🏼 If the above code does not work follow the bellow consolidated steps .

Following are the consolidated command steps to install node red which should be run on the ssh terminal.

1 sudo apt-get install -y git install git first

2 git --version check git version

3 bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) install node js and node red

After executing these commands, you will be prompted for permission to install Node-RED. To proceed with the installation, go with "yes" .

This will take a while to finish

The screen displayed above is what you will see after completing the setup.

4 node-red-pi --max-old-space-size=256 is a command that is used to start the Node-RED runtime on a Raspberry Pi device with a specific memory allocation.

Note: installation is complete

5 sudo systemctl enable nodered.service for autostarting node-red everytime raspberry pi reboots.

🔖
Refer - https://nodered.org/docs/getting-started/raspberrypi

Running as a service

The install script for the Pi also sets it up to run as a service. This means it can run in the background and be enabled to automatically start on boot.

The following commands are provided to work with the service:

  • node-red-start - this starts the Node-RED service and displays its log output. Pressing Ctrl-C or closing the window does not stop the service; it keeps running in the background
  • node-red-stop - this stops the Node-RED service
  • node-red-restart - this stops and restarts the Node-RED service
  • node-red-log - this displays the log output of the service

You can also start the Node-RED service on the Raspberry Pi OS Desktop by selecting the Menu -> Programming -> Node-RED menu option.

Configuring Node-Red settings

node-red admin init

run the settings wizard and add username and password.

Following are the setting that I gave

7 node-red-restart after applying all the settings restart node red

Opening Node-Red editor on your PC

When browsing from another machine you should use the hostname or IP-address of the Pi: http://<hostname>:1880.

You can find the IP address by running hostname -I on the Pi.

in my case its

http://192.168.xx.xx:1880

Type in the username and password and you will see the node red dashboard

Node-red

🔖
A thing about flows on Node-red-In Node-RED, flows refer to the visual representations of your application's functionality. A flow is a sequence of nodes that are connected together to perform a specific task.
🔖
A flow in Node-RED is defined by a set of interconnected nodes, each with its own input and output ports. Each node performs a specific function, such as reading data from a sensor, processing data, or sending data to a database. Nodes can be combined in a variety of ways to create complex application logic, and can be easily customized or extended using JavaScript or other programming languages.

Follow the below link to find more about node flows

Editor Guide : Node-RED
https://nodered.org/docs/user-guide/editor/

Dashboard

In node red we need to install dashboard widgets

Dashboard widgets in Node-RED refer to the various graphical elements that you can add to your application's user interface. These widgets are designed to display and interact with data that is generated by your application or external data sources.

To install dashboard

Click on the menu tab

Click on Manage palette

Click on install and search for dashboards

Click on node-red-dashboards and click install as shown in the above picture

When the above confirmation is prompted click on install

Nodes

Towards the left side of the dashboard one can see a list of nodes .

check whether dashboard nodes are available on the lists

  1. To use a node drag it from the node palette on the left-hand side of the screen to the workspace on the right-hand side.
  1. Once you have added the node to the workspace, you can configure its settings by double-clicking on it. This will open the node's properties panel, where you can set parameters and options for the node.

Connect the nodes together by dragging a connection line from the output of one node to the input of another.

Deploy the application by clicking on the "Deploy" button in the top-right corner of the screen. This will activate the nodes and start the application.

After confirming deploy the below shown msg will be displayed .

when you double click on any widget ( button for example ) you will get a properties tab add a group by clicking on the pencil icon next to group .

Click the Add button to add button to the dashboard .

If everything is fine then there wont be any warning signs above the widgets

Now click on the Deploy button to push the changes to dashboard

Dashboard

To view dashboard click on the below shown icon.

Following is the dashboard for the button that we made .

What is MQTT?

🔖
MQTT (Message Queuing Telemetry Transport) is a publish-subscribe messaging protocol that is commonly used in IoT (Internet of Things) applications. An MQTT server is a message broker that acts as a central hub for sending and receiving messages between IoT devices and applications. It provides a lightweight and efficient way to send and receive data over a network, making it well-suited for IoT applications where resources such as bandwidth, processing power, and memory are often limited. MQTT is designed to be flexible and can be used in a wide range of IoT applications, from industrial automation and monitoring to smart homes and wearable devices.

To install mqtt on raspberry use the following command .

sudo apt install mosquitto mosquitto-clients

😪 The lengthy series of challenges !

☹️ i had some errors when installing the mosquito server clients .

It seems i forgot to add the import the repository package.

After some digging I found mosquitto documentation follow the link to find the doc .

Mosquitto Debian repository
On a previous post I described how to make mosquitto debian packages. This turned out to be a bit problematic, so I've now put up an experimental debian repository for mosquitto. It includes packages
https://mosquitto.org/blog/2013/01/mosquitto-debian-repository/

wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key

sudo apt-key add mosquitto-repo.gpg.key

cd /etc/apt/sources.list.d/ Then make the repository available to apt

sudo wget http://repo.mosquitto.org/debian/mosquitto-bullseye.list

for other debian version use

sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list
        sudo wget http://repo.mosquitto.org/debian/mosquitto-stretch.list

sudo apt-cache search mosquitto

sudo apt-get install mosquitto

Still Not working

sudo apt autoremove

In the end, I restarted the system, which resolved the errors that were occurring.

Update the package list by running the following command:

👉🏼 sudo apt-get update

Install the mosquitto broker by running the following command:

👉🏼 sudo apt-get install mosquitto

Install the mosquitto client by running the following command:

👉🏼 sudo apt-get install mosquitto-clients

To check the working of server paste the following command

ps aux | grep mosquitto

well in my case the mosquito server failed to install ☹️

I kept of trying different approaches to install like changing mirrors of debian repository .etc

How to change the Repository Mirror on Raspbian
Pick the fastest repository mirror.
https://pimylifeup.com/raspbian-repository-mirror/

☹️ but nothing seemed to be working .

upon returning home and attempting the same installation process on my home network, everything worked smoothly. It appears that certain repositories may have been restricted access at our lab network .

😃 Finally back to being happy !

sudo apt install mosquitto mosquitto-clients

I used the same command at my home network and everything was back to normality .

successfully installed mosquito broker

It worked 🥳

mosquitto -v use the following command to confirm the latest version of mosquitto broker

New error

There is an error showing address already in use

I restarted the pi and the error got cleared .

ran ps aux | grep mosquitto

running perfectly “🤗

🔖
A little about ps aux | grep mosquitto is a command used to search for all running processes that contain the keyword "mosquitto" in their names.
  • ps stands for process status and displays information about running processes.
  • aux are command-line options that show all running processes for all users (a) in a detailed list (u) that includes the process owner and other information (x).
  • grep is a command-line utility used for searching a given input for a pattern, and here we use it to filter out the processes that have the word "mosquitto" in their names.

So the combined command ps aux | grep mosquitto is used to show all running processes that have "mosquitto" in their name.

MQTT publisher and subscriber

🔖
Mosquitto provides two main components: a publisher and a subscriber. The publisher is responsible for sending messages to the message broker, while the subscriber is responsible for receiving messages from the message broker. These messages are sent and received based on specific topics, which act as channels for communication.

First terminal paste

mosquitto_sub -v -t notebook/test

mosquitto_sub -v -t notebook/test is a command that subscribes to the MQTT topic notebook/test and prints the messages received from that topic to the console with verbose mode enabled.

Here's what each argument means:

  • mosquitto_sub: This is the command to start the Mosquitto subscriber client.
  • v: This enables verbose mode, which prints additional information about each received message, including the topic and message payload.
  • t notebook/test: This specifies the MQTT topic to which the client should subscribe. In this case, the topic is notebook/test.

So when you run this command, the subscriber w

Second terminal paste

mosquitto_pub -t notebook/test -m "12345"

mosquitto_pub -t notebook/test -m "12345" is a command that publishes the message "12345" to the MQTT topic notebook/test.

Here's what each argument means:

  • mosquitto_pub: This is the command to start the Mosquitto publisher client.
  • t notebook/test: This specifies the MQTT topic to which the message should be published. In this case, the topic is notebook/test.
  • m "12345": This specifies the message payload to be published. In this case, the payload is the string "12345".

So when you run this command, the publisher will connect to the MQTT broker and publish the message "12345" to the notebook/test topic. The message will be sent to the broker, and any subscribers that have subscribed to that topic will receive the message.

likewise I send mosquitto_pub -t notebook/test -m "hallo world" and mosquitto_pub -t notebook/test -m "mqtt is alive"

Time to add some layer of Security to Mqtt

After reviewing the information provided at https://mosquitto.org/man/mosquitto-conf-5.html, I have found all the essential directives for implementing security measures.

cd /etc/mosquitto/conf.d go to the mosquitto directory .

sudo nano mosquitto.conf make a file

port 1883
        password_file /etc/mosquitto/passwords.txt
        allow_anonymous false

after saving the file

come back to cd /etc/mosquitto ( by clinking cd .. )

sudo nano passwords.txt make a file passwords.txt

where esp8266:xxxxx is the client and xxxxx is the password .

we can have as many user name and passwords as we want.

to encrypt the file use the following command.

sudo mosquitto_passwd -U passwords.txt

  • sudo: This runs the command with administrative privileges.
  • mosquitto_passwd: This is the command to manage the Mosquitto password file.
  • U: This updates the password file specified in the argument.
  • passwords.txt: This is the name of the password file to be updated.

cat passwords.txt

you can see the username followed by encryption

MQTT publisher and subscriber with authentication

Subscriber

mosquitto_sub -u esp8266 -P ******** -v -t notebook/test

Publisher

mosquitto_pub -u esp8266 -P ******** -t notebook/test -m "hallow world"

follow “MQTT publisher and subscriber” above for reference .

we have successfully configured MQTT with authentication .

MQTT on Node RED

If you search the flows you can find mqtt nodes .

Input Node

Drag and drop an input node and a debug node , double click on the input node to show settings .

Click on the pencil icon to edit the node

Add name for the node “MQTTclient1” and on Server write localhost

On Security add the user name and password for nodered

Click on Add

Give Topic as fabacademy/test and change Qos to 0

Now click on the Debug messages on the right side of the tool bar .

What is a debug node ? The debug node in Node-RED is a tool that allows you to view and inspect the data that is flowing through your Node-RED flows. just like a Serial monitor on arduino IDE.

Now click on Deploy .

The input MQTT node failed to establish a connection. Although the connecting status is displayed, the connection itself does not appear to be established.

Fond the issue ( My mistake)

In the subsequent step, I mistakenly provided authorization for the Node-RED username and password instead of the credentials generated for MQTT.

After deploying you can see the status of the node as connected which means the node is connected and working .

Inputting to the Subscribed Node

Publishing was done on the terminal and we have the message delivered at the debug window from the subscribed node .

Output Node

In a similar manner, I utilized both the timestamp node and MQTT output node to transmit a timestamp message to the Putty terminal.

ESP32 input from Node-RED

Follow the library documentation .

https://github.com/plapointe6/EspMQTTClient

After opening the example simpleMQTTClient i changed the wifi SSID , wifi PASSWORD , MQTT username , MQTT password , IP address . then uploaded the same code to ESP32 board ( since our lab had only 1 esp8266 and it was already in use ).

On the node red side i used a subscribe ( mqtt out ) node to display the contents received from the esp32 board

Serial Monitor output of esp32 board

You can see the message from the esp32 board (This is a message) on the debug window

ESP32 Output to Dashboard

💡
What is OTA - The process of uploading data through OTA (Over-The-Air) involves wirelessly transferring information or files to a remote device or system. This convenient method eliminates the need for physical connections, enabling remote updates and modifications.

Uploading sketch to ESP32 Through OTA

Node appearance : Node-RED
https://nodered.org/docs/creating-nodes/appearance

You name to change both icon and colour

AS7341 (multispectral sensor)- ESP32 - Node-RED

🔖
What is AS7341 ? The AS7341 is a multispectral sensor developed by ams AG, a manufacturer of high-performance sensor solutions. The AS7341 sensor is capable of detecting and measuring light across a wide range of wavelengths, from ultraviolet (UV) to near-infrared (NIR). It integrates 11 spectral channels, each with a dedicated photodiode and a specific optical filter to capture light at different wavelengths. This allows for precise and simultaneous measurement of various spectral bands. Applications of the AS7341 sensor include color analysis, ambient light sensing, color identification, and spectral analysis in various industries such as automotive, lighting, agriculture, and consumer electronics. It provides a compact and efficient solution for capturing and analyzing spectral data in real-time.

The AS7341 sensor greatly interests me due to its capability for color analysis, making it an ideal fit for my primary objective of creating a personalized automated colorimeter for my hydroponics project.

🔖
What are colorimeters ?

pH colorimeters typically utilize colorimetric methods to assess the pH of a solution. These methods involve the use of indicators or reagents that change color in response to different pH levels. The color change is then quantitatively measured by the instrument, allowing for pH determination.

By utilizing this sensor, I envision accurate and precise measurements and analysis of the colors and pH levels of water within the hydroponic system. I hope this technology has the potential to eliminate the need for expensive probes traditionally used for such measurements.

AS7341 sensor
Sensor connected to ESP 32 via i2c pins

The sensor I had was an adafruit one .

Adafruit AS7341 10-Channel Light / Color Sensor Breakout
The Adafruit AS7341 10-Channel Light / Color Sensor Breakout is a multi-channel spectrometer, which is a special type of light sensor that is able to detect not only the amount of light ...
https://www.adafruit.com/product/4698

After installing libraries I found the example library ” basic count”

The serial monitor displayed float values from the uploaded code i was expecting values in nanometer .

I went through another example from adafruit which had outputs in nanometer range .

following is the example .

Adafruit AS7341 10-Channel Light / Color Sensor Breakout
A micro spectrometer that's easy to use
https://learn.adafruit.com/adafruit-as7341-10-channel-light-color-sensor-breakout/arduino
Serial output example in nanometer scale

I utilize client publish commands to send all the codes to Node-RED for output.

Please find the ESP32 codes on resource page

Back to Node Red

I wanted to output all the Spectrums on an interface so I added gauges (from the dashboard ui ) and added subscriber to it . now its time to edit the dashboard .

Click on the dashboard

Then click on the layout

In Node-RED, I arrange the gauges on the panel through a simple drag-and-drop process. This awesome Node-Red feature that allows me to easily position and organize the gauges according to my desired layout and visual presentation.

Editing The gauge Node

The AS7341_CHANNEL_415nm_F1 channel is a 16-bit value, which means its maximum value is 65535.

adjusting the max and min value on guage

Thanks to ChatGPT, I discovered the corresponding color of a specific nanometer range.

I carefully selected the appropriate color for each gauge based on the corresponding nanometer range. By matching the specific wavelength range to its corresponding color, I ensured that each gauge accurately represents the desired color for the given nanometer range.

Discovering Colors in Real Time 🔥 😎

Inspired by the vibrant and deep colors on some of my book covers, I decided to utilize them as a reference for color detection. 😄.

vivid book colour

Finally sensing Colors and displaying them on Node-Red via MQTT

That my hero shot 😊 ( sensing colors )

A small Node-Red to ESP32 example

Using the Switch UI on the dashboard, I toggled the onboard light of the ESP32 on and off.

Finally I think I learned a bit about Output and input on node red via mqtt .

Still the assignment is not complete until i do the same from My own board . Unfortunately I did not have any board with esp32 or WIFI modules on my previous assignments .

Making a circuit and PCB for my own esp8266 (Wroom 02 ) AS7341 sensor

Considering that the AS7341 sensor did not require the extensive capabilities of the ESP32, I opted to create a dedicated board for this task using the ESP8266 WROOM. The ESP8266 provided ample functionality for running the AS7341 sensor, making it a suitable and efficient choice for the assignment.

wroom 02 (esp8266)

Random nerds had the best documentation on esp8266 following is the link .

ESP8266 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials
The ESP8266 comes with 33 GPIOs with multiple functions. This article is a simple and easy to follow reference guide for the ESP8266 NodeMCU GPIOs.
https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/
Please note that not all pins of the ESP8266 can be utilized for various purposes 😥. To provide a clearer understanding, I would like to present a chart sourced from the Random Nerd Tutorials, which outlines the pin functions during programming and booting. This chart will help illustrate the specific capabilities and limitations of the pins on the ESP8266.
The pins highlighted in green are OK to use.

Auto program and reset 😕

In the context of the ESP8266, "auto program and reset" refers to a functionality that allows for automatic programming and resetting of the board. This feature simplifies the process of uploading new firmware or code onto the ESP8266 without the need for manual intervention which is done through switch .I wanted to implement the same feature on my board This feature is particularly convenient during development and testing phases, as it eliminates the need to manually press buttons or perform specific actions to initiate programming or reset operations on the ESP8266 board.

Following is a link in to how the auto program works on esp8266

ESP8266 – Auto Program & Reset - StudioPieters®
The upload procedure for ESP8266 boards is a little different from a standard Arduino procedure. Most Arduinos will automatically reset when a new program is being uploaded, and will automatically enter programming mode.
https://www.studiopieters.nl/esp8266-auto-program-reset/

I went through the Adfruit Huzzah board which had esp8266 ( click here for schematic ).

They have places 2 mmbt2222 transistor for auto program .

🔖
what i understood about auto programing ! .The basic concept of the transistor auto-program circuit is to control the voltage level of the GPIO0 pin. When the transistor is in an appropriate state , it can pull the GPIO0 pin to a low voltage or ground, triggering the ESP8266 to enter the programming mode. On the other hand, when the transistor is inactive or in a different state, it allows the GPIO0 pin to be pulled to a high voltage or left floating, enabling the ESP8266 to boot into its normal operational mode.

Due to a lack of surface-mount device (SMD) transistors in our inventory, I needed to adapt the circuit by replacing the transistor with a MOSFET.

During discussions with my instructor, Saheen, I learned that he had previously employed a similar circuit using a MOSFET for an ESP32. Consequently,

I decided to implement the same approach in my circuit.

esp8266 circuit
modified circuit

Rest of the circuit were of not much effort AS7341 is using i2c and I additionally added an led on gpio 2.

ON to PCB design

During my exploration, I discovered that the ESP8266 module has specific design restrictions for its footprint, particularly regarding the placement of traces or PCB in certain areas after digging through data sheet i found that It is generally recommended to avoid placing a printed circuit board (PCB) or any conductive material in close proximity to the antenna of an ESP8266 module. This is because the presence of conductive materials near the antenna can negatively impact the performance and efficiency of the wireless communication.

My initial attempt at design .

My final design .

And….. I exhausted my week 😭😭😭😭

Due to time constraints, I was unable to complete the milling or fabrication of my ESP8266 PCB before reaching my deadline for the week. However, I plan to revisit the project after my presentation to finalize the PCB. Additionally, I am considering implementing my project with an ESP32. I aim to return this week and provide the necessary documentation for integrating ESP32 and Node-RED into my project.

ESP32 - Node red implementation on my PROJECT ( Week 14 revisited )

Documentation on The Schematic , PCB and Fabrication is updated on my project page

Please find the documentation on the following link -

Rpi zero running node red (left) Hydroponics Project board (center) with pH sensor board (right green )

By utilizing the same codes and flows, I established a connection between the pH sensors and Node-RED through an ESP32. Subsequently, I placed the pH sensor into a beaker containing a pH7 buffer solution.

Readings shown on Node-Red guage

Conclusion

I realized that the values were constantly fluctuating, indicating the need for additional implementation of smoothing algorithms to stabilize the pH readings. My understanding is that what I accomplished on Node-RED is merely scratching the surface, and there is a great deal more to explore and experiment with as I continue working on my project.

😅
As the week drew to a close, I couldn't help but reflect on how it had been the longest and most eventful week throughout my Fab Academy journey.

Resources and Downloads 📩

📩 Arduino sketches ESP32-Light Spectrum and Simple MQTT
📩 ESP8266 PCB and schematic
📩 Node-Red flows export file