Many people in Scouting will know JOTI. It is an annual weekend where scouts of all ages can communicate with eachother using IRC servers and clients.
More information about this can be found on: the scouting jota/joti website.
During this weekend a number of activities are done, including games and small projects.
Here is one of these projects: a digital temperature/humidity gauge using arduino!
The project is entirely put together and programmed by a member of Scouting Geulle in the Netherlands, and is free to use for anybody.
It can do multiple things with the same project, showing the power of using an arduino. The code can be set up to do the following things:
- a temperature and humidity gauge, with several options on how it displays these values
- a simple stopwacht
- a reaction game
Updated version! Please check out the update at the end of the page!
For this project a minimal amount of parts is needed:
- 1 arduino nano V3, 5 volts, atmega328p
- 1 breadboard with 400 contacts
- 1 DHT-12 sensor
- 1 TM1637 4 segment LED display with a : seperator in the middle
- 10 DUPONT cables, 10cm, male-male
- 1 switch, make contact, printmodel
- 1 antistatic bag, 100 X 150 mm to store a complete package in
- 1 USB cable (for all the projects only one is needed)
All of these parts can be obtained very cheap on aliexpress and other websites. When buying in bulk (for about 100 packages) the price per complete project comes down to about $7.
The reason for the breadboard is twofold: it's hard to get enough solderingstations on a weekend when dealing with 50 scouts. With a breadboard none are needed. Also, this way burning fingers isn't an issue, especially with the younger kids.
First, you will need the arduino IDE software for programming the project.
The latest version for this is downloadable from: https://www.arduino.cc/en/main/software
To make sure you have a working version, there is a direct download for the arduino IDE version 1.8.5 right here: arduino ide
Download it, open the zipfile and copy the folder 'arduino 1.8.5' to your desktop.
Drivers
Once you have downloaded
Once set up, you will also need a driver for the arduino nano. There are drivers included in the arduino install, but it might happen that no driver is available.
If you (like me) ordered the arduino's in china, it probably has a different serial chip.
The drivers for this chip:
Windows 7: Arduino driver
Download and install it, then plug in the arduino, it should recognize it as a COM port.
Windows 10:
It is a bit of a hit and miss in windows 10. Just plug in the arduino and wait. Sometimes windows 10 will find a driver online for it!
It might take up to 15 minutes to find it though..
If for some reason it just won't install the driver, things get a little more difficult.
First, download the driver here CH341SER.EXE
and run the install
Then, know solutions are:
- disabling the driver signing enforcement:
Start by pressing ALT-X (alt key + X key at the same time)
You will see a menu, select 'command prompt (admin)'. Click that option.
Then, enter:
disable driver signing
bcdedit /set testsigning on
If you see 'the operation completed successfully' it worked.
Now, restart your computer and install the driver by plugging in the nano on USB.
Once installed, do the same thing but enter:
enable driver signing
bcdedit /set testsigning off
- using a USB2 port, not a USB3 (usually a blue one)
The code
Last, you need the code to make it work!
All documents and code needed for this project can be downloaded here as one zipfile: arduinojoti.zip
Once unpacked, you have a folder with 2 main items in it:
- board layout.jpg - the board layout and connections
- arduinojoti - the source code for the project, including needed libraries
Copy these files in an easy to find folder.
Documents
The document that can be included in the kit can be downloaded werkbladen.doc
Unfortunately, this is in dutch. If you would like an english version, let me know (use the email on the main page).
First start by building the project:
- Make sure you have all the parts needed
- Start with the arduino. Place it on the left hand side of the board, with the USB port pointing outward.
- Stick the sensor in the board, making sure that the holes in it are pointing to the center of the board.
- Make all the connections with the dupont cables as shown on the picture included in the documents. The pins go on the endpoints of the lines.
- Stick the switch in the board. Be carefull, since it is a pcb switch, the pins are easy to bend. It won't sit as snug also on this board, so make sure to push it in well.
- Stick the display on the board, the display itself should point outward.
- Recheck all connections again to make sure everything is correct.
That's all for building the project!
To make the project do anything at all, the arduino needs to be programmed.
To do this, start the arduino IDE and open the file arduinojoti.ino
This code can actually do several things with the project. For this there are several so-called DEFINE lines to tell the code what to do.
The code is written in dutch, so the most imporant comments are translated here.
display brightness
The line #define BRIGHTNESS 20 tells the arduino how bright the display should be. Allowed are values from 0 (= off) to 100 (= full on).
Program mode.
#DEFINE PROGRAMMA 1
this line defines what the code actually does with the project:
- 1 - temperatyre/humidity gauge
- 2 - stopwatch
- 3 - reaction timer. The display will show WAIT for a random time, blinking the :. As soon as the counter starts, you hit the button. The time shown is the time it took to react in milliseconds.
if double lines are shown, you pressed to early. If you wait to long, STOP is shown. In either situation, another push on the button will reset the game and start over.
- 8 - just a silly display test, funny to watch
- 9 - a sensor tester, in case there is doubt the sensor is working. It needs the serial console of the arduino IDE to show the values.
Switch function
#define SCHAKELAARFUNCTIE 0
The switch in the project can have different functions, depending on the program mode that is selected.
For program mode 1, there are 4 different functions for the switch:
- 0 - no function. The display is always on and the temperature and humidity are switched constantly.
- 1 - the display will always be on, but the switch is used to switch between temperature and humidity.
- 2 - the display is off by default (except after starting). The switch will switch the display on exactly long enough to show 1 cycle as in mode 0
- 3 - a combination of 1 and 2 but the switch will also be used to switch between temperature and humidity.
For program mode 2
the switch is used to start, stop and reset the clock, in that order.
For program mode 3
the switch is used to stop the counter.
Delay time
#define DISPLAYDELAY 2
defines how long the temperature and humidity is shown in seconds. The default is 2 seconds for each.
Screen off time
#define DISPLAYOFF 4
defines how long the sreen will stay on after one press of the button (in switch mode 2 and 3). The default is 4 seconds, exactly enough time to show the temperature and humidity 2 seconds each
Sensor correction
Since these cheap sensors (DHT-12) are not calibrated officially, they might deviate from the actual temperature by a couple degrees. Also the humidity might differ a little.
This deviation is not the same for all the sensors.
To be able to correct this deviation, 2 lines are added:
#define TCORRECTIE 0
#define HCORRECTIE 0
The way to go about setting the correct value for these is first to have a calibrated temperature and humidity gauge to compare to
Then, leaving both at 0, check the measured temperature and humidity on the arduino.
Now write down the difference for both, and subtract the measured value from the calibrated value, and put that on TCORRECTIE for the temperature, and HCORRECTIE for the humidity.
After uploading the project to the arduino again, it should now have the correct temperature and humidity
After all the changes are made (or none, the code defaults to program 1, switch function 0), it's time to program the arduino!
For this, you only have to click on the 'upload' button of the arduino IDE on the top left.
You should see the led flicker, after which the arduino will start executing the program and the display should light up showing the temperature and humidity.
After the arduino has been programmed with the wanted options, it will run off of any USB connection providing it with 5 volts. So any charger, usb port and powerbank will make it run!
Yes, kids are wonderfull. While doing the project, a couple of kids were wondering: Why can't i switch the program without reprograming?
Good question!
So version 2 was born. Another nice idea is to power the project using 2 CR2032 batteries. The changes compared to version 1:
- The position of the parts has been altered to accomodate the batteries on the board.
- It has 2 switches instead of 1.
- It has 2 cr2023 battery holders (and batteries) added, so the project can run without usb cable!
- It needs 12 dupont cables instead of 10.
- Different code, again downloadable as a zipfile: arduinojoti_v2.zip
- A new worksheet for this project: werkbladen_v2.doc
The extra cost: about $1 for everything if you buy it in bulk
You could leave out the batteries and power the project another way. In which case the parts can stay where they are and only the switch position and connections change.
Build up the project as before but take note of these points when building:
- Program mode 8 is now program mode 4.
- Do not make the white connections yet
- The switches have to be altered slightly before they are put on the board: cut away the top-left pin of the left switch and the top-right pin of the right switch.
- Once everything is done, put the battery holders on the board. The green connections of the holder are on the right spot. To connect the red (minus) connections, you have to rotate the holders.
The red connection of the top one has to connect to the topmost row, the red connection of the bottom holder has to connect to the lowermost row.
Once they are in place, connect the white wires but do not insert the batteries yet.
- NEVER power the arduino using the batteries when plugging in the usb cable!! If the batteries are inserted, just disconnect one of the white connections before plugging in the USB cable.
Now, you can start programming the arduino exactly the same as version 1 but using the version 2 code.
In the code settings, the setting called PROGRAMMA is now the starting program for the arduino when it powers up.
The left switch has the same function as the single swith in version 1. The right switch will switch the running program!
In the screen testing mode (program 4), just keep the switch pressed while it it running, eventually it will switch to program 1 again.
There are not many things that can go wrong with this project, but like anything, something can (and probably will on occasion).
The most common problems are listed here:
The arduino is not doing anything (no led is lighting up)
Most likely problem: the USB cable is defective or not plugged in correctly. Most unlikely cause: defective arduino
Easy to test by plugging the usb cable into a phone. If it charges, the arduino is defective.
The display is not showing anything
Most likely the connections to the display aren't right. The display can handle the signals being on the wrong pin, so solving it is simple: check the connections if they are in the right spot.
If they are, test with another display unit. If that lights up, it's a defective display. If it doesn't, check the display with another arduino, it might be a broken port on the arduino.
The display is showing weird values for temperature and humidity
Most likely this is either a wrongly connected sensor or broken sensor. Check the connections. If these seem ok, replace the sensor with a known to be good one.
Also, program mode 9 can be loaded to check the values coming out of the sensor.