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.
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'm going to create a peg box using the same board but with a little bit of twist. In this
setup, I'm going to send the temperature and humidity readings to a 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. This video is sponsored by PCBWay. PCBWay
specializes in manufacturing of very high quality, low volume, colored PCBs at a very budgetary price.
In addition to standard PCBs, you can order advanced PCBs, aluminum PCBs, rigid flex PCBs.
They also provide PCB assembly and other related services which can meet your need
at the greatest extent. Talking about the quality, it's absolutely mind-blowing.
The setup is very simple. The temperature and humidity sensor sends the collected data to
the NodeMCU on pin number D3. NodeMCU then sends the data over Wi-Fi 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 pin number D6 of the NodeMCU. The blue LED connected
to pin number D5 lights up when NodeMCU sends the temperature and humidity readings to the database.
If you are planning to install this box somewhere inside your house,
then you can also add an OLED display and display the readings on it.
So this is how my board looks like in 2D and 3D. There are three breakout boards in this 100cm
by 100cm assembly. Each board can be used with either Arduino or NodeMCU and DHT11 or DHT22
sensor or sensor module. The board can be used with either NodeMCU or Arduino Nano.
Temperature and humidity readings can be collected using either 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 a bit of
modification in the final version and moved the sensor a bit far from the microcontrollers.
Let's start by soldering the female pin headers to the board. The pin headers will house the
NodeMCU in it. Next, let's solder few more pin headers for the LEDs, DHT11 sensor and the OLED
display. Before installing the circuit in the PEG box, let's hook up the OLED display and make sure
everything works as expected. Boom! Nailed it! 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 sendIMLive and sendTemperatureAndHumidity which sends heartbeat
and the data rate from the temperature and humidity sensor to the database server.
The readDHTSensor function reads the data from the DHT11 or the DHT22 sensor. In the setup
section, we first set up the Wi-Fi and then send the sendIMLive message to the server advising that
I am back up and running. Then in the loop section, the microcontroller sends the heartbeat
every minute using the sendIMLive function and if the time elapses, it sends the humidity and
temperature reading using the sendTemperatureAndHumidity function. The white LED flashes
every second and the blue LED turns on when the device sends the temperature and humidity data to
the database server. So the data sent by the NodeMCU over Wi-Fi is saved in the MySQL database
hosted on the Raspberry Pi 4. Here you can see the microcontroller sends the data every 30 minutes
which is then saved in the MySQL database. The data saved on the Pi's MySQL database can then
be used to generate various types of graphs either by using Google Charts or any other third-party
application. It totally depends on how you want to present your data. Now let's look at the design
of the peg box. Using freely available pallet planks, I designed the body of the box. The
pallet planks I'm using are 160 by 9 by 2 centimeter in 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 them on the top prevents the electronics from adverse climatic conditions.
The back bit will stick to the wall and hence we do not 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 the rainwater from
accumulating inside the bin. The mechanism will keep the bin dry throughout the year.
Using two hammers, I'm 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 projects. 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 my project. As mentioned earlier, my pallet
planks are 9 centimeter wide and hence all the on-screen measurements are based on that.
Using wood glue, I'm joining all the pallet planks used in making the box.
I got a bit too excited and accidentally deleted one of my recordings. So I'm using 3D animation
to show you guys how I joined the two sides of the box. I used plywood board to create the base
of the bin. I glued few cylindrical wooden sticks on the roof of the box. To be very frank, these
sticks actually changed the entire outlook of the peg box. 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 three coats of paint on the entire setup and insulated
all the holes that I found using wooden putty. So this is how it looks like. The electronics
bit will stay hidden under the roof of the box. Don't worry, I'll obviously insulate them and
make them weatherproof before installing them on the wall. Now the next thing you need to do
is to find a spot where you want to install this unit. I'm using metal frame hangers to hang it to
the wall. Place the unit against the wall and using pencil, mark the points where you want to
the holes. Now using a hammer drill, drill the holes to the wall. Then put the wall plugs in
the wall and then using a screwdriver, install the screws. Alright, so that's it. This unit
is now all set to hold all my pegs in it. So this is how my final setup looks like.
Do comment and let me know if there are any scopes of improvement. Thanks again for watching this
video. I hope it helps you. If you want to support me, you can subscribe to my channel and watch my
other videos. Thanks. See you again in my next video. Bye now.