Jump to content
Electronics-Lab.com Community

Search the Community

Showing results for tags 'nodemcu'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Electronics Forums
    • Projects Q/A
    • Datasheet/Parts requests
    • Electronic Projects Design/Ideas
    • Power Electronics
    • Service Manuals
    • Theory articles
    • Electronics chit chat
    • Microelectronics
    • Electronic Resources
  • Related to Electronics
    • Spice Simulation - PCB design
    • Inventive/New Ideas
    • Mechanical constructions/Hardware
    • Sell/Buy electronics - Job offer/requests
    • Components trade
    • High Voltage Stuff
    • Electronic Gadgets
  • General
    • Announcements
    • Feedback/Comments
    • General
  • Salvage Area

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Yahoo


Skype


Location


Interests

Found 8 results

  1. Destiny Internet Ghost - Internet Notifier The Internet has changed the way we live our lives. From communication, education, banking, entertainment and shopping, the Internet has had a profound impact on our world. Gone are the days when the pen was the most important tool in this world. times have changed and now the internet rules the world. It is very difficult to imagine our world without the Internet. In the year 2021 I created a "Internet Hardware WatchDog" using NodeMCU which reboots my home router whenever there is an issue with the Internet. This device sits next to my router and happily takes care of it whenever it has a hiccup. This year, I wanted to extend the watchdogs horizon by adding an "Internet Status Notifier" that displays the current status of the Internet using an RGB LED. When the Internet is up and running, the notifier displays a blue light and when the Internet is down it goes red. Video: https://youtu.be/mWDEx0khpWM Note: If you do any work with "mains power" such as 120v or 240v AC power wiring, you should always use proper equipment and safety gears and determine whether you have adequate skill and experience or consult a Licensed Electrician. This project is not intended for use by children. Awards Video Featured on Instructables Components Required For this project we need: 1 x RGB LED 1 x 200 Ohm Resistor 1 x WeMos-D1 Mini/NodeMCU 1 x 220V to 5V Step Down Converter 1 X 2M Long Power Chord 1 x 220v Male Wall Plug, and 1 x 3D Printer Circuit Diagram The circuit is very simple. Connect the 5V pin and the GND pin of the D1-mini to the stepdown converter. Then, connect the Common Anode of the RGB LED via a 220ohm resistor to the 3.3V pin of the D1-mini. Then connect the Blue LEDs to D6, Red to D7 and Green to D8 pin of the board. That's it as simple as that. The Logic When the device is turned on it starts pinging "www.google.com". If it receives a successful ping, the Blue LED turns on and starts fading in and out. If the ping drops, the blue LED turns off and the Red LED turns on and starts fading in and out until a successful ping is received. After running the code on a breadboard for a few days, I figured out that the D1-mini board sometimes freezes and completely becomes unresponsive. To avoid this situation, I added a logic to "reboot" the board every hour. 3D Model While browsing the Internet, I stumbled upon "Destiny Ghosts". The Ghost is an AI companion in the game "Destiny". It is a floating intelligence that was created by the "Traveler" during his dying days to assist the Guardians to protect the Universe. I immediately fell in love with the concept and the design of the Ghosts. I spent a few days creating my own 3D model of the Ghost. You can download the STL files from www.cults3D.com. 3D Printing Ghosts are floating machine entities slightly larger than a human hand. They consist of a spherical core with a single glowing "eye" surrounded by a "shell". The default Ghost shell consists of eight roughly tetrahedral white segments with orange highlights, but there are huge diversities of shells available that Ghosts can adopt for cosmetic purposes. In the game Ghosts are used for navigation, accessing computer systems, lighting dark areas, summoning your Sparrow, and much more. 3D Printing is a highly addictive hobby! There are so many things you can do using a 3D printer. From designing 3D Models to printing them using the 3D printer has now become my new hobby. I've been a "maker" since I was 10 years old, and have always constructed and made my own stuff. 3D printing for me is a blessing. I am totally lost in the 3D printing heaven. 3D printing has changed my electronics workshop life forever. Before when I used to order parts, I always used to wonder if the parts would fit into my project's resources... but after I got my 3D printer... it doesn't matter at all, because if it doesn't fit - I could design and print it myself. The 3D printer was definitely "The Missing Piece" from my electronics workshop. Coloring Using Acrylic Colors, I painted the body of the Ghost. After that, I super glued the orange highlights to the tetrahedral white segments. Next, I super glued the front eye and the back lid to the body of the Ghost. After that, I super glued the stand to the back bit of the Ghost. This stand will keep the unit straight when you place it on your desk. Adding Electronics Since the circuit is very simple, I did not design a PCB for this. I just went ahead and soldered the D1-Mini and all other components to a general purpose perf-board. At the top bit, I soldered the D1-Mini and the RGB LED and at the bottom bit, I soldered the 200v-to-5v step-down converter and the 220ohm resistor. Next, after soldering the 2M long power-cord, I hot glued the perf-board to the back bit of the unit. The Code The code starts by including all the necessary libraries. Then it defines all the variables needed for setting up the WiFi connection. Next, it defines the LED Pins followed by the list of all the global variables used in the code. In the setup() section, I first defined all the pin modes followed by setting up the Wi-Fi connection. I assigned a static IP address to the D1-mini board. If you want to use DHCP then go ahead and delete these three lines from your code. void setup() { Serial.begin(9600); /** Define the pin modes **/ pinMode(LED_RED, OUTPUT); analogWrite(LED_RED, 1023); pinMode(LED_BLUE, OUTPUT); analogWrite(LED_BLUE, 1023); pinMode(LED_GREEN, OUTPUT); digitalWrite(LED_GREEN, HIGH); /** We start by connecting to a WiFi network **/ IPAddress local_IP(192, 168, 0, 240); // Static IP Address for ESP8266 IPAddress subnet(255, 255, 255, 0); // Subnet Mask IPAddress gateway(192, 168, 0, 1); // Default Gateway /*********** Setup a WiFi connection ***********/ Serial.println(); if (WiFi.config(local_IP, gateway, subnet)) { Serial.println("Static IP Configured"); } else { Serial.println("Static IP Configuration Failed"); }; WiFi.mode(WIFI_STA); WiFi.begin(WIFI_SSID, WIFI_PWD); Serial.println("Connecting to WiFi"); while (WiFi.status() != WL_CONNECTED) { delay(300); Serial.print("."); switch(ctr){ // Green LED Flashes On Boot case 0: digitalWrite(LED_GREEN, HIGH); ctr=1; break; case 1: digitalWrite(LED_GREEN, LOW); ctr=0; break; }; }; Serial.println("\nWiFi connected"); Serial.print("IP address: "); Serial.println(WiFi.localIP()); digitalWrite(LED_GREEN, HIGH); // Turn off the Green LED }; Next in the loop() section, I am pinging 8.8.8.8 or Google.com and if I receive a successful ping I am fading in and out the Blue LED. If the ping fails the Red LED faded in and out. void loop() { if (pingTest()) BrightnessController("BLUE"); // If a successful ping is received else BrightnessController("RED"); // If the ping fails turn on the red LED if (millis() >= 3600000) ESP.reset(); // Reboot the WEMOS D1 Mini Every Hour = 3600000 milliseconds }; Both BrightnessController() and pingTest() functions are defined in the bottom section of the code. Then, to avoid the D1-mini from freezing and becoming unresponsive, I am using the ESP.reset() function to reset the device every hour. Demo On A Breadboard Before adding the electronic bits to the 3D printed bits, I did a quick test on a Breadboard to make sure everything works as expected. As you can see, when I turn on the circuit the Green LED starts flashing. As soon as a connection is established with the router the device starts pinging 8.8.8.8. Initially, few of the pings fail and the Red LED lights up. As soon as a successful ping is received the Blue LED starts fading in and out. Bingo! Job done... Final Demo So, this is how my final setup looks like. Powering on the unit makes the green LED flash until it establishes a connection with the router. After that, the Blue LED starts fading in and out advising us that the unit has received successful ping from www.Google.com. You can install this unit anywhere in your house and use it as an "Internet Status Notifier". Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Video: View Full Blog Post: View References GitHub: View Stl Files: Download Internet Hardware WatchDog Using NodeMCU: View Support My Work BTC: 1Hrr83W2zu2hmDcmYqZMhgPQ71oLj5b7v5 LTC: LPh69qxUqaHKYuFPJVJsNQjpBHWK7hZ9TZ DOGE: DEU2Wz3TK95119HMNZv2kpU7PkWbGNs9K3 ETH: 0xD64fb51C74E0206cB6702aB922C765c68B97dCD4 BAT: 0x9D9E77cA360b53cD89cc01dC37A5314C0113FFc3 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 COS: bnb136ns6lfw4zs5hg4n85vdthaad7hq5m4gtkgf23 Memo: 572187879 BNB: 0xD64fb51C74E0206cB6702aB922C765c68B97dCD4 MATIC: 0xD64fb51C74E0206cB6702aB922C765c68B97dCD4 Thanks, ca again in my next tutorial.
  2. Had some time this weekend and a desire to create something new and interesting, so went ahead and created an Arduino/NodeMCU based indoor dial thermometer. This device displays the temperature in degree centigrade on a D-Shaped Gauge as well as on a 7-Segment display. In addition to that, it also saves the temperature and humidity readings in a MySQL DataBase hosted on a home based Raspberry Pi Server. The data is then displayed using the "Our Smart Home" app. Awards This project got featured on Cults3D and Instructables https://cults3d.com/en/3d-model/gadget/arduino-based-indoor-dial-thermometer https://www.instructables.com/NodeMCU-Based-3D-Printed-Indoor-Gauge-Thermometer/ Components Required For this project we need: 2 x TM1637 Display Modules 1 x DHT22 or DHT11 Module 1 x NodeMCU Microcontroller 1 x 28BYJ-48 Stepper Motor with ULN2003 Driver Board 1 x 10K Resistor A 3D Printer Copper Wire and Some Nuts & Bolts Circuit Diagram The circuit is very simple. Connect the ULN2003 driver board’s IN1, IN2, IN3 and IN4 to the NodeMCUs digital pins D0, D1, D2 and D3. Then connect the OUT Pin of the DHT22 to the D5 Pin of NodeMCU. After that connect the 2 x Display Modules to the microcontroller. We are going to use a Common Clock Pin D4 for both modules. Then connect the DIO of one of the modules to D6 (TEMP) and the other one to D7 (HUM) pins on the NodeMCU. Important: Please avoid using the boot config pins D3, D4, D8 and the RTC pin D0 for the displays. Now, on the D8 Pin we are going to connect the switch. This switch has a very important role in this circuit. This switch acts as the 'home' or the 'starting point' of the stepper motor. When the switch is open Pin D8 is connected to GND through the pull-down resistor and we read a LOW. When the switch is closed, Pin D8 connects to 3.3v pin of NodeMCU and we read a HIGH. When the 'temperature changes' or the 'device boots up', the pointer starts moving 'counterclockwise'. As soon as the pointer hits the home position, Pin D8 reads HIGH and the logic moves the pointer 'clockwise' to display the temperature on the gauge as read by the DHT22 module. The Code The code starts by including all the necessary libraries. Then it defines all the variables needed for setting up the WiFi connection. Next, it assigns a static IP address to the ESP8266 (if you want to use DHCP then go ahead and delete these three lines from the code). After that, it sets up the 2 x URLs that are needed for updating the heartbeat, temperature and humidity. String URLUpdateStatus = "http://192.168.0.7/Arduino/Weather/UpdateStatus.php"; String URLUpdateTemp = "http://192.168.0.7/Arduino/Weather/UpdateTemperature.php"; Before going ahead let's have a quick look at the 2 php files. The "UpdateStutus.php" file uses an UPDATE query to update the timestamp of the device sending the request to the current epoch time and hence updating the heartbeat. <?PHP try { $Token = $_GET["Token"]; $Location = $_GET["Location"]; include "ConnectionStringArduino.php"; // Create connection $sql = 'Update `Status` SET `DateTime`=\''.time().'\',`State`=\'1\' WHERE `Device`=\''.$Location.'\' AND `Token` = \''.$Token.'\';'; $result = $con->query( $sql ); if($result === FALSE) { die(mysqli_error());} mysqli_close($con); } catch (Exception $e) {} ?> The "UpdateTemperature.php" uses an INSERT query to add a new row to the database with the current values of Temperature and Humidity. <?PHP try { $Location = $_GET["Location"]; $TEMP = $_GET["TEMP"]; $HUM = $_GET["HUM"]; include "ConnectionStringArduino.php"; // Create connection $sql = "INSERT INTO `Weather` (`DateTime`,`Temperature`,`Humidity`,`Location`) VALUES ('".time()."','".$TEMP."','".$HUM."','".$Location."');"; $result = $con->query( $sql ); if($result === FALSE) { die(mysqli_error());} mysqli_close($con); } catch (Exception $e) {} ?> This is what is written to the database and can be displayed using Google Charts, in my case, I am using the "Our Smart Home" app to display the data using php and JavaScript. Currently I am only displaying the data from the Study room and the Peg Box. To know more about my award winning "Peg Box" project please have a look at my electronics tutorial no. 34 "Peg Box with Temperature and Humidity Monitor using NodeMCU" (https://youtu.be/elH331NXPsU). After that, I am defining all the variables required for reading and storing the value of temperature and humidity. Next, I am defining all the variables and setting up any additional symbols required for displaying temperature and humidity on the TM1637 Display Module. After that, I am defining the D8 pin of the NodeMCU as the reset switch pin. We will talk about this in detail in the following sections. Next, I am setting up the Steps Per Revolution of the stepper motor as 2038 and then initializing the stepper library through pins D0 to D3. const int stepsPerRevolution = 2038; // Change this to fit the number of steps per revolution of your motor Stepper myStepper(stepsPerRevolution, D0, D2, D1, D3);// Initialize the stepper library on pins D0 through D3 One thing to note: since I need both clockwise and counterclockwise movements, I have to initialize the pins in the order shown on screen. Then in the setup() section, first I am setting up the WiFi connection and then sending a heartbeat to the server. Then I am setting up the brightness of the 7-Segments to their max values followed by starting the dht module and finally setting the pin-mode of the switch to INPUT. void setup() { Serial.begin(115200); // Initialize the serial port /*********** Setup a WiFi connection ***********/ if (WiFi.config(local_IP, gateway, subnet)) { Serial.println("Static IP Configured"); } else { Serial.println("Static IP Configuration Failed"); }; WiFi.mode(WIFI_STA); WiFi.begin(WIFI_SSID, WIFI_PWD); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }; Serial.println("\nWiFi connected"); Serial.print("IP address: "); Serial.println(WiFi.localIP()); SendIamAlive(); // Send the initial wakeup message to the server /**********************************************/ display_TMP.setBrightness(7); // Set the display brightness (0-7) display_HUM.setBrightness(7); // Set the display brightness (0-7) dht.begin(); // Setup the DHT sensor pinMode(SWITCH, INPUT); // Declare the switch pin as input }; Now, in the loop() section I am reading the temperature using the Read_Temp() function and then sending the Temperature and Humidity values every 30 minutes and heartbeat every minute to the home server. void loop() { /** Read the temp and humidity info from ther sensor and display it on the 7-segmnet and Gauge **/ Read_Temp(); /** Sending Humidity and temperature every 30 minutes **/ if((millis() - lastTime) > timerDelay){ Serial.println("Sending Temp and Humidity");SendTemperatureAndHumidity(); lastTime = millis(); }; /** Sending I am alive message every minute **/ if((millis() - StatusCounter) > 60000){ Serial.println("Sending Heartbeat"); SendIamAlive(); StatusCounter = millis(); }; }; Next, you see the definition of the SendIamAlive() and SendTemperatureAndHumidity() functions which utilizes the WiFiConnect() function to send the values using the previously discussed URLs. The Read_Temp() function reads the temperature and humidity and updates the 7-Segment displays and moves the pointer only if there is a change in the values. The Move_Needle() function first sends the pointer to the home position using the Return_Home() function and then looks through and moves the pointer to the correct position until the stepCout is = STEPS. The value of STEPS is calculated based on the "stepsPerRevolution" which we previously set it up as 2038. So, 2038 / 2 (for half circle) = 1019 Now by dividing 1019 by 180 degrees we get the steps required to display each degree centigrade. Now to display each degree centigrade we need 180/60 = 3 divisions. Since our gauge starts from -10 and not 0 we also have to add the first 10 blocks which is (5.661 * 10 * 3) to our calculation. int STEPS = (5.661 * 3 * TEMP) + 169.833; // 5.661 (step resolution) * 3 (steps to display each °C) * TEMP + 169.833 (5.661 * 10 * 3) = since it starts from -10 and not 0) That's it as easy as that. 3D Designing Lets have a quick look at the 3D model of the project. At the front, we have The Pointer, D-Shaped Dial, and the Temperature Scale on the dial. Down at the bottom we have the Enclosure that will house the microcontroller and all other electronics components in it. The enclosure has a Lid to keep the electronic components safe and sound. At the back, we have a pocket to hold the DHT22 Module, 3 x holes for the stepper motor, 2 x groves for the TM1637 Display Module and 2 x L-Shaped Brackets to hold the top Dial to the bottom Enclosure. 3D Printing Once the 3D models were sorted, it was time for me to fire up my 3D printing oven and start printing these 3D models. I used: - 1.75mm Cold White PLA Filament, and printed the models with - 0.2mm - with 0% infill - and with support. As we all know, 3D printing is the process that uses computer-aided design or CAD, to create objects layer by layer. 3D printing is not a new technology, it's been there since the 1980's, when Charles W. Hull invented the process and created the first 3D-printed part. Since then, the field of 3D printing has grown exponentially and holds countless possibilities. The 3D printing process fascinates me a lot and I sometimes love to sit near my printer and watch these layers getting printed. The entire printing process took a little over 5 hours to complete and this is the final result. Alright now, let's start gluing all the printed parts. I first superglued the L-Shaped Brackets to the dial followed by the pocket that will hold the DHT22 module. Then, I went ahead and screwed the bottom enclosure to the top section via the L-Shaped Brackets. Breadboard Demo Before adding the electronic bits to the 3D printed bits, let's do a quick test to make sure everything works as expected. So, this 7-Segment display is displaying the temperature and the other one is displaying the humidity. The needle is currently going round and round in circles as it has no idea where to stop. To stop the needle, and to send it the correct position on the gauge, I need to connect this red jumper cable connected to 3.3v to the D8 Pin of the NodeMCU. Once I short the cable, the needle changes its direction and moves clockwise to display the temperature value read from the DHT22 module. The temperature and humidity values are also sent to the 'Home Server' which are then displayed using the "Our Smart Home" app. Coloring Using Acrylic colors, I painted all the 3D printed parts of the project. Assembling Once the coloring is done, its now time for me to put all the electronic components together. First I screwed the stepper motor to the back of the dial. Then, I gently pushed the DHT22 Module into its pocket at the back of the dial. Now the interesting bit. As per our previous discussion, we are going to use a copper wire as a switch that will move the pointer to its correct position. The copper wire will be fed through these two holes from the back and will loop through this small pipe like structure in the front. A small cut will be made on the top exposed side of the copper wire. Now on the pointer, we need to add a small piece of copper wire. When this copper bit touches the two copper wires on the pipe, it will complete the circuit and will send a HIGH to the system. Next, I am hot gluing the two TM1637 7-Segment Display Modules to the back of the dial. Once done, it's pretty much just a matter of soldering all the sensors to the NodeMCU as per our circuit diagram. Final Demo So, this is how my final setup looks like. Once the device is turned on, the pointer moves counterclockwise until it touches the copper wires that acts like a switch. Upon touching the wires the pointer moves clockwise to display the temperature value read from the DHT22 module on the D-Shaped Gauge. The temperature and humidity values are also displayed using 7-Segment Displays. The values are also sent over WiFi to a Raspberry Pi Home Server and stored in a MySQL database. Using google charts, you can display the data using various different graph options. In my case, I am using the "Our Smart Home" app to display the data using php and JavaScript. Thanks for watching, please comment and let me know if there are any scopes of improvement. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Video: Watch Full Blog Post: Visit Thermometer STLs: Download Peg Box: Watch How To Wire A Pushbutton: View Stepper Motor Specs: View Support My Work BTC: 1Hrr83W2zu2hmDcmYqZMhgPQ71oLj5b7v5 LTC: LPh69qxUqaHKYuFPJVJsNQjpBHWK7hZ9TZ DOGE: DEU2Wz3TK95119HMNZv2kpU7PkWbGNs9K3 ETH: 0xD64fb51C74E0206cB6702aB922C765c68B97dCD4 BAT: 0x9D9E77cA360b53cD89cc01dC37A5314C0113FFc3 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 COS: bnb136ns6lfw4zs5hg4n85vdthaad7hq5m4gtkgf23 Memo: 572187879 BNB: 0xD64fb51C74E0206cB6702aB922C765c68B97dCD4 MATIC: 0xD64fb51C74E0206cB6702aB922C765c68B97dCD4 Thanks, ca gain in my next tutorial.
  3. In my last tutorial I created a Weather Station using Arduino and NodeMCU using DHT11 or DHT22 temperature and humidity sensor and displayed it using an OLED Display. In this tutorial, I am going create a Peg-Box using the same board but with a little bit of twist. In this setup, I am going to send the Temperature and Humidity readings to my Raspberry Pi based home server and store it in a MySQL database. The data can then be viewed using PHP and Google Charts, on a Mobile Phone or a PC connected to the home network. Circuit Diagram The setup is very simple. The temperature and humidity sensor sends the collected data to the NodeMCU on pin D3. NodeMCU then sends the data over WiFi to the Raspberry Pi, which is then saved in the MySQL database. The Yellow LED, which is the status indicator flashes every second and is connected to D6 pin of the NodeMCU. The Blue LED connected to pin D5, lights up when NodeMCU sends the temperature and humidity readings to the database. If you are planning to install this box somewhere inside the house, then you can also add an OLED display and display the readings on it. The Board So, this is how my board looks like in 2d and 3d. There are 3 breakout boards in this 100cm x 100cm assembly. Each board can be used with either Arduino or NodeMCU and DHT11 or DHT22 sensor or sensor module. Temperature and humidity readings can be collected using either a DHT11 or DHT22 Module or by using one of these sensors with a 10K resistor. The bottom section of the board is for the OLED display. The attached gerber is bit different from what you see on screen. I made some modifications in the final version and moved the sensors a bit far from the microcontrollers. Component Assembly Lets start by soldering the female pin-headers to the board. The pin-headers will house the NodeMCU in it. Next, lets soldered few more pin-headers for the LEDs, DHT11 sensor and the OLED display. Before installing the circuit in the peg-box, lets hook up the OLED Display and make sure everything works as expected. Boom, nailed it. The Code The code starts by including all the libraries and by defining all the constants and variables that will be used throughout the program. Then there are two functions SendIamAlive() and SendTemperatureAndHumidity() which sends heartbeat and the data read from the temperature sensor to the database server. The ReadDHTSensor() function reads the data from the DHT11 or DHT22 sensor. In the setup section we first setup the WiFi and then send a SendIamAlive() message to the server advising that it is back up and running. Then in the loop section the microcontroller send a heartbeat every minute using the SendIamAlive() function and if the time elapses it sends the humidity and temperature data using the SendTemperatureAndHumidity() function. The White LED flashes every seconds and the Blue LED turns on when the device sends the temperature and humidity data to the database server. MySQL So,the data sent by the NodeMCU over WiFi is saved in the MySQL database hosted on a RaspberryPi 4. Here you can see, the microcontroller sends the data every 30 minutes (you can change the frequency) which is then saved in the MySQL database. The data saved on the Pi's MySQL database can then be used to generate various different types of graphs either by using google charts or any other 3rd party application. It totally depends on you how you want to present it. 3D Design Now, lets look at the design of the peg-box. Using freely available pallet planks, I designed the body of the box. The pallet planks I am using are 160cm x 9cm x 2cm (length, width and thickness). So, the rest of the measurements will be based on that. The top bit of the peg-box will house the microcontroller and the sensors in it. Putting it on the top prevents the electronics from adverse climatic conditions. The back bit will stick to wall and hence we don't need to cover it up. You can either put the pegs straight in the front bin or throw it to the top bit, from where it will slide down to the front bin. The sliding design with an opening in the front will prevent rainwater from accumulating inside the bin. This mechanism will keep the bin dry throughout the year. Woodworking Using 2 hammers I am dismantling the pallet. My aim is to reuse all the nails used in building this pallet so that, I can use them in building my project. After that, I sanded the pallet planks to give them a nice and smooth texture. Then using a chop-saw or a hand-saw I extracted all the pieces of wood required for building this project. As mentioned earlier, my pallet plank are 9cm wide and hence, all the onscreen measurements are based on that. Final Assembly Using wood-glue I am joining all pallet planks used in making the box. I got a bit too excited and accidentally deleted one of my recordings. So, I am using 3D animation to show you guys how I joined the two sides of the box. I used a plywood board to created the base of the bin. I glued few cylindrical wooden sticks on the roof of the box. To be very frank these sticks changed the entire outlook of the peg-box. Coloring Since my aim is to install the peg-box outside the house, I have to make sure that I apply multiple coats of paint on the box to avoid the pallet wood from rotting. I applied 3 coats of paint on the entire setup and insulated all the holes that I found using wood putty. So, this is how it looks like. The electronics bit will stay hidden under the roof of the box. Ha ha, Don't worry, I will obviously insulate them and make them weather-proof before installing them on the wall. Installation Now the next thing you need to do is to find a spot where you want to install this unit. I am installing this near my clothesline, however you may want to install it in your pantry or behind a door or something like that. It totally depends on how much space you have and where you want to install it. I am using metal frame hangers to hang this on the wall. Place the unit against the wall, and using a pencil mark the points where you want to drilling the holes. Now, using a hammer drill, drill the holes in the wall. Then, put the wall plugs in the wall and then use a screw driver to install the screws. Alright so, that's it. This unit is now all set to hold all my pegs in it. Demo So, this how my final setup looks like. Do comment and let me know if there are any scopes of improvement. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Blog Posts: 1. Peg Box 2. DHT11 & DHT22 3. OLED Tutorial Video references: 1. Peg Box 2. DHT11 & DHT22 3. OLED Tutorial Resources: Gerber Schema 3D Model Code: Code (Arduino + PHP + MySQL DB) Code_With_OLED_Arduino Code_With_OLED_NodeMCU Code_With_PHP_NodeMCU Libraries: DHTStable.h SSD1306.h Adafruit display library Adafruit GFX library Support My Work: BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  4. I love mining and I truly believe that blockchain and digital currencies will one day change the world. Cryptocurrency has played a significant role in my life and has made me a morning person, ha ha. Miners require 24 x 7 access to the Internet. Recently, I went on a short business trip and my router for some stupid reason stopped working. I lost complete access to my home network and my miners. When I returned from my trip, my only aim was to fix this issue by creating an "Internet Hardware Watchdog" that reboots the router whenever something silly happens to it. Note: If you do any work with "mains power" such as 120v or 240v AC power wiring, you should always use proper equipment and safety gears and determine whether you have adequate skill and experience or consult a Licensed Electrician. This project is not intended for use by children. The Logic Let me first explain the logic to you. In a nutshell, in this setup I am going to ping "www.google.com" and as soon as the ping drops I will reboot the router. To achieve this, the NoduMCU first connects to the WiFi network and then pings 8.8.8.8 (www.google.com). If it receives a successful ping, one out of the 3 blue LED patterns is displayed. If the ping fails, 5 more retries are given before rebooting the router. The reason I am NOT rebooting the router straightaway is to avoid false positive ping fail responses. However, once the "fail_count" counter becomes 5, NodeMCU turns off the router by pulling the armature of the relay module. The armature of the relay is held for 15 seconds before releasing it so that the router is properly power cycled. Once the armature is released, the system waits for a minute before sending the next ping request. This gives enough time to the router to successfully perform its POST activities. The above steps are then endlessly repeated in the loop section of the code. Components Required For this project we need: NodeMCU Stepdown Converter Relay Module 2 x Red LEDs 3 x Blue LEDs 100Ω Resistor Power Plug and a Power Socket Schematic Now, let's put the components together exactly the way I have shown in the schematic diagram. Be very careful while handling AC Main Power sockets and cables. The Stepdown Converter powers the NodeMCU and the Relay Module. LEDs are connected to the Digital pins of the microcontroller. The relay acts as a switch and switches on or off the router based on the ping response. Please make sure you check the pins of your relay module before hooking it up to the circuit. The Board So, this is how my board looks like in 2D and 3D. I basically have created a replica of the NodeMCU Prototyping Board which you can buy from AliExpress for about $4 to $6. Components Assembly Lets start by soldering the NodeMCU to the board. Since I care a lot about my Sensors and Microcontrollers, I am not going to solder them directly to the board. Instead I am soldering 'female pin headers' to the board which will house all the sensors and the microcontrollers in them. I initially thought of soldering the LEDs directly on the board however something clicked in my mind and I went ahead and soldered them on a separate perfboard and then soldered the perfboard to the NodeMCU development board. Well, this was totally unnecessary. Once the LEDs were in place, my next step was to solder the step-down-converter and the relay-module to the board. If you want to know how I created this relay module, please check out my tutorial no. 19 DIY Relay Module : https://www.youtube.com/watch?v=3n69b4sdDjk the video and the blog post links are in the description below. Next, I made a hole in the transparent box and glued the power socket into it. Well I created a bit of mess while gluing the socket and accidentally glued the box on to my dining table, silly me. I also drilled a hole at the back of this box, for the cable that will connect to the AC Main power supply. Pretty much that's it. Once again, I would like to warn you guys: If you do any work with the "main power" such as 110v or 240v AC, you should always use proper equipment and safety gears and determine whether you have adequate skill and experience or consult a Licensed Electrician. This project is not intended for use by children. To conclude the setup, I added a small skull inside the acrylic box. This skull has been sitting on my desk just collecting dust for over a year, ha ha. The Code Now, let's have a look at the code. You can download the code and other resources from the links provided in the description below. To Run the attached code you need to download and install the "ESP8266Ping" library. You can either download it from GitHub or from the link provided in the description below. Unzip and copy the archive to the Arduino's Library Folder and change the board type to ESP8266 in the Arduino IDE and select NodeMCU. The code starts by including all the libraries and variables on top. Then in the setup() section I have defined all the pin modes and have made a connection to the WiFi router. In the loop() section I am performing a ping test and based on the test result I am either blinking the blue LEDs or power cycling the router. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Blog Posts: Internet Hardware WatchDog : https://diy-projects4u.blogspot.com/2021/12/internet-hardware-watchdog.html DIY Relay Module : http://diy-projects4u.blogspot.com/2020/08/diy-relay-module.html Video: Internet Hardware WatchDog : DIY Relay Module : https://www.youtube.com/watch?v=3n69b4sdDjk Other Resources: Code: https://drive.google.com/file/d/1HyTUMUBDK0neO854XMl3dyy5ceoeTImw/view?usp=sharing ESP8266Ping Library : https://github.com/dancol90/ESP8266Ping.git ESP8266Ping Library : https://drive.google.com/file/d/1uFfY5wW7-oWRNjP_XaBj2IM189M1n1FK/view?usp=sharing Schema: https://drive.google.com/file/d/1gn2ZhMp5Uz4YDv5GjxgIq1rtzh-21Rwe/view?usp=sharing Gerber File: https://drive.google.com/file/d/1l0bszJ0AV7S9s-y9jTWGcw9MrWayVJxZ/view?usp=sharing Flowchart: https://drive.google.com/file/d/1CL3g0nT1IZfdL8MZqN_PB-mKC9k_JfWH/view?usp=sharing Support My Work: BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  5. If you have ever programmed a NodeMCU, then I bet you know the pain you have to go through while connecting sensors to NodeMCU on a breadboard. I looked for various solution on the web and found "NodeMCU Development Boards" for around $6 to $7. Well, I wasn't ready to spend that much for a simple projects. So, I went ahead and designed a replica of those boards, which, 10 of them I got fabricated from PCBWay for just $5. PCB Design Let me first show you the design of the board. I have placed the NodeMCU in the middle of the board. On the right hand side are the extensions of all the digital pins. And on the left hand side are the extensions of the left hand side pins. Starting from left to right I have the VIN and the -VE pin to power up the NodeMCU at the bottom left hand side of the board. NodeMCU has an inbuilt LDO voltage regulator which keep the voltage level at 3.3v so there is no need for an additional voltage regulator. Just above that, is a series of GND pins. On top of that is a series of +5v and GND pins, followed by a series of 3.3v and GND pins. I have also added a series of 3v3 and GND pins on the top right hand side of the board. Then there is a reset button and a set of TX and RX pins for serial communication. On the same breakout board I have also added an Arduino Nano's Development Board. Since, I had a fair bit of real-estate left on my board, I created a generic PCB out of the left over space. PCB Assembly Lets start by soldering the male and the female pin headers to the board. It really doesn't matter, what order you solder the components to the board. The only think to remember is that, do not solder a component that blocks another one. As you can see, I am soldering both male and female pin headers side by side on the board so that sensors with either male or female pin header can be hooked up to the board, making it more generic and expandable. So, this is how the final setup looks like. Please comment and let me know if there is any scope of improvement, thanks. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Blog Posts: https://diyfactory007.blogspot.com/2021/11/nodemcu-development-board.html YouTube: https://youtu.be/y2m2nh7wHaY Odysee : https://odysee.com/@Arduino:7/DIY---NodeMCU-Development-Board:1 cos.tv : https://cos.tv/videos/play/32048547001832448 Schema : https://drive.google.com/file/d/1XRR2sNZ5t4NhLFla9X3DyjaPAujrjeGY/view?usp=sharing Support My Work: BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  6. Created a touchless Covid Free Electronic Dice using Arduino to play some board games with my son. My new project is an amazing way of giving our younger generation the taste of board games while staying COVID free. Total cost: AU$12 Time taken: 4hrs Components Required For this project we need: 1 x Push Button Switch 1 x Arduino Nano R3 (or ESP8266) 1 x 8x8 Led Matrix with MAX7219 IC 1 x Step Up Power Module [MT3608] 1 x IR Sensor 1 x AA Battery Holder and Batteries and Some Connecting Cables Circuit Diagram Using a Step Up Power Module connected to 2 x AA batteries I am powering up the Arduino Nano. In my logic, I am using an IR Module to send interrupts, which changes the face of the dice which is then displayed using a 8x8 LED Matrix. If you want to know more about the DIY IR module please check out my "Tutorial No. 21: DIY - IR Module". Link is in the description below. Video: https://youtu.be/_M8FQIPi1qk Blog : http://diy-projects4u.blogspot.com/2020/10/diy-ir-module.html If you want to change the face of the dice by shaking it, you can use a tilt sensor to generate the interrupts. If you want to store the results in a database, you can use a ESP8266 board and send the result over WiFi and store it in a database. The possibilities are endless, however, I just want to keep my circuit simple. The Code The code is very simple. Lets start by including the "LedControll.h" library. I have included the link to the library in the description below. Next, lets define all the pins that we are going to use in our code. After that, you will find few functions that work in combination to generate the dice faces and the dice animation. In the setup() section, we are setting up the pinMode of the IR Sensor and initializing the display. We are also showing the initial animation where in my case, number 6 flies from right-to-left and fills up the led display. In the loop() section I am reading the IR sensor to check if someone has moved their hand over the sensor module. If a motion is detected, then a random number between 1 and 6 is generated, and based on that the face of the dice changes using ShowDicePic() function. Housing Design Now lets create the body of the dice. From a broken piece of chipboard, I extracted the 6 sides of the dice. Next, using a double-sided tape I attached the AA battery holder to the bottom of the dice. Then, I soldered the step-up converter to the AA battery holder. The step-up boost converter has to be adjusted to approximately 5V before installation by twisting the variable resistance in it. I made a hole on one of the sides for the push button switch, and then glued the push button switch to it. I hot-glued the 8x8 LED matrix to the top section of the dice. 8x8 LED matrix with MAX7219 driver IC, is a very cheap, easy to code and it takes up very little space in your project. The top section also has the IR transmitter and receiver LEDs. Pretty much I hot glued them all and then attached them to a Arduino Nano. Then, I made 4 holes on the bottom plate and attached the all the sides to it. Lets do a quick test before finalizing the project. Looks promising, isn't it? Cool, so this is how my final setup looks like. I covered the LED Matrix with a translucent black sheet. Let me know what you guys think of this project. If you have any suggestions or advises please feel free to drop a comment below. Thanks Thanks again for checking my post. I hope it helps you. If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3 Blog Posts: 1. Arduino Dice : https://diy-projects4u.blogspot.com/2021/10/arduino-dice.html 2. DIY IR Module: http://diy-projects4u.blogspot.com/2020/10/diy-ir-module.html Video references: 1. Arduino Dice : https://www.youtube.com/watch?v=a4CnaDDR2x0 2. DIY IR Module: https://www.youtube.com/watch?v=_M8FQIPi1qk Schema: https://drive.google.com/file/d/168eiuHINb_5dGh9wBQ1qDsTv3bXY39Hj/view?usp=sharing Code : https://drive.google.com/file/d/1jLRFUFD3P037GIfAIZJU2GpHcbZOxgpc/view?usp=sharing LedControll.h : https://drive.google.com/file/d/1U5SFjC8Q6bB_X8ZQeJ6Ifq7ID5iecZ0K/view?usp=sharing Support My Work: BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60 LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2 Thanks, ca again in my next tutorial.
  7. The very first program you write when you start learning a new programming language is: "Hello World!". The program itself does nothing more than printing a “Hello World” text on the screen. So, how do we get our Arduino to display the "Hello World!"? In this video, I will be showing you how to get started with the small 0.91 (128x32) and 0.96 (128x64) I2C OLED displays. There are 100s of tutorials on the web explaining the same thing in different ways, but I couldn't find one that tells me all about the OLED display and how to use it in different scenarios. It took me some time to work it all out. So, I thought I should create a tutorial on what I have learned and combine all the features and ways the OLED displays can be used in our projects. Step 1: Things We Are Going to Learn Today In this video we will be talking about: - What is an OLED display? - Then we will have a closer look at the 0.91 (128x32) and 0.96 (128x64) I2C OLED displays - Next we will talk about installing the Adafruit Library to your Arduino IDE - Then we will connect NodeMCU and Arduino to an OLED display - Next we will have a look at the code and display some graphics and text on it - We will also talk about applying Custom Fonts and displaying Images - Then we will connect Multiple OLEDs to a micro-controller using I2C Multiplexer - Finally, we will talk about few common errors people make while using the OLED displays Step 2: Hardware Requirement For this tutorial we need: - A Breadboard - A 0.91" (128x32) and 0.96" (128x64) I2C OLED displays - Arduino UNO/NANO (whatever is handy) - NodeMCU - TCA9548A I2C multiplexer - Few Connecting Cables - and a USB cable to upload the code Step 3: What Is an OLED Display? OLED or organic light-emitting diode is a light-emitting diode (LED) in which the emissive electroluminescent layer is a film of organic compound (millions of small LED lights) that emits light in response to an electric current. OLEDs are used to create digital displays in devices such as television screens, computer monitors, portable systems such as mobile phones, hand-held game consoles and PDAs. An OLED display works without a backlight because it emits visible light. There are many types of OLED displays available in the market based on their - Sizes - Color - Brands - Protocol - SPI (Serial Peripheral Interface) or I2C - Passive-matrix (PMOLED) or active-matrix (AMOLED) control scheme In this tutorial, I am going to talk about connecting the blue color 0.91 (128x32 OLED) and 0.96 (128x64 OLED) I2C OLDE displays to an Arduino NANO and NodeMCU. I2C bus technology uses only 2 pins of the MCU so we have heaps available for other sensors. Step 4: Closer Look Lets have a closer at these two displays. At the back of these displays there are heaps of SMD capacitors and resistors soldered on-board; but, since its an I2C device we only care about these 2 pins (SCL and SDA) The display connects to Arduino using only four wires – two for power (VCC and GND) and two for data (serial clock SCL and serial data SDA), making the wiring very simple. The data connection is I2C (I²C, IIC or Inter-Integrated Circuit) and this interface is also called TWI (Two Wire Interface). - The on-board pins can be in different order, so always triple check before hooking it up to your project. - Operation voltage is between 3v to 5v but, it is best to use the guidance from the manufacturer's datasheet. - Sometimes we need to use 2 displays in our projects. So, how can we achieve this? The trick is to have a configurable address on your display. This unit has a configurable address between 0x78 and 0x7A. Just by unsoldering the 0Ohm resistor from one side and hoking it up to the other side or just by putting a global solder we can change the address. We will talk about it in depth when we hook up multiple displays to an Arduino in the later section of this tutorial. In picture these displays look very big. But, practically speaking they are tiny. They are made of 128 x 32/64 individual OLED pixels and do not require any back-light. Just have a look at this and see how small it is. Even though they are small they can be very useful in any electronic projects. Step 5: Library There are several libraries available to control these displays. In past I have used the "u8glib library" but I find the AdaFruit library very easy to understand and use in our projects. So, I am going to use the AdaFruit library in this tutorial. To control the OLED display you’ll need the "adafruit_GFX.h" library and the "adafruit_SSD1306.h" library. There are two ways you can download and install the library to your Arduino IDE. Method 1 Go to the "Library manager" and search "adafruit_SSD1306" and "adafruit_gfx" Select the latest version and hit the Install button. Once installed you can use these libraries in your program. Method 2 These two libraries can be also be downloaded from github (you need both): I will provide the links in the description below. The display library: https://github.com/adafruit/Adafruit_SSD1306 The GFX library: https://github.com/adafruit/Adafruit-GFX-Library Once downloaded, copy the Adafruit_SSD1306-master folder from the downloaded zipped file into the Arduino libraries folder. This folder is usually found at Documents > Arduino > libraries on Windows systems. On Linux it is usually found at home folder > Arduino > libraries. Finally in the Arduino library folder, rename the Adafruit_SSD1306-master folder to Adafruit_SSD1306. Even if you don’t rename that’s fine. Now, lets have a look at the "Adafruit_SSD1306.h" file Two things we need to know in this library: 1. If you want to use the smaller display use the default 128_32 otherwise for the bigger display comment the 128_32 and uncomment the 128_64 2. If you have soldered the 0x7A Address on the board (which we will talk about later) then use the 7 bit 0x3D address for the bigger displays, otherwise use the default 0x3C address. For the smaller displays the address is 0x3C. Step 6: Wiring 128 X 64/32 OLEDs Lets start by connecting the NodeMCU to the display. The first and most important thing to note is that some of the displays may have the GND and VCC power pins swapped around. Check your display to make sure that it is the same as the image. If the pins are swapped, make sure to change the connections to the Arduino or NodeMCU. - NodeMCU OLED Wiring OLED VCC – NodeMCU 3.3V OLED GND – NodeMCU GND OLED SCL – NodeMCU D1 OLED SDA – NodeMCU D2 - Arduino Uno OLED Wiring OLED VCC – Arduino 5V OLED GND – Arduino GND OLED SCL – Arduino Uno A5 OLED SDA – Arduino Uno A4 - Arduino MEGA 2560 OLED Wiring OLED VCC – Arduino 5V OLED GND – Arduino GND OLED SCL – Arduino MEGA 2560 pin 21 OLED SDA – Arduino MEGA 2560 pin 20 Step 7: Code Adafruit library comes with really good examples for both 128x32 and 128x64 displays. The Library is located under File > Examples > Adafruit SSD1306 > and then the display type in the Arduino IDE. We are going to use the 128x32 I2C example and will modify it to work with both 128x64 and 128x32 displays fist by hooking it up to an Arduino and then to a NodeMCU board. The code starts by including both the Adafruit libraries. In this tutorial I am going to stress on only those parts of the code which are necessary for us to load on both boards and displays. If you want to know more about the code please drop a comment on my blog or in the comments section below and I endeavour to get back to you. - First we are going to load the code to an Arduino Nano connected to a 128x32 display. We can use the code as is without any modifications. 128x32 uses 0x3C address so this bit looks all good here, lets double check the header library, yes its also using the 0x3C address and the display type is 128x32. - Now lets connect the 128x64 display. As we know it uses the 0x3C address by default so we don't need to update the address in either the code or the library. We just need we need to comment the 128_32 and uncomment the 128_64 in the header library and change the LCDHEIGHT to 64 in our code. - Now to run the same code on a NodeMCU we need to change one more line in our code. The "#define OLED_RESET 4" > "#define OLED_RESET LED_BUILTIN" rest of the code is same as Arduino Pretty much to display anything we first need to clear the previous screen using display.clearDisplay(); // Clear the buffer Then draw the object testdrawline(); // Draw a line Show it on the hardware display.display(); // Make them visible on the display hardware! Wait for some time before displaying the next item. delay(2000); // Wait for 2 seconds In this example we are displaying few items like text, lines, circles, scrolling text, triangles and more. Go ahead and use your imagination and display whatever you want on these tiny displays. Attachments Libraries.zip Download NodeMCU.zip Download Step 8: Customizing Text & Adding Images Sometimes your code needs to display custom fonts and images. If you are very good in bit mapping then you just need to create a byte arrays by turning on or off the tiny LEDs of the display to create custom fonts and images. However, I am not very good in doing these mappings and don't want to spend hours creating the bit map tables. So, what are my options? I generally use two websites to generate custom fonts and images. The links are provided in the description below. Custom Fonts ------------ Go to the font converter website, select the font family, style, size, Library Version as "Adafruit GFX Font" and then hit the "Create" button. On the right hand side of this page you can see how your font is going to look like on the actual display. Based on your selection the webpage generates the fonts header file. Create a file called "modified_font.h" in the same folder where your code is and copy and save the generated code into it. Then you just need to include the header file in your code to use the custom font. #include "modified_font.h" Then, you just need to set the font before displaying the text to apply the custom font to it. display.setFont(&Your_Fonts_Name); You can get the name of the font from the header file you just added to your project. Thats it, easy. Memory is always a concern while using custom fonts, so always consider the bytes that will be consumed by the memory. Just remember Arduino UNO has only 32K of memory. Custom Images ------------- To display a bitmap image on your screen you first need to create a 128 x 64/32 sized image. I am using the good old "MS Paint" to create a 128 x 64 bitmap image which I will then upload to this image converter website. The website converts images into byte-strings, which can be used with Arduino and OLED displays. Start by uploading the image to the website. Then put a check on the "Invert image colors" check-box and change the "Output code format" to "Arduino Code" next select the orientation and hit the "Generate Code" button to generate the byte array. The "Preview" section shows you how your image will look like on the actual display. I have included the code along with this tutorial which you can use to display your images. You just need to replace the array in my code with the one you just generated and then load it to your Arduino. Attachments Custom_Font.zip Download Custom_Image.zip Download Step 9: Connecting 2 Displays Connecting two 128 x 64 displays to your project is easy. You just need to unsolder the 0Ohm resistor from 0x78 address and put it on 0x7A and then use the 0x3D address in your code instead of the default 0x3C. You must be wondering why we are using the 0x3C and 0x3D address and not the actual 0x78 and 0x7A. Arduino accepts 7-bit address and not the 8-bit hardware addresses. So, we first need to convert the 8-bit address to binary, and then chop off the least significant bit to get the 7 bits. Then convert the 7 bits to HEX to get the 0x3C or 0x3D addresses which you enter in your code. First, initialize the display by giving it a unique name: Adafruit_SSD1306 display1(OLED_REST); Adafruit_SSD1306 display2(OLED_REST); Then in your code use the display 1 and display 2 to call the begin statements with the device addresses in them: display1.begin(SSD1306_SWITCHCAPVCC, 0x3C); // display 1 op address 0x3C display2.begin(SSD1306_SWITCHCAPVCC, 0x3D); // display 2 op address 0x3D That's it, you can now go ahead and do whatever you want using either Display 1 or Display 2 in the rest of your code. I have provided an example with this tutorial. Wiring is exactly the same as what we have done before, pretty much you just need to add another display to the same I2C pins of either the Arduino or NodeMCU. Based on the addresses, the MCU then sends the data on the I2C data line. Attachments Two_OLEDs.zip Download Step 10: Connecting More Than 2 Displays 3 More Images Now, what if you want to hook up more than 2 displays? Arduino has limited number of pins and hence you cannot have more than a certain amount of shields attached to it. Moreover, it has only one pair of I2C buses. So, how can we attach more than 2 I2C displays to an Arduino? The trick is to use a TCA9548 Multiplexer. TCA9548 allows a single micro-controller to communicate with up to '64 sensors' all with the same or different I2C address by assigning a unique channel to each sensor slave sub-bus. When we talk about sending data over 2 wires to multiple devices we then need a way to address them. Its same as the postman coming on a single road and dropping the mail packets to different houses because they have different addresses written on them. The Multiplexer connects to 3V3, GND, SDA and SCL lines of the micro-controller. The slave sensors are connected to one of eight SCL/SDA slave ports on the board. The channels are selected by sending the TCA9548A its I2C address (0x70 {default} - 0x77) followed by the channel number (0b00000001 - 0b10000000). You could have at the max 8 of these multiplexers connected together on 0x70-0x77 addresses in order to control 64 of the same I2C addressed parts. By connecting the three address bits A0, A1 and A2 to VIN you can get different combination of the addresses. I will explain this in-depth in my next tutorial on TCA9548A breakout board. For now, lets just hook up 8 OLEDs to this board and have a quick look at the code. Connection: VIN to 5V (or 3.3V) GND to ground SCL to I2C clock SDA to I2C data Then wire up the sensors to VIN, GND and use one of the SCn / SDn multiplexed buses Now, Int the code lets start by including the "Wire" library and by defining the multiplexers address. #include "Wire.h" #include #define MUX_Address 0x70 // TCA9548A Encoders address Then we need to select the port we want to communicate to and send the data on it using this function: void tcaselect(uint8_t i) { if (i > 7) return; Wire.beginTransmission(MUX_Address); Wire.write(1 << i); Wire.endTransmission(); } Next we will initialize the display in the setup section by calling "u8g.begin();" for each display attached to the MUX "tcaselect(i);" Once initialized, we can then do whatever we want just by calling the function "tcaselect(i);" where "i" is the value of the multiplexed bus and then sending the data and clock accordingly. Attachments I2C_Port_Scanner.zip Download Multipe_OLEDs.zip Download Step 11: Advantages and Disadvantages The image of an OLED is beautiful. However, OLEDs also have disadvantages. Because OLED screens contain organic material, their lifespan is shorter than LCD displays. Additionally, many OLED displays get burn-ins after showing the same image for a long time. After a burn-in, the image stays on the screen even after showing another image. So make sure you keep refreshing the screen every few seconds. Water can instantly damage the organic materials of these displays. Advantages No need for a backlight Displays are very thin and lightweight Low power consumption Viewing angles are wider than LCDs Brightness and contrast are great High speed and have low response time Deep black color Disadvantages Costly technology Short lifecycle OLEDS are more likely to burn-in Water damage Step 12: Common Errors To conclude the tutorial lets talk about few common errors people make while using these displays: - Always triple check the pins before using it in your project - Pick up the right library address in the header file and in your code #define SSD1306_I2C_ADDRESS 0x3C // in Adafruit_SSD1306.h and display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // in your code If the address is wrong the OLED will not display anything - The display size must be changed in the driver before it can be used. If it is not changed you will get an error message when attempting to verify the code #error ("Height incorrect, please fix Adafruit_SSD1306.h!"); - If using NodeMCU make sure you replace the OLED_RESET from 4 to LED_BUILTIN #define OLED_RESET LED_BUILTIN I have scene people making all sorts of things using this OLED display. Some have even made video games and all. I am really not interested in making a video game using this tiny display. However, I will now leave you to explore your imaginations and come out with amazing ideas. - Blog: http://diyfactory007.blogspot.com.au - Add Image: http://javl.github.io/image2cpp/ - Custom Text: http://oleddisplay.squix.ch/#/home - Adafruit display library: https://github.com/adafruit/Adafruit_SSD1306 - Adafruit GFX library: https://github.com/adafruit/Adafruit-GFX-Library - u8glib library: https://code.google.com/archive/p/u8glib/ or https://github.com/olikraus/u8glib If you want to use the smaller display use the default 128_32 otherwise for the bigger display comment the 128_32 and uncomment the 128X64 NO_ACK in your code (just uncomment the type of screen you are using) (fonts are in the fonts library) Attachments DataSheets.zip Download LCD-U8glib.zip Download OLED_Graphing.zip Download Schema.zip Download
  8. HI Everyone Im trying to connect the A6 Module to a nodemcu Version 3.without success, Does anyone have experience how to set this up and communicate between the 2 modules? All help appreciated Thanks Meir
×
  • Create New...